Custom Records · 3 min read
Create or Update a Record
Create or update one custom record by its key, and set the contact it belongs to
Creates a record, or updates it if a record with the same key already exists. Fields you send replace the stored values, fields you don't send are kept, and null clears a field. See how updates work.
PUT
/api/v1/objects/{api_name}/records/{key}Headers#
| Name | Required | Description |
|---|---|---|
X-API-Key | Yes | An API key from your organization. See Authentication. |
Content-Type | Yes | application/json |
Path parameters#
| Name | Type | Required | Description |
|---|---|---|---|
api_name | string | Yes | The record type's API name, for example subscription. |
key | string | Yes | The record's key, for example SUB-1042. If data also contains the key field, it must have the same value. |
Request body#
| Field | Type | Required | Description |
|---|---|---|---|
data | object | No | The record's fields, as field name and value. Only fields defined on the record type are accepted. See field values. |
phone | string | No | The owner's phone number in international format. |
email | string | No | The owner's email address. |
external_id | string | No | Your own id for the owner. |
shopify_customer_id | string | No | The owner's Shopify customer id. |
contact_id | integer | No | The owner's Lemu AI contact id. If that contact was merged into another, the record goes to the contact it was merged into. |
Choosing the owner#
Records of a normal record type belong to one contact. A catalog has no owner, so these fields are ignored for it.
- If you send
contact_id, that contact is the owner. - Otherwise, if you send
phone,email,external_idorshopify_customer_id, Lemu AI finds the contact the same way as Send an event. A new contact (taggedrecord) is only created from aphoneoremail. - If you send no owner fields and the record already exists, it keeps its owner.
- A new record with no owner fields is rejected.
Sending a different owner for an existing record moves the record to that contact.
Example request:
curl -X PUT https://app.lemuai.com/api/v1/objects/subscription/records/SUB-1042 \
-H "X-API-Key: lemu_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"email": "priya@example.com",
"data": {
"plan": "Gold",
"status": "active",
"renews_on": "2026-11-30",
"monthly_amount": 499
}
}'Response#
200
{
"status": "created",
"record": {
"id": 18342,
"key": "SUB-1042",
"contact_id": 901,
"data": {
"subscription_id": "SUB-1042",
"plan": "Gold",
"status": "active",
"renews_on": "2026-11-30",
"monthly_amount": 499
},
"created_at": "2026-10-27T09:30:12Z",
"updated_at": "2026-10-27T09:30:12Z",
"deleted_at": null
}
}| Field | Type | Description |
|---|---|---|
status | string | created (new record, or a deleted one brought back), updated (a field or the owner changed) or unchanged (nothing changed). |
record.id | integer | The record's id in Lemu AI. |
record.key | string | The record's key. |
record.contact_id | integer or null | The owner. null for catalog records. |
record.data | object | All of the record's fields after the update, including the key field. |
record.created_at, record.updated_at | string | Timestamps, in ISO 8601 (UTC). |
record.deleted_at | string or null | When the record was deleted. Always null here. |
Errors#
| Status | When |
|---|---|
400 | There's no record type with this api_name, the record type is archived, the record has no owner, no contact matches the owner, a new owner contact couldn't be created because your plan's contact limit is reached, a field is unknown or has a value of the wrong type, a required field is missing, the key in data doesn't match the path, or the record is larger than 16 KB. detail lists every problem. |
401 | The API key is missing or not valid. |
402 | Creating the record would take your organization over its plan's record limit. |
422 | The body isn't valid JSON, or an owner field is too long. |
See Errors for the error format.
Was this page helpful?
Docs