The messaging API
Not a stable interface yet. The messaging API is new, has not been used by an application against a real provider, and may change without a major version. See the module's status.
/messaging/v1 sends and reads conversations. It exists only while the
messaging module is on (KARTA_MESSAGING=1);
otherwise every path is a 404. The OpenAPI document is at
/messaging/v1/openapi.json (no key needed).
Every request carries an API key of the mail server:
Authorization: Bearer karta_<prefix>_<secret>. The key needs a scope for
what it does:
| Scope | Allows |
|---|---|
messaging:send | send, check a recipient, upload a file to send |
messaging:read | read conversations, messages, files and connectors |
messaging:manage | connectors (make, enrol, link, revoke, remove), conversation references, settings |
A key sees only its own server's records: another server's connector,
conversation, message or file is a 404. Every key has a rate limit per minute
(429 with Retry-After). Errors have the shape of the rest of the API:
{"error": {"code": "invalid_request", "message": "The request does not match the API",
"details": [{"field": "/to", "message": "is not a phone number (use +, the country code and the number)"}]}}Times are RFC 3339 in UTC. Lists are newest first, limit (1 to 200, default
- and
cursor(thenextof the page before);nextisnullon the last page.
Send a message
curl -sS https://karta.example/messaging/v1/messages \
-H "Authorization: Bearer $KARTA_KEY" \
-H 'Idempotency-Key: order-1043-ready' \
-H 'Content-Type: application/json' \
-d '{
"to": "+599 7111 2222",
"text": "Uw bestelling #1043 is klaar om opgehaald te worden.",
"channels": ["whatsapp"],
"category": "transactional",
"reference": "order-1043",
"consent": {"basis": "order", "ref": "1043"}
}'
{
"id": "01a1d333-0f68-7ad1-bfa4-e5e7800a6e88",
"request_id": "01a1d333-0f63-7eab-92d7-e33a1039672c",
"state": "sending",
"chosen_channel": "whatsapp",
"channels": ["whatsapp"],
"skipped": [],
"estimate": null,
"to": "+59971112222",
"attempts": [
{"id": "01a1d333-0f68-7ad1-bfa4-e5e7800a6e88", "attempt_no": 1, "channel": "whatsapp",
"connector_id": "0199f3a2-7c10-7d3e-9a41-5b2c0e8d1f66", "state": "queued", "final": false,
"started_at": "2026-11-13T10:00:00.123456Z", "ended_at": null, "error_class": null,
"cost": null, "fallback_from": null, "duplicate_possible": false}
]
}202 means Karta accepted the request, not that the message arrived: follow the
attempt with GET /messaging/v1/messages/:id or the messaging.message.status
webhook event.
| Field | |
|---|---|
to | A phone number. It is normalised to E.164 with the server's country for local numbers (+599 777 1234, 00599..., 777 1234), or lid:<digits> to answer a chat WhatsApp shows without a number. Never a group. |
channels | The channels to try, in order, from whatsapp and sms. Default: the organisation's default channels, else ["whatsapp"]. |
text | Up to 4096 characters. |
media_id, caption | A file from POST /media instead of text, with an optional caption. |
category | transactional (default), service or authentication. marketing is refused. |
reference | Your own reference (200 characters); list messages with ?reference=. |
metadata | An object of at most 2 KB, returned with the message. |
consent | {"basis": ..., "ref": ...}: why this person may be written to (for example an order). |
policy | wait_for_connector_s (0 to 3600, default 120), allow_paid, fallback_after_s (300 or more). |
from | The sender of an SMS (at most 20 characters). |
Idempotency. Idempotency-Key (1 to 200 letters, digits and _ . : -) is
required. The same key with the same request answers the same (header
Idempotent-Replayed: true) and sends once, so retry after a timeout without
fear; the same key with a different request is 409 idempotency_key_reused.
Keys are remembered as long as the request is (the retention period).
channels may name several: Karta moves on to the next on facts only (Routing and guard
rails); skipped says which steps it passed over and why, and
estimate what an SMS would take. A request may be waiting with no attempt yet (the agent is offline,
quiet hours).
Errors: 400 idempotency_key_required, 422 invalid_request (with the
fields), 422 no_connector (no connector on any of the channels), 422 first_contact_requires_reason, 422 paid_channel_not_allowed, 422 fallback_not_allowed, 409 idempotency_key_reused, 403 forbidden (missing scope), 429 rate_limited.
Read
curl -sS 'https://karta.example/messaging/v1/messages?reference=order-1043' \
-H "Authorization: Bearer $KARTA_KEY"
A message has direction (in or out), kind (text, media, location,
contact, reaction, other), text (the text or the caption; content for
the other kinds), media_id, state, final, error (class, code),
cost, reference, occurred_at. An outbound message's states are queued,
waiting (the connector is offline), sending, sent, delivered, read,
failed and unknown (nobody can tell whether it went out: Karta never sends
it again by itself). GET /messages/:id adds the events (every state with its
time) and the attempts of its request. GET /messages filters by reference,
to, since and direction.
GET /messaging/v1/conversations?address=%2B59971112222 # across connectors
GET /messaging/v1/conversations/:id/messages # the thread, newest first
PATCH /messaging/v1/conversations/:id {"external_ref": "pos_customer:812"} # messaging:manage
A conversation is one thread between a connector and one address; set
external_ref to your own record (a customer) and find it again with
?external_ref=.
Check a recipient
curl -sS https://karta.example/messaging/v1/recipients/check \
-H "Authorization: Bearer $KARTA_KEY" -H 'Content-Type: application/json' \
-d '{"address": "+59971112222", "channels": ["whatsapp"]}'
{"address": "+59971112222",
"results": [{"channel": "whatsapp", "connector_id": "...", "registered": true,
"checked_at": "2026-11-13T10:00:00.000000Z", "cached": false}]}registered is true, false, or null when the connector cannot say or did
not answer within 10 seconds. Answers are cached 7 days when the number is on the
channel and 24 hours when it is not.
Files
POST /messaging/v1/media (multipart, part file, at most 16 MiB) stores a file
and returns its id (med_...) to send with a message; GET /messaging/v1/media/:id returns the decrypted file. Received files have a
media_id too.
Connectors and settings
GET /messaging/v1/connectors # status, capabilities, last seen, agent version
POST /messaging/v1/connectors # {"plug": "postduif", "name": "..."}: answers with the one-time token
POST /messaging/v1/connectors/:id/enrolment # a new token (a lost agent)
POST /messaging/v1/connectors/:id/link # {"account_id": "wa-1"}: a QR on the shop computer
POST /messaging/v1/connectors/:id/unlink
POST /messaging/v1/connectors/:id/revoke
PATCH /messaging/v1/connectors/:id # {"name": ..., "limits": {"per_minute": 8, "per_day": 200}}
DELETE /messaging/v1/connectors/:id
GET /messaging/v1/settings PUT /messaging/v1/settings
PUT /settings changes the fields it names: retention (30 to 3650, "keep"
or "default"), send_per_minute, send_per_day, quiet_hours
(enabled, start, end, utc_offset_minutes), default_channels,
paid_by_default, paid_daily_cap, and server: default_country, sms_allowed,
webhook_include_body.
Webhooks
Karta's signed webhooks carry what happens: see Messaging webhook events.