Custom channel via API
With an API channel you bring messages from a system you control into the inbox: from your own app, your shop or a messenger The-Y doesn't support natively (e.g. Viber via Make or n8n). Your system delivers customer messages through the API. The CRM sends replies from the inbox back to an address of your system, signed.
Contents: How it works · Setup · Deliver a customer message · Receive replies · Report delivery status · In the CRM · Limits · Troubleshooting
How it works
- In: your system sends every customer message as a
POSTto the API. It becomes a conversation in the “API channel” – with contact, assignment, notifications and automations like any other channel. - Out: every reply in the conversation – from a person, an automation, the API or an AI client via MCP – goes as a signed
POSTto your reply address (webhook). Your system delivers it to the customer. - Back (optional): your system reports “delivered”, “read” or “failed” – then you see the ticks in the inbox.
Setup
- Create the API channel. Settings → Channels → card “Your own channels: API and web form” → “Create API channel”. Enter a name only you see in the CRM, e.g. “Viber via Make” or “Customer app”. Each API channel belongs to one brand; with several brands, choose the right one at the top first.
- Copy the secret. The secret (
whsec_…) is then shown once in the window (“Secret – visible only now”). Copy it into your system: it lets you verify that replies really come from the CRM. Later you can only create a new one (“Create new secret” – the old one stops working immediately). - Enter the “Reply address (webhook)”. The CRM sends every reply here. Cloud:
https://only, and no addresses in a local or internal network. Empty = incoming only, no replies. - “Send test”. The CRM sends the signed event
webhook.pingto the address and shows whether it was delivered. - “Create a key for this channel”. In the same window you get an API key with exactly one scope, “Deliver messages” (
channels:inbound), and only for this channel. It is shown only once (“Key – visible only now”) – copy it, done. - Take the channel ID. The “Channel ID (channel_id)” is shown in the window and goes into every incoming message.
Deliver a customer message
Send each message from your customer to the API like this (cloud: crm.the-y.at, self-hosted: your own address):
POST https://crm.the-y.at/api/ext/v1/channels/inbound
Authorization: Bearer tyk_…
Content-Type: application/json
{
"channel_id": "<channel ID from the API channel's window>",
"sender": { "id": "customer-4711", "name": "Anna Muster", "email": "anna@example.com", "phone": "+43 664 1234567" },
"text": "Hello, is my parcel on its way?",
"thread": "order-4711",
"subject": "Order 4711",
"message_id": "msg-001"
}
| Field | Meaning |
|---|---|
channel_id | Required. The channel ID from the API channel's window. |
sender.id | Required. Your ID for the customer (e.g. customer number or ID in the messenger). Replies are addressed to this ID. |
text | Required. The message, up to 8,000 characters. |
sender.name, sender.email, sender.phone | Optional. Help match the contact. |
sender.contact_id | Optional. ID of an existing contact in the CRM. |
thread | Optional. Your own conversation ID: same ID = always the same conversation (a closed one is reopened). Without thread there is one ongoing conversation per sender; once it is closed, the next message starts a new one (like WhatsApp). |
subject | Optional. Subject of the conversation. |
message_id | Optional, recommended. Your ID for the message. If the same ID arrives a second time, the API answers 200 with "duplicate": true and creates nothing twice. |
Contact: the CRM looks up sender.contact_id first, then the email address, then the phone number and finally the ID within the channel.
API response: 201 with conversation_id, message_id, contact_id, created_conversation and "duplicate": false. GET /api/ext/v1/channels/inbound lists the account's API channels (a key “only for this channel” sees only its own).
The same with curl:
curl -X POST https://crm.the-y.at/api/ext/v1/channels/inbound \
-H "Authorization: Bearer tyk_…" \
-H "Content-Type: application/json" \
-d '{"channel_id":"<channel ID>","sender":{"id":"customer-4711","name":"Anna Muster"},"text":"Hello!","message_id":"msg-001"}'
| Response | Meaning |
|---|---|
400 invalid_field | A field is missing or invalid; field says which one. |
401 | No key or an invalid key. |
403 insufficient_scope | The key lacks the “Deliver messages” scope (channels:inbound). |
404 channel_not_found | This API channel does not exist in this account – or the key belongs to a different channel. |
409 channel_disabled | The API channel is switched off in the CRM; nothing is accepted. |
429 | Limit reached (see Limits). Wait the seconds given in Retry-After. |
503 temporarily_unavailable | Not possible right now. Send again in 30 seconds with the same message_id – nothing is created twice. |
Receive replies
Every reply in the conversation arrives as a POST at your reply address:
# Reply to your reply address (POST, JSON)
X-TheY-Event: message.outbound
X-TheY-Timestamp: 1763683200
X-TheY-Signature: v1=<HMAC-SHA256(secret, "<timestamp>.<body>")>
X-TheY-Event-Id: evt_<message ID>
{ "id": "evt_…", "event": "message.outbound", "tenant": "…", "at": "…",
"data": { "channel_id": "…", "conversation_id": "…", "thread": "order-4711",
"recipient": { "id": "customer-4711" },
"message": { "id": "…", "text": "It's on its way!", "author": { "name": "Ola" },
"attachments": [ { "filename": "invoice.pdf", "content_type": "application/pdf", "size": 12345, "data_base64": "…" } ] } } }
- Verify the signature like the webhooks under “Integrations”: HMAC-SHA256 with the secret over
<X-TheY-Timestamp>.<body>, timestamp at most 5 minutes old. Sample code: Verify the webhook signature. - To whom?
data.recipient.idis thesender.idfrom the incoming message,data.threadyour conversation ID (if you sent one). - Detect duplicates by
data.message.idorX-TheY-Event-Id(stays the same on “Send again”). - Answer with
2xx. If you return{ "id": "<your ID>" }, you can report the delivery status later. - Attachments are included as base64 (at most 5 MB in total).
- If delivery fails (429, 5xx or timeout), the CRM retries immediately, up to 3 attempts. After that the message is shown as “not delivered” in the conversation with a “Send again” button, and the channel's window shows the last error. After 3 failures in a row the admins get a notification (“replies are not getting through”, in the app and – if enabled – by email). Once it works again: “replies are getting through again”.
Report delivery status (optional)
If your system returned its own ID when it received a reply, use it to report the status later. The inbox then shows the ticks; the status only moves forward, never back.
POST https://crm.the-y.at/api/ext/v1/channels/inbound/status
Authorization: Bearer tyk_…
Content-Type: application/json
{ "channel_id": "<channel ID>", "message_id": "<your ID>", "status": "delivered" }
status is delivered, read or failed (optionally with error as a short text).
In the CRM: like the other channels
- Conversations carry the label “API channel”. Filters, saved views, SLA targets, assignment, brands and permissions work as for any channel.
- Automations: condition “Channel” = API channel; the action “Send reply in conversation” goes out via your reply address. Automations never send marketing through the API channel (there is no consent for it there).
- Opening hours: under Settings → Opening hours & holidays the API channel gets its own hours or “Like opening hours” and an auto-reply to the first message (default: off).
- Reply via the API and MCP:
POST /api/ext/v1/conversations/{id}/messages; find the channel's conversations withGET /api/ext/v1/conversations?channel=api. See the REST API reference. - Free plan: replies count towards the 1,000 outgoing messages per month like any other.
Limits
- Deliver, status and list count like any API request: Free 60 per minute and 1,000 per day; Cloud Pro, Paid and Founder 300 per minute (API limits). Replies the CRM sends to your address do not count.
- Message text up to 8,000 characters; attachments in replies up to 5 MB in total.
- Not included yet: incoming attachments (please put a link in the text) and starting a new conversation from your side – in the API channel the CRM only replies to messages your system delivered.
Troubleshooting
“403 insufficient_scope” although the key works otherwise
Existing keys do not get the “Deliver messages” scope automatically. Create a new key in the channel's window (“Create a key for this channel”).
“404 channel_not_found”
Check the channel_id (shown in the channel's window or in GET /api/ext/v1/channels/inbound). A key “only for this channel” gets 404 for any other channel.
Replies do not reach my system
Click “Send test” in the channel's window. In the cloud the address must start with https:// and answer with 2xx. The last error is shown below the address. Use “Send again” in the inbox for messages that were not delivered.
The signature never matches
Sign the body raw, exactly as it arrives – do not parse it as JSON and serialise it again. If you clicked “Create new secret”, the old one no longer works. Discard timestamps older than 5 minutes.
