Aiva over API
Drive the same Aiva agent that powers Webchat from your own product, over HTTP.
Aiva over API lets your backend send end-user messages to Aiva and read the replies, so you can build Aiva into surfaces we don't render: a mobile app, an in-product help screen, another chat system.
Aiva over API runs the same Aiva as Webchat. A message you POST runs the full pipeline of your workspace: knowledge, tools, identity gate, escalation to your team. The conversation is stored and appears in your dashboard inbox, and a teammate can take over at any point.
The model is asynchronous: you POST a message, Aiva processes it, and the reply reaches you through a signed callback to your server or by polling the conversation. There is no blocking "wait for the answer" endpoint.
1. Get access
Requesting access needs the Business plan. In the dashboard, open Settings → Channels → API and submit the request form (what you are building, expected volume). When access is granted, the workspace owner gets an email, and the owner's account receives a one-time starter credit so you can make your first calls before topping up.
The rest of this guide assumes the API card in Settings → Channels shows Active.
2. Create an API key
In Settings → Channels → API → Keys, create a key:
- Scopes pick what the key can call. Grant only what the integration needs.
- Callback URL (optional, https) is where we POST signed events: Aiva's replies, teammate replies, identity confirmations, handoff notices. Leave it empty to use polling instead.
The callback URL cannot be changed later: create a new key for a new URL. A conversation's events go to the key that started it, and stop when that key is revoked.
The full key (ak_<id>_<secret>) and, if you set a callback URL, the callback signing secret are shown exactly once. Store both in your secret manager; neither is retrievable again.
3. Send a message
curl -X POST https://assistify.chat/api/v1/messages \
-H "Authorization: Bearer ak_xxx_yyy" \
-H "Content-Type: application/json" \
-d '{
"externalConversationId": "order-4821",
"externalUserId": "user-93",
"content": "What is your refund policy?",
"idempotencyKey": "'"$(uuidgen)"'"
}'externalConversationIdis your stable conversation id, unique in your workspace. The first message with a new id creates the conversation; later messages with the same id continue it. Once a conversation is closed, Aiva no longer answers it: start a new id.externalUserId(optional) is your stable end-user id. It links messages to one contact and enables identity verification and per-user spend caps.idempotencyKeyis a UUID you generate per logical message. Retrying with the same key can never create a duplicate or double-charge; use a fresh UUID for each new message.
The response is 202 Accepted:
{ "status": "success", "data": {
"conversationId": "…", // our internal id
"messageId": "…",
"status": "queued" // "queued" | "duplicate" | "skipped"
}}queued: the message is stored and a reply is on its way. A reply can still fail to come, for example when Aiva is switched off in the meantime.duplicate: an idempotency replay of an earlier submit.skipped: the message is stored and no AI reply will be generated. Areasonfield says why:agent_assignedorhuman_handoffwhen a teammate has the conversation,status_CLOSEDwhen it is closed,entitlement_deniedwhen Aiva does not answer this workspace.
4. Receive the reply
Polling
Without a callback URL, poll the conversation until a new AI message appears:
curl https://assistify.chat/api/v1/conversations/order-4821 \
-H "Authorization: Bearer ak_xxx_yyy"The response contains the ordered message history with senderType per message (VISITOR, AI, AGENT). Poll every few seconds; a reply that uses tools can take over a minute.
Callbacks
With a callback URL on the key, we POST each event to your endpoint:
// ai.reply
{
"event": "ai.reply",
"conversationId": "order-4821", // your externalConversationId
"messageId": "…",
"seq": 2,
"content": "Our refund policy is…",
"visibility": "public",
"poweredBy": "Assistify",
"timestamp": "2026-07-02T10:30:00.000Z"
}Respond with any 2xx quickly (we time out after 5 seconds). Failed deliveries are retried with exponential backoff. Deliveries carry a stable X-Assistify-Delivery-Id header that is reused across retries, so deduplicate on it.
visibility is "public" or "private". A private reply used at least one tool, which may have returned personal or account data; render it only where the end user is authenticated.
Verify the signature
Every callback is signed with the key's callback secret: HMAC-SHA256 over `${timestamp}.${rawBody}`, sent as X-Assistify-Signature: sha256=<hex> with X-Assistify-Timestamp (unix seconds). Verify before trusting the payload:
const { createHmac, timingSafeEqual } = require('crypto');
function verify(req, secret) {
const ts = req.headers['x-assistify-timestamp'];
const sig = req.headers['x-assistify-signature']; // "sha256=…"
const expected = 'sha256=' + createHmac('sha256', secret)
.update(`${ts}.${req.rawBody}`).digest('hex');
const a = Buffer.from(sig), b = Buffer.from(expected);
return a.length === b.length && timingSafeEqual(a, b);
}Sign over the raw request body exactly as received. Parsing and re-serializing the JSON changes the bytes and breaks the signature.
Test your endpoint
In Keys, every key with a callback URL has a Send test action. It delivers a signed test.ping event through the same pipeline as real events, so you can confirm your endpoint and signature verification before going live. The outcome appears in the Logs tab.
5. When a teammate takes over
When Aiva escalates the conversation to your team, your callback receives conversation.handoff with the reason and a summary. The summary and next step are written for your team, not for the end user. Until a teammate replies or takes the conversation, Aiva keeps answering the end user, and POSTs return queued.
From then on, every public reply a teammate writes, from the dashboard, the mobile app, Discord or Telegram, reaches you as agent.reply, with agentId and agentName (null when the author is no longer a member of the workspace). Handle ai.reply and agent.reply through one code path. Files and images a teammate sends do not travel over the API.
Messages you POST while a teammate has the conversation are stored and shown to them, and come back as status: "skipped". They still pass the credit check: with an empty wallet the POST fails and the message is not stored.
6. Identity
The identity model mirrors the widget:
| Tier | Meaning |
|---|---|
| anonymous | No externalUserId; each message creates a new anonymous contact. |
| unverified | You supplied an externalUserId. Links messages to one contact, but does not unlock personal tools. |
| verified | The end user completed a verification ceremony. Personal and account-scoped tools unlock. |
Supplying an externalUserId is an assertion by your key, not proof. To verify, call POST /v1/identity/verify with method: "magic_link" and the user's email; the user clicks the emailed link within 15 minutes, and your callback receives identity.verified. Verification is always earned by the end user out-of-band; the API cannot assert it directly.
Links are limited to 3 an hour for one user and address, and to 10 an hour from one server address in all. Past that, the call answers { "status": "not_sent", "reason": "rate-limited" }. identity.verified reaches the keys that own a conversation with that user, so verify a user who has written at least once.
7. Billing
API usage is billed per token consumed from a prepaid credit wallet: the workspace owner's account balance, shared by the owner's workspaces. API conversations do not count toward your plan's conversation allowance. The balance is under Settings → Channels → API → Credits; top-ups and auto-recharge are under Settings → Billing.
- Before generating, the wallet must cover one full-size model call; otherwise the call fails with
402 INSUFFICIENT_CREDITSand nothing is charged. - After generating, the actual token cost is settled once. Idempotent retries never double-charge. A generation that needs several model calls can cost more than that floor, so the balance can end slightly below zero; the next call then fails with
402until you top up. - Settings → Workspace → API spend limits caps spending per day, week and month, for the whole workspace and for each
externalUserId, so a single end user cannot drain the wallet. A capped request fails with429 USER_SPEND_CAP_REACHED.
8. Debugging
- Logs tab (Settings → Channels → API → Logs) shows your most recent authenticated API requests with status, error code and duration, and your most recent callback deliveries with their outcome. Requests are kept 30 days and deliveries 7 days. A failed delivery can be replayed from there with the original payload.
- Responses to an authenticated request carry the key's rate limit state:
X-RateLimit-Limit,X-RateLimit-Remaining,X-RateLimit-Reset. A429includesRetry-Afterin seconds. - Errors use one envelope everywhere:
{ "status": "error", "statusCode": 402, "code": "INSUFFICIENT_CREDITS", "message": "…" }. Branch oncode, not on the message text.
The full endpoint and event schemas are in the API reference.
Going live checklist
- Key created with only the scopes you need; secrets stored server-side.
- Callback endpoint verifies signatures over the raw body and deduplicates on
X-Assistify-Delivery-Id, confirmed with Send test. - Idempotency keys are fresh UUIDs per message, persisted with your outbound queue so retries reuse them.
agent.replyandconversation.handoffare handled, so a teammate's takeover reaches your end user.- Credit balance funded, auto-recharge or a top-up reminder in place, and spend limits set if your end users are untrusted.