What actually happens when you call each endpoint — including where things stop, which is usually the part worth knowing.
This runs before any endpoint sees your call.
your system
│ Authorization: Bearer ikx_live_…
▼
┌─────────────────────────────────────────────────────┐
│ 1. hash the key (SHA-256) and look it up │
│ no match / revoked / expired ──────────────► 401 │
│ (all three give the SAME message, so the │
│ response cannot be used to probe which keys │
│ exist) │
├─────────────────────────────────────────────────────┤
│ 2. does the key hold the scope this endpoint needs? │
│ no ────────────────────────────────────────► 403 │
├─────────────────────────────────────────────────────┤
│ 3. rate limit for this bucket (read/write/send) │
│ over budget ───────────────────────────────► 429 │
│ + Retry-After │
├─────────────────────────────────────────────────────┤
│ 4. mint a 5-minute JWT for the key's machine user │
│ → every database query now runs AS that user │
│ → row-level security scopes it to their org │
├─────────────────────────────────────────────────────┤
│ 5. run the endpoint │
├─────────────────────────────────────────────────────┤
│ 6. write an audit row: method, path, status, timing │
│ (never the body — that contains customer words) │
└─────────────────────────────────────────────────────┘Step 4 is the important one. Your key is not "allowed to see org X" by application logic — it becomes a user in org X, and the database itself refuses to return anything else. An endpoint that forgot to filter would return nothing, not another tenant's data.
POST /v1/messages — one call from your CRM, delivered and recorded.
POST /v1/messages
{ channel, to | contact_id, subject?, content }
Idempotency-Key: <your unique string>
│
▼
┌── has this key been used before? ──────────────────────┐
│ YES, and it succeeded → return the original result │
│ SEND NOTHING ✔ done │
│ YES, still in flight → 409 send_in_progress │
│ YES, but it failed → carry on (retry allowed) │
│ NO → claim it, carry on │
└────────────────────────────────────────────────────────┘
│
▼
find or create the CONTACT (by email or phone)
│
▼
find or create the CONVERSATION (the thread for that person)
│
▼
pick a CHANNEL — skips any that need reconnecting
│ └─ none usable → 409
▼
┌── is this a test/demo channel? ────────────────────────┐
│ YES → skip the provider entirely │
│ record the message locally │
│ respond delivered:false, test_mode:true │
│ NO → send via Gmail / WhatsApp │
└────────────────────────────────────────────────────────┘
│
├─ provider refused ──► 502 provider_error
│ (safe to retry, SAME key)
▼
record the message in the conversation
│
├─ recording failed ──► 502 recorded_partially
│ ⚠ the customer DID receive it
│ do NOT retry
▼
mark the key as used ✔ 200 { id, conversation_id, contact_id }The two 502s mean opposite things. provider_error: nothing was delivered, retry with the same key. recorded_partially: it was delivered and only our record failed — retrying sends a second copy.
Nothing to call. This happens whether or not your system is listening.
customer replies (email, WhatsApp, Facebook, Instagram)
│
▼
provider notifies IkoniaCX (webhook), or a scheduled sync collects it
│
▼
┌── claim this message id ───────────────────────────────┐
│ already claimed → stop │
│ (providers redeliver when they do not get a fast │
│ 200; without this the customer gets two auto-replies)│
└────────────────────────────────────────────────────────┘
│
▼
attach to the existing conversation with that person
│
▼
classify · score sentiment · run automation rules
│
▼
visible in the shared inbox ─────────┐
│ │
▼ ▼
webhook fires to your CRM your team replies
(or you poll /v1/conversations) in the appBoth routes write to the same thread, so a message your CRM sent and a reply typed by a colleague sit in one history. Rather than polling, register a webhook — see below.
GET /v1/contacts?search=jane@example.com
│ (only if you do not already hold the contact_id)
▼
GET /v1/contacts/{id}/conversations
│ every thread with that person, ALL channels
▼
GET /v1/conversations/{id}/messages
│ oldest first
▼
each message says who spoke:
contact → the customer
agent → your team, or your CRM via this API
ai → an automated reply IkoniaCX generated
system → a platform note, not something anyone saidA broadcast needs an audience. Groups are the reusable kind; a one-off list of ids works too.
POST /v1/contact-groups { name: "VIP customers" }
│ idempotent on name — re-running your sync returns
│ the SAME group rather than splitting the audience
▼
POST /v1/contact-groups/{id}/members
{ contacts: ["jane@example.com", "+27821234567"] }
│ or { contact_ids: [...] }
▼
┌── each identifier ─────────────────────────────────────┐
│ matches a contact → added (re-adding is harmless) │
│ matches nothing → reported in "unmatched" │
│ NOT created │
└────────────────────────────────────────────────────────┘
│
▼
GET /v1/contact-groups/{id}/members
→ members, plus without_phone: how many a WhatsApp
broadcast would skipUnmatched identifiers are never turned into contacts automatically. Doing so would fill your audience with records nobody meant to create — usually from a typo — and you would then be messaging them.
WhatsApp does not allow free text to someone who has not messaged you recently. A business-initiated message must use a template Meta has approved.
POST /v1/whatsapp/templates
{ name: "order_shipped", category: "UTILITY",
body_text: "Hi {{1}}, order {{2}} has shipped." }
│
├─ name not lowercase_with_underscores ──► 400
├─ placeholders not {{1}},{{2}} in order ──► 400
│ (Meta rejects these too, but says so unhelpfully)
▼
submitted to WhatsApp ─────────► status: PENDING
│
│ … Meta reviews: minutes to about a day …
▼
GET /v1/whatsapp/templates
│
├─ APPROVED → usable:true ✔ can be broadcast
├─ PENDING → still waiting
└─ REJECTED → fix the wording and submit a new nameThe variables count in the response tells you how many values a broadcast must supply for that template.
The highest-consequence call in the API: one request can message thousands of people and cannot be recalled. It is checked harder than anything else, and every check happens before a single message goes out.
POST /v1/broadcasts
{ template, variables, group_id, max_recipients }
Idempotency-Key: <your unique string>
│
▼
┌── 1. template exists and is APPROVED? ─────────────────┐
│ no → 404 template_not_found │
│ not approved → 409 template_not_approved │
├── 2. variable count matches the template? ─────────────┤
│ no → 400 variable_mismatch │
│ (a missing value renders as a literal {{2}} │
│ to every single recipient) │
├── 3. resolve the audience ─────────────────────────────┤
│ people with no phone number are counted │
│ and reported, never silently dropped │
│ nobody reachable → 422 no_recipients │
├── 4. max_recipients present? (REQUIRED) ───────────────┤
│ missing → 400 max_recipients_required │
│ audience bigger than it → 409 │
│ audience_larger_than_expected │
│ NOTHING IS SENT │
│ (a segment that unexpectedly resolves to 40,000 │
│ is far more likely a bug in your query than │
│ an intention, and a message cannot be recalled) │
├── 5. idempotency key already used? ────────────────────┤
│ yes → return the ORIGINAL broadcast, send nothing │
└────────────────────────────────────────────────────────┘
│ all checks passed
▼
create the broadcast + recipient rows status: draft
│
▼
respond immediately ✔ 200 { id, recipients, skipped_no_phone }
│
│ sending continues in the background
▼
┌── claim the broadcast (only if still "draft") ─────────┐
│ someone else already claimed it → stop │
│ (this is why a double-click cannot double-send) │
└────────────────────────────────────────────────────────┘
│
▼
send in batches of 50, one second apart status: sending
│
▼
GET /v1/broadcasts/{id} ← poll for progress
{ sent_count, delivered_count, read_count,
failed_count, failures: [ … ] }max_recipients is required, not optional. It is the difference between a bad query costing you nothing and a bad query messaging your entire customer base.
The alternative to polling. Note where the queue sits — that boundary is deliberate.
customer replies
│
▼
IkoniaCX stores the message
│
▼
┌── queue one delivery per subscribed endpoint ──────────┐
│ written to a table, NOT sent here │
│ │
│ why: calling your server inline would put YOUR │
│ uptime on the critical path of us receiving a │
│ customer message. If you were slow, our webhook │
│ would be slow, and WhatsApp responds to a slow │
│ webhook by redelivering — which is how duplicate │
│ auto-replies start. │
└────────────────────────────────────────────────────────┘
│
▼
delivery worker runs every minute
│
▼
┌── re-check the URL still resolves publicly ────────────┐
│ a hostname registered months ago can be repointed │
│ at an internal address — checked EVERY time, not │
│ only at registration │
└────────────────────────────────────────────────────────┘
│
▼
POST to your endpoint
X-IkoniaCX-Event: message.received
X-IkoniaCX-Signature: t=<unix>,v1=<hmac of "t.body">
X-IkoniaCX-Delivery: <id, for your deduplication>
│
├── 2xx within 10s ──► delivered ✔ failure streak reset
│
└── anything else ───► retry: 1m → 5m → 30m → 2h → 6h
then abandoned
│
▼
20 consecutive failures
│
▼
endpoint DISABLED
(re-enable with PATCH {active:true},
which also clears the counter)Respond 2xx immediately and do the work afterwards. If you process inline and take longer than 10 seconds, we record a failure and retry — so slow processing turns into duplicate deliveries, not just late ones.
Deduplicate on X-IkoniaCX-Delivery. If your 2xx is lost in transit we retry, and you receive the same event twice.
Every flow above runs identically on a test key — except the last step.
test key ──► validated ──► rate limited ──► recorded
│
▼
┌───────────────────────────┐
│ provider call SKIPPED │
│ nothing reaches anyone │
│ delivered: false │
│ test_mode: true │
└───────────────────────────┘Messages still appear in the conversation, so you can verify your integration end to end — including retries and error handling — without a single customer hearing from you.