Skip to content
uniboxTry it free

API

Connecting another system

A key lets your ERP, site or script read what is in the inbox and reply inside a conversation. A webhook tells it when something happened here.

Getting a key

Settings → API and webhooks → Create key. The key is shown once: we store only a hash of it, so nobody — including us — can read it back to you afterwards. If it is lost, revoke it and make another.

Send it on every request. Ten live keys per workspace, a thousand requests an hour per key.

curl https://unibox.chat/api/v1/conversations \
  -H "Authorization: Bearer ubx_…"

What you can read

Everything is scoped to the workspace the key belongs to. limit defaults to 50 and caps at 200.

GET /api/v1/conversations
GET /api/v1/conversations/{id}
GET /api/v1/conversations/{id}/messages
GET /api/v1/contacts

A conversation carries its assignee, its first-response time in seconds, its satisfaction score if one came back, and the tracked link it came from. A contact carries your own custom fields under custom.

What you can write

One thing: a reply, into a conversation that already exists.

POST /api/v1/conversations/{id}/messages
{"body": "Saiu hoje, chega quinta."}

The same endpoint sends a photo or a PDF. Give it a URL we can download, and body becomes the caption:

POST /api/v1/conversations/{id}/messages
{
  "body": "Segue o raio-x.",
  "media": {
    "url": "https://exemplo.com/raiox.jpg",
    "mimetype": "image/jpeg",
    "filename": "raiox.jpg"
  }
}

image/jpeg, image/png and application/pdf, up to 5 MB. The message is stored and reported as image or document — the same kind you get back from GET …/messages and in the message.sent webhook. A caption is capped at 1024 characters, which is WhatsApp's limit rather than ours.

media.url must be https and must resolve to a public address. We check every address the name answers with, connect to that address rather than re-resolving the name, and re-check each redirect — a URL that points back into a private network is refused, because this server can reach things your key should not. We also read the first bytes of the file and refuse one whose contents do not match its type, so mimetype is a hint and never the deciding word. It is optional; the file itself decides.

There is deliberately no endpoint that starts a conversation or sends to a number. Every workspace here shares one WhatsApp gateway and one egress IP, so a public send-to-anyone endpoint would put every customer's number at risk of being blocked for something one script did. Sends also count against the same hourly and daily ceiling the inbox obeys, and come back as 429 when it is reached.

Webhooks

Add an https endpoint in the same panel and pick the events. We POST JSON:

{
  "event": "deal.won",
  "deliveryId": "…",
  "attempt": 1,
  "data": { "cardId": "…", "contactId": "…", "valueCents": 250000, … }
}

Events: message.received, message.sent, conversation.assigned, deal.won, deal.lost.

Each delivery is signed. The header is X-Unibox-Signature: t=<unix>,v1=<hex>, where the hex is an HMAC-SHA256 of "<t>.<raw body>" using your endpoint secret. Verify it before trusting the payload, and reject a timestamp that is not recent — the timestamp is inside the signed string precisely so a captured delivery cannot be replayed later.

Answer with any 2xx. A failure is retried with a growing delay — one minute, four, sixteen, then hourly — and an endpoint that has failed twenty times in a row is switched off and says so in settings.

Errors

Every error is {"error", "message"}. 401 for a missing or wrong key, 404 for something that is not in your workspace, 429 for the hourly key limit or the sending ceiling, 502 when WhatsApp itself refused. Sending media adds 413 when the file is over 5 MB and 502 (media_error) when the URL could not be downloaded; a URL we will not accept at all is a 400.

Something missing that you need? Tell us — this is version one and it is short on purpose.

API — Unibox