Send CRM records in a batch
POST /api/v1/crm/{connection}/records
The key needs the scope leads:write
Applies up to 500 changes from your CRM in one request: contacts, leads, opportunities and sales, each with the CRM's own id.
They are the same records a signed CRM webhook carries, and they pass through the connection's status and field mapping. Records are applied one by one, in order, and each gets its own line in results. Applying a record twice changes nothing. A record that cannot be applied (it names a lead nobody knows, or is not a valid record) is kept as a reconciliation error and reported with result error; the request still answers 200. The key needs leads:write, and sales:write too when the batch holds a sale record: without it the whole batch is refused and nothing is applied.
Request
| Parameter | In | Needed | What it is |
|---|---|---|---|
connection | path | yes | Id of a CRM connection in the workspace of the key. It is the last part of the address of the connection's page under Settings, Connections. |
Idempotency-Key | header | no | Your own unique value for this request, 8 to 191 characters. A repeat with the same key and the same body returns the first response with the header Idempotent-Replay: true instead of applying the batch again. |
Body
| Field | Type | Needed | What it is |
|---|---|---|---|
records | array of object | yes | The changes, oldest first. 1 to 500 in one request. |
records[]. | string | no | What changed, written object.verb: contact, lead, opportunity or sale, then created, updated, deleted or merged. lead.updated is a changed lead. |
records[]. | string | no | The kind of record, when type is not given.One of: contact, lead, opportunity, sale |
records[]. | string | no | What to do with it, when type is not given. The default is upsert: create it or update it.One of: upsert, delete, merge |
records[]. | string | yes | The CRM's own id of the record. A whole number is accepted too. |
records[]. | string (date-time) | no | When it changed in the CRM, as ISO 8601 or Unix seconds. The default is now. For lead status the newest change wins, and a record older than what is already stored is answered stale. |
records[]. | string | no | For a merge: the id of the record that stays. |
records[]. | object | no | The fields of the record, after the connection's field mapping. Each kind of record reads its own fields; anything else is ignored. |
records[]. | string | no | Contact and lead: the name of the person. Opportunity: what the opportunity is called. |
records[]. | string | no | Contact and lead: email address. A lead with the email of a contact already here is tied to that contact. |
records[]. | string | no | Contact and lead: phone number. |
records[]. | string | no | Contact and lead: company. |
records[]. | string | no | Lead: the status in the CRM's own words. It is translated by the connection's status mapping, then by the built-in list; a status found in neither is reported as unmapped_status and the lead keeps the status it has. |
records[]. | string | no | Lead: why it was disqualified or lost. |
records[]. | string | no | Lead: the CRM's id of the contact the lead belongs to, when contacts are sent as records of their own. |
records[]. | string | no | Lead, opportunity and sale: the HeyMySocial id of the lead, when the CRM stores it. It ties the record to a lead that was captured here. |
records[]. | string (date-time) | no | Lead: when the lead came in. Used only when the record creates the lead; the default is updated_at. |
records[]. | string (date-time) | no | Lead: when it was first contacted. It only fills an empty value and never replaces one recorded here. |
records[]. | string | no | Opportunity and sale: the CRM's id of the lead it belongs to. The lead must have been sent on this connection first. |
records[]. | number | no | Opportunity: the estimated value in major units (84000 is 84,000.00). |
records[]. | integer | no | Opportunity: the estimated value in minor units, instead of value. |
records[]. | string | no | Opportunity and sale: ISO 4217 code, three letters. A sale without one is refused as invalid_record. |
records[]. | string | no | Opportunity: the stage in the CRM's own words. |
records[]. | string (date) | no | Opportunity: the day it is expected to close. |
records[]. | string | no | Sale: the CRM's id of the opportunity it closes, when that was sent on this connection. |
records[]. | number | no | Sale: the amount in major units. A negative amount is a refund. |
records[]. | integer | no | Sale: the amount in minor units, instead of amount. |
records[]. | string (date-time) | no | Sale: when the sale happened. The default is updated_at. |
records[]. | string | no | Sale: sale or refund. The default follows the sign of the amount.One of: sale, refund |
records[]. | string | no | Sale: what the amount stands for: booked (the default), invoiced or collected.One of: booked, invoiced, collected |
records[]. | string | no | Sale: a short note, kept with the sale (250 characters). |
curl -X POST https://heymysocial.com/api/v1/crm/01JDEXAMPLE0000000000000000/records \
-H "Authorization: Bearer $HMS_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"records": [
{
"type": "lead.created",
"external_id": "L-1042",
"updated_at": "2026-11-24T10:15:00Z",
"data": {
"name": "Mette Jensen",
"email": "mette@example.com",
"phone": "+45 55 51 23 45",
"company": "Jensen Byg",
"status": "Qualified"
}
},
{
"type": "opportunity.created",
"external_id": "O-311",
"updated_at": "2026-11-24T11:00:00Z",
"data": {
"lead_external_id": "L-1042",
"name": "Roof installation",
"value": 84000,
"currency": "DKK",
"stage": "Quote sent"
}
},
{
"type": "sale.created",
"external_id": "S-88",
"updated_at": "2026-11-25T08:30:00Z",
"data": {
"lead_external_id": "L-1042",
"opportunity_external_id": "O-311",
"amount": 84000,
"currency": "DKK",
"occurred_at": "2026-11-25T08:30:00Z",
"revenue_basis": "invoiced"
}
},
{
"type": "sale.created",
"external_id": "S-89",
"updated_at": "2026-11-25T08:31:00Z",
"data": {
"lead_external_id": "L-9999",
"amount": 1200,
"currency": "DKK"
}
}
]
}'
Responses
200 Every record was looked at. Read results: one line for each record, in the order you sent them.
| Field | Type | What it is |
|---|---|---|
processed | integer | Records that were applied or needed no change. |
failed | integer | Records with the result error. Each is kept as a reconciliation error. |
results | array of object | What happened to each record, in the order sent. |
results[]. | string | The kind of record: contact, lead, opportunity or sale. Missing when the record did not say. |
results[]. | string | The CRM's id of the record. |
results[]. | string | created, updated, linked (tied to a lead or contact that was already here), unchanged, stale (older than what is stored), echo_ignored (a status this product sent, coming back), superseded (a newer status here stands and is sent to the CRM), deleted, merged, skipped or error. |
results[]. | string | The id of the record here, when there is one. |
results[]. | string | More about the result. For error, the kind of problem: unknown_lead, unknown_contact, invalid_record or merge_review. Otherwise a note: unmapped_status (applied, but the status has no mapping), not_linked, kept_locally, relinked, duplicate_marked or erased. |
{
"processed": 3,
"failed": 1,
"results": [
{
"object": "lead",
"external_id": "L-1042",
"result": "created",
"id": "01m88q4x13nxs8p0w4ejpg4rhp"
},
{
"object": "opportunity",
"external_id": "O-311",
"result": "created",
"id": "01m88q4x3a6qtyt80b8e2qk6ry"
},
{
"object": "sale",
"external_id": "S-88",
"result": "created",
"id": "01m88q4x3dspgnkctw8qr2kd54"
},
{
"object": "sale",
"external_id": "S-89",
"result": "error",
"detail": "unknown_lead"
}
]
}
401 unauthenticated: the API key is missing, mistyped, revoked or expired.
The error shape and every code
403 access_denied: the key lacks the scope leads:write, or the batch holds a sale record and the key lacks sales:write. Nothing was applied.
The error shape and every code
404 not_found: no CRM connection with this id in the workspace of the key, or the connection was disconnected.
The error shape and every code
409 duplicate: the Idempotency-Key was already used with a different request, or the first request with it is still running (then retryable is true).
The error shape and every code
422 validation_failed: records is missing, empty, not a list of objects, or longer than 500.
The error shape and every code