Sync customers
customers:read customers:writeWhen your team opens a chat or ticket, they see the customer’s name, email, phone, labels and your own fields. Syncing customers from your system means that information is already there, and correct.
How customers work
Section titled “How customers work”- Customers belong to one product. The same email under two products is two customers.
- The email is unique within a product. Creating a second customer with an email that’s already there answers
409 CUSTOMER_EMAIL_TAKEN. - Your own ID. Give each customer an
external_id: their ID in your system (up to 255 characters, no spaces). It’s unique within the product (409 CUSTOMER_EXTERNAL_ID_TAKEN), so it’s the reliable way to find the same person again, even if their email changes. - Stages. Each contact is a
subscriber(wrote in on a channel),lead(has an open deal) orcustomer. Customers you create arecustomerunless you setstage. - Labels are short tags such as
vip. Fields are your own custom fields (plan, account number, city), set up in the dashboard under the product’s customer settings.
Create or update (“upsert”)
Section titled “Create or update (“upsert”)”Look the customer up by your own ID, then create or update. external_id finds a customer at any stage:
const base = `https://api.supportaka.com/api/v1/organizations/${org}/products/${product}`;const headers = { Authorization: `Bearer ${process.env.SUPPORTAKA_KEY}`, 'Content-Type': 'application/json' };
async function upsertCustomer(user) { const query = new URLSearchParams({ external_id: String(user.id) }); const { items } = await fetch(`${base}/customers?${query}`, { headers }).then((r) => r.json()); const existing = items[0];
const body = JSON.stringify({ external_id: String(user.id), // your own user ID name: user.fullName, email: user.email, phone: user.phone ?? '', // E.164, e.g. +2348012345678; '' clears it labels: user.isVip ? ['vip'] : [], fields: { plan: user.plan, city: user.city }, });
const res = existing ? await fetch(`${base}/customers/${existing.id}`, { method: 'PATCH', headers, body }) : await fetch(`${base}/customers`, { method: 'POST', headers, body }); if (!res.ok) throw new Error((await res.json()).code); return res.json();}base = f"https://api.supportaka.com/api/v1/organizations/{org}/products/{product}"session = requests.Session()session.headers["Authorization"] = f"Bearer {os.environ['SUPPORTAKA_KEY']}"
def upsert_customer(user): page = session.get(f"{base}/customers", params={"external_id": str(user.id)}).json() existing = page["items"][0] if page["items"] else None
body = { "external_id": str(user.id), # your own user ID "name": user.full_name, "email": user.email, "phone": user.phone or "", # E.164, e.g. +2348012345678; "" clears it "labels": ["vip"] if user.is_vip else [], "fields": {"plan": user.plan, "city": user.city}, } res = (session.patch(f"{base}/customers/{existing['id']}", json=body) if existing else session.post(f"{base}/customers", json=body)) res.raise_for_status() return res.json()PATCH changes only what you send. An empty string clears the email, phone or external_id. labels replaces the customer’s labels, so send the full set. fields changes only the keys you send, and null clears one. An unknown field key is 400 VALIDATION_FAILED naming fields.<key>.
Custom fields
Section titled “Custom fields”List the product’s fields to see their keys and types:
curl https://api.supportaka.com/api/v1/organizations/$ORG/products/$PRODUCT/customer-fields \ -H "Authorization: Bearer $SUPPORTAKA_KEY"Each field has a key (what you send in fields), a type (text, number, date, boolean or select) and, for a select, its options. Fields are created in the dashboard.
Finding customers
Section titled “Finding customers”GET …/customers filters with:
| Parameter | Keeps customers… |
|---|---|
external_id |
with that ID from your system, at any stage |
q |
whose name or email contains the text |
stage |
at that stage: subscriber, lead, customer, or all |
label |
with that label |
field + field_value |
whose custom field equals the value |
source |
who first came from that source, such as whatsapp or email |
Keeping your system in step
Section titled “Keeping your system in step”Customers also arrive by themselves, when someone writes to you on WhatsApp or the website widget. To hear about them, subscribe a webhook to customer.created and customer.updated. They carry the customer’s id and your external_id (or null), so you can match them to your records straight away, then fetch the details:
curl https://api.supportaka.com/api/v1/organizations/$ORG/products/$PRODUCT/customers/$CUSTOMER_ID \ -H "Authorization: Bearer $SUPPORTAKA_KEY"Limits
Section titled “Limits”Each plan allows a number of contacts across the organization. Past it, creating answers 409 CONTACT_LIMIT_REACHED with details.limit and details.used.