LemuAIDocs

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

Open in ChatGPTOpen in ClaudeMarkdown

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#

NameRequiredDescription
X-API-KeyYesAn API key from your organization. See Authentication.
Content-TypeYesapplication/json

Path parameters#

NameTypeRequiredDescription
api_namestringYesThe record type's API name, for example subscription.
keystringYesThe record's key, for example SUB-1042. If data also contains the key field, it must have the same value.

Request body#

FieldTypeRequiredDescription
dataobjectNoThe record's fields, as field name and value. Only fields defined on the record type are accepted. See field values.
phonestringNoThe owner's phone number in international format.
emailstringNoThe owner's email address.
external_idstringNoYour own id for the owner.
shopify_customer_idstringNoThe owner's Shopify customer id.
contact_idintegerNoThe 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.

  1. If you send contact_id, that contact is the owner.
  2. Otherwise, if you send phone, email, external_id or shopify_customer_id, Lemu AI finds the contact the same way as Send an event. A new contact (tagged record) is only created from a phone or email.
  3. If you send no owner fields and the record already exists, it keeps its owner.
  4. 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
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

JSON
{
  "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
  }
}
FieldTypeDescription
statusstringcreated (new record, or a deleted one brought back), updated (a field or the owner changed) or unchanged (nothing changed).
record.idintegerThe record's id in Lemu AI.
record.keystringThe record's key.
record.contact_idinteger or nullThe owner. null for catalog records.
record.dataobjectAll of the record's fields after the update, including the key field.
record.created_at, record.updated_atstringTimestamps, in ISO 8601 (UTC).
record.deleted_atstring or nullWhen the record was deleted. Always null here.

Errors#

StatusWhen
400There'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.
401The API key is missing or not valid.
402Creating the record would take your organization over its plan's record limit.
422The body isn't valid JSON, or an owner field is too long.

See Errors for the error format.