LemuAIDocs

Contacts · 2 min read

Upsert a Contact

Create or update one contact by phone number and add it to a contact list

Open in ChatGPTOpen in ClaudeMarkdown

Adds one contact to a contact list, creating whatever doesn't exist yet:

  • The contact is matched by phone in your organization. The match ignores formatting, so +91 98765 43210 and +919876543210 are the same number. If a match is found, the fields you send are updated; if not, a new contact is created.
  • The list is matched by list_name. If no list has that name, it is created.

Use this endpoint when a record is created or changes in your CRM.

POST/api/v1/contacts/upsert

Request body#

FieldTypeRequiredDescription
list_namestringYesThe contact list to add the contact to (1 to 255 characters). Created if it doesn't exist.
phonestringOne of phone or external_idPhone number in international format. This is what existing contacts are matched on.
external_idstringOne of phone or external_idYour own id for the person. Stored on the contact, but not used for matching: a request with only external_id always creates a new contact.
emailstringNoA valid email address.
first_namestringNoUp to 100 characters.
last_namestringNoUp to 100 characters.
companystringNoUp to 255 characters.
titlestringNoJob title, up to 255 characters.
tagsarray of stringsNoReplaces the contact's tags.
custom_fieldsobjectNoExtra values. Merged into the contact's existing custom fields: keys you send are updated, others are kept.

When updating, fields you leave out (or send as null) keep their current value.

Example request:

cURL
curl -X POST https://app.lemuai.com/api/v1/contacts/upsert \
  -H "X-API-Key: lemu_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "list_name": "October renewals",
    "phone": "+919876543210",
    "external_id": "crm-58213",
    "first_name": "Priya",
    "last_name": "Sharma",
    "tags": ["renewal", "gold"],
    "custom_fields": { "plan": "Gold", "renewal_date": "2026-11-05" }
  }'

Response#

200

JSON
{
  "contact": {
    "id": 901,
    "organization_id": 7,
    "external_id": "crm-58213",
    "phone": "+919876543210",
    "phone_last4": "3210",
    "phone_masked": false,
    "email": null,
    "first_name": "Priya",
    "last_name": "Sharma",
    "company": null,
    "title": null,
    "tags": ["renewal", "gold"],
    "custom_fields": { "plan": "Gold", "renewal_date": "2026-11-05" },
    "created_at": "2026-10-20T10:00:00Z",
    "updated_at": "2026-10-24T09:12:40Z"
  },
  "contact_list": {
    "id": 55,
    "organization_id": 7,
    "name": "October renewals",
    "description": null,
    "metadata": {},
    "column_schema": [],
    "created_at": "2026-10-24T09:12:40Z",
    "updated_at": "2026-10-24T09:12:40Z"
  },
  "contact_created": false,
  "list_created": true
}
FieldTypeDescription
contactobjectThe contact after the update. See contact fields.
contact_listobjectThe list the contact was added to: id, name, description, and timestamps.
contact_createdbooleantrue if a new contact was created, false if an existing one was updated.
list_createdbooleantrue if the list was created by this request.

Errors#

StatusWhen
402Your plan's contact limit is reached
422Neither phone nor external_id was sent, list_name is missing, or a field is too long or not valid (for example email)

Was this page helpful?