LemuAIDocs

Custom Records · 2 min read

Create or Update Records in Bulk

Create or update up to 1,000 custom records of one record type in a single request

Open in ChatGPTOpen in ClaudeMarkdown

Creates or updates up to 1,000 records of one record type. Each record works the same way as Create or update a record, and each one succeeds or fails on its own, so one bad row doesn't stop the rest.

POST/api/v1/objects/{api_name}/records/batch

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.

Request body#

FieldTypeRequiredDescription
recordsarrayYesBetween 1 and 1,000 records. Each one accepts the fields below.

Each record:

FieldTypeDescription
keystringThe record's key. If you leave it out, the value of the key field in data is used.
dataobjectThe record's fields. See field values.
phone, email, external_id, shopify_customer_id, contact_idThe owner, as in Choosing the owner. Needed for a new record of a normal record type.

If the same key appears more than once in one request, the last one is saved and the earlier ones are reported as errors.

Example request:

cURL
curl -X POST https://app.lemuai.com/api/v1/objects/subscription/records/batch \
  -H "X-API-Key: lemu_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "records": [
      {
        "key": "SUB-1042",
        "email": "priya@example.com",
        "data": { "plan": "Gold", "status": "active", "renews_on": "2026-11-30" }
      },
      {
        "phone": "+919812345678",
        "data": { "subscription_id": "SUB-1043", "plan": "Silver", "status": "paused" }
      },
      {
        "key": "SUB-1044",
        "data": { "plan": "Platinum" }
      }
    ]
  }'

Response#

200: the request was processed. Check each result to see which records were saved.

JSON
{
  "results": [
    { "key": "SUB-1042", "status": "updated", "record_id": 18342, "contact_id": 901 },
    { "key": "SUB-1043", "status": "created", "record_id": 18343, "contact_id": 1207 },
    {
      "key": "SUB-1044",
      "status": "error",
      "error": "A new record needs its owner: phone, email, external_id, shopify_customer_id or contact_id"
    }
  ],
  "counts": { "updated": 1, "created": 1, "error": 1 }
}
FieldTypeDescription
resultsarrayOne entry per record you sent, in the same order.
results[].keystringThe record's key. Missing when the row had no key at all.
results[].statusstringcreated, updated, unchanged or error.
results[].record_idintegerThe record's id. Not included for rows with an error.
results[].contact_idintegerThe record's owner. Not included for catalog records or rows with an error.
results[].errorstringWhy the row failed. Only included when status is error.
countsobjectHow many rows ended with each status.

Errors#

These apply to the whole request. Problems with a single record are reported in results instead.

StatusWhen
400There's no record type with this api_name, or the record type is archived.
401The API key is missing or not valid.
402The new records would take your organization over its plan's record limit. Nothing is saved.
422records is missing, empty or has more than 1,000 items, or a field has the wrong type.

See Errors for the error format.