Skip to content

Upsert Contacts

Send a JSON array of contacts (not an object). Each contact needs at least a phone.

Terminal window
curl -X POST https://api.whatbot.in/public/v1/contacts \
-H "X-API-Key: wa_live_xxx" \
-H "Content-Type: application/json" \
-d '[
{
"phone": "9876543210",
"name": "Ravi Kumar",
"opt_in": true,
"tags": ["gold", "vip"],
"source_ref": "crm-lead-4821",
"attributes": {
"email": "ravi@kumarjewels.com",
"city": "Chennai",
"budget": "15L",
"product_interest": "gold coins"
}
}
]'
FieldTypeRequiredDescription
phonestringYesThe contact’s phone number, any format. Auto-normalized to E.164 (98765 43210+919876543210). This is the unique key — re-sending the same number updates the existing contact.
namestringDisplay name shown in the inbox. Won’t overwrite the real WhatsApp profile name on an active conversation — it fills in only where a name is missing.
opt_inbooleanWhether the contact has opted in to marketing messages. Used for broadcast eligibility.
tagsstring[]Labels for segmenting broadcasts and filtering the inbox, e.g. ["gold","vip"].
source_refstringYour own reference id (e.g. the CRM record id). Stored for traceability; not shown to customers.
attributesobjectFree-form custom fields — put anything you want here (email, city, budget, status, source, assigned rep, language…). No schema, no pre-declaration. These become {{variables}} usable in WhatsApp templates and show on the contact in the inbox.
FieldTypeRequiredDescription
upsertednumberHow many contacts were created or updated.
receivednumberHow many contacts were in the request body.
200
{ "upserted": 1, "received": 1 }
  • Keyed by phone. Sending a phone that already exists updates that contact (merging the new fields) instead of creating a duplicate. Safe to re-run.
  • Batch freely. Send one contact or thousands in a single array.
  • Phone normalization applies a default country code to bare 10-digit numbers, so 9876543210, +91 98765 43210, and 919876543210 all resolve to the same contact.

Anything under attributes can be referenced in an approved WhatsApp template. If you push attributes: { "city": "Chennai" }, a template body like Hi, our {{city}} store has new stock renders per-contact automatically.

StatusCause
401Missing/invalid X-API-Key
422Body wasn’t a JSON array, or a contact was missing phone / had an invalid number