API reference
Escalations
Allow your team to take over a conversation. Continue the chat within your own UI.
On this page
There are times when a shopper needs to speak to a team member, whether that’s for a bulk order, an issue with their delivery or a question your catalogue can’t answer. Our chatbot escalation API opens that handoff and, if you have live chat enabled, carries the conversation between the shopper and your team. Handoffs go to your team in Ottla’s Support inbox with the conversation attached, and can also be forwarded to your own help desk by webhook.
Handoffs by email, ticket and webhook are on every plan. Live chat is on Growth and above. Every endpoint here needs feedback:write (your Storefront widget key has it) and an allowed Origin, and honours Idempotency-Key from a server, apart from /escalation/messages. For the whole flow, step by step, read the live chat handoff guide.
The calls in order
- The shopper chats with the assistant through
/askuntil they ask for a person, or an answer comes back withfallback: trueand you offer one. - Call
POST /escalation, withmode: "live"if you want a live chat, and keep thechannel_secret. - If
channelislive, send the shopper’s messages with/escalation/messageand poll/escalation/messagesfor replies. Meanwhile/askanswershuman_active, so nothing talks over your team. - If nobody has joined yet, offer to take an email address with
/escalation/contact, so the reply still reaches the shopper. - When the conversation closes, ask for a rating with
/escalation/rate.
Hand the conversation to your team
Hands the shopper to a person on your team. The conversation so far is attached, it lands in the Support inbox and your team is alerted by email. When you send shopper_contact, your team’s reply is emailed to the shopper too. Rate limit group escalation: 20 a minute per key.
- Key
Authorization: Bearerwith thefeedback:writescope- Origin
- One of the key’s allowed origins
- Call from
- The browser or your server
- Rate limit
escalationgroup, 20 a minute- Retries
- Safe with
Idempotency-Key
Headers and parameters
| Field | Description |
|---|---|
Origin
|
Your storefront’s address, which must be one of the key’s allowed origins. Browsers send it themselves; a server must send it too. |
Idempotency-Key
|
Makes a retry safe: the same key, path and body within 24 hours returns the first response again. A key is shared by every API key and store in the workspace, so it must be unique to each request (a random id, not a row number from one store’s database): reusing the key with a different body is refused with 409. Servers only. |
X-Ottla-Client-Ip
|
The shopper’s public IP address, when your server calls on a shopper’s behalf, so each shopper has their own allowance. Read only for a key marked “Used by a store connector or another server” in the console, which also needs allowed IP addresses; ignored for any other key. |
X-Ottla-Request-Id
|
Your own id for this request, returned in the response header. Ottla creates one when you send none. Servers only. |
Responses
-
201 Created
Received.
-
401 Unauthorised
No API key was sent (
unauthenticated), or the key is unknown, revoked or expired (invalid_api_key). -
403 Forbidden
The key cannot be used for this request:
forbidden_scope,ip_not_allowedortenant_suspendedas for any key, or theOrigincheck failed:origin_not_configured,origin_required,origin_invalidororigin_not_allowed. -
409 Conflict
The
Idempotency-Keywas used before with a different body (idempotency_key_reused), or a request with it is still running (idempotency_in_flight). -
422 Invalid
The request is not valid (
validation_failed, witherrorskeyed by field), or theIdempotency-Keyheader is malformed (invalid_idempotency_key). -
429 Rate limited
A rate limit was reached: this key’s limit for the operation’s group (
rate_limited), the workspace’s limit across all its keys (tenant_rate_limited), the limit for one network address (ip_rate_limited) or for one shopper (shopper_rate_limited). Waitretry_afterseconds.
| Field | Description |
|---|---|
question
|
What the shopper needs help with, up to 2,000 characters. It becomes the subject. |
session_id
|
The chat’s session_id, up to 128 characters, so your team sees the conversation. |
shopper_contact
|
An email address for the reply, up to 320 characters. |
shopper_name
|
The shopper’s name, up to 191 characters. |
opened_reason
|
shopper_request (the default) when the shopper asked for a person; fallback or no_answer when the assistant couldn’t help. |
mode
|
ticket (the default) or live to ask for a live chat. |
context
|
Further facts for your team as key and value pairs, up to 50 keys, such as the basket value. |
website_id
|
Ottla’s id for the website. Ignored for a key bound to one website. |
curl https://ottla.ai/api/v1/escalation \
-H "Authorization: Bearer YOUR_BROWSER_KEY" \
-H "Origin: https://shop.example" \
-H "Content-Type: application/json" \
-d '{"question": "Can I change the delivery address on my order?", "session_id": "sess_8f2c1", "shopper_contact": "[email protected]", "mode": "ticket"}'
<?php
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://ottla.ai/api/v1/']);
$response = $client->post('escalation', [
'headers' => [
'Authorization' => 'Bearer YOUR_BROWSER_KEY',
'Origin' => 'https://shop.example',
'Idempotency-Key' => bin2hex(random_bytes(16)),
],
'json' => [
'question' => 'Can I change the delivery address on my order?',
'session_id' => 'sess_8f2c1',
'shopper_contact' => '[email protected]',
'mode' => 'ticket',
],
]);
$handoff = json_decode((string) $response->getBody(), true);
{
"status": "received",
"escalation_id": 912,
"channel": "ticket",
"message": "Thanks! A member of the team will reply here, and we'll also email you if you've stepped away.",
"channel_secret": "q7Rk2VbN9xT4mLs8DfW3hJc6YpZ1aGe5uKo0iXv7BnM2tQr4"
}
| Field | What it holds |
|---|---|
escalation_id | The handoff’s id in your Support inbox. |
channel | How it reaches your team: ticket (the Support inbox, with replies by email), live (a live chat) or handoff (forwarded to your own help desk by webhook, carried by the escalation.opened event). |
message | A line to show the shopper, in their language. |
channel_secret | The secret for this conversation’s live chat calls. Returned only when a new conversation opens. |
Asking for mode: "live" opens a live chat only when live chat is on your plan, switched on and someone is available. Otherwise it opens as a ticket, so always read channel rather than assuming. There’s one open conversation per session_id: a repeat request adds to it and returns no secret, so keep the first one.
Send a message
Posts the shopper’s message into their open conversation with your team. Rate limit group escalation_message: 120 a minute for each conversation.
- Key
Authorization: Bearerwith thefeedback:writescope- Origin
- One of the key’s allowed origins
- Call from
- The browser or your server
- Rate limit
escalation_messagegroup, 120 a minute- Retries
- Safe with
Idempotency-Key
Headers and parameters
| Field | Description |
|---|---|
Origin
|
Your storefront’s address, which must be one of the key’s allowed origins. Browsers send it themselves; a server must send it too. |
Idempotency-Key
|
Makes a retry safe: the same key, path and body within 24 hours returns the first response again. A key is shared by every API key and store in the workspace, so it must be unique to each request (a random id, not a row number from one store’s database): reusing the key with a different body is refused with 409. Servers only. |
X-Ottla-Client-Ip
|
The shopper’s public IP address, when your server calls on a shopper’s behalf, so each shopper has their own allowance. Read only for a key marked “Used by a store connector or another server” in the console, which also needs allowed IP addresses; ignored for any other key. |
X-Ottla-Request-Id
|
Your own id for this request, returned in the response header. Ottla creates one when you send none. Servers only. |
Responses
-
201 Created
Sent.
-
401 Unauthorised
No API key was sent (
unauthenticated), or the key is unknown, revoked or expired (invalid_api_key). -
403 Forbidden
The key cannot be used for this request (as for any storefront operation), or
channel_secretdoes not match an open conversation (not_authorised). The response does not say which, so it cannot be used to guess conversations.Error codes:
forbidden_scopeip_not_allowedtenant_suspendedorigin_not_configuredorigin_requiredorigin_invalidorigin_not_allowed -
409 Conflict
The
Idempotency-Keywas used before with a different body (idempotency_key_reused), or a request with it is still running (idempotency_in_flight). -
422 Invalid
The request is not valid (
validation_failed, witherrorskeyed by field), or theIdempotency-Keyheader is malformed (invalid_idempotency_key). -
429 Rate limited
A rate limit was reached: this key’s limit for the operation’s group (
rate_limited), the workspace’s limit across all its keys (tenant_rate_limited), the limit for one network address (ip_rate_limited) or for one shopper (shopper_rate_limited). Waitretry_afterseconds.
| Field | Description |
|---|---|
channel_secret
|
The secret from POST /escalation, up to 64 characters. |
body
|
The shopper’s message, up to 4,000 characters. |
A sent message answers 201 with status: "sent" and its message_id.
Read new messages
Returns the conversation’s messages after since_id, oldest first. Poll it every few seconds while a live chat is open to show your team’s replies: each conversation has its own allowance, so every open chat can poll as often as every 2 seconds. It also returns the last messages of a conversation that has just closed. It isn’t idempotent, and it shares the escalation_message rate limit group.
- Key
Authorization: Bearerwith thefeedback:writescope- Origin
- One of the key’s allowed origins
- Call from
- The browser or your server
- Rate limit
escalation_messagegroup, 120 a minute
Headers and parameters
| Field | Description |
|---|---|
Origin
|
Your storefront’s address, which must be one of the key’s allowed origins. Browsers send it themselves; a server must send it too. |
X-Ottla-Client-Ip
|
The shopper’s public IP address, when your server calls on a shopper’s behalf, so each shopper has their own allowance. Read only for a key marked “Used by a store connector or another server” in the console, which also needs allowed IP addresses; ignored for any other key. |
X-Ottla-Request-Id
|
Your own id for this request, returned in the response header. Ottla creates one when you send none. Servers only. |
Responses
-
200 OK
New messages.
-
401 Unauthorised
No API key was sent (
unauthenticated), or the key is unknown, revoked or expired (invalid_api_key). -
403 Forbidden
The key cannot be used for this request (as for any storefront operation), or
channel_secretdoes not match an open conversation (not_authorised). The response does not say which, so it cannot be used to guess conversations.Error codes:
forbidden_scopeip_not_allowedtenant_suspendedorigin_not_configuredorigin_requiredorigin_invalidorigin_not_allowed -
422 Invalid
The request is not valid (
validation_failed, witherrorskeyed by field), or theIdempotency-Keyheader is malformed (invalid_idempotency_key). -
429 Rate limited
A rate limit was reached: this key’s limit for the operation’s group (
rate_limited), the workspace’s limit across all its keys (tenant_rate_limited), the limit for one network address (ip_rate_limited) or for one shopper (shopper_rate_limited). Waitretry_afterseconds.
| Field | Description |
|---|---|
channel_secret
|
The secret from POST /escalation. |
since_id
|
The highest message id you already have. 0 or absent returns the whole conversation. |
| Message field | Description |
|---|---|
id | The message id. Use the highest id you have received as your since_id when polling for more messages. |
sender | shopper, agent or system. Agents are team members on your store. |
body | The body of the message. Can be null for some system messages. |
event_kind | Present on system messages about the conversation, such as agent_joined or transferred. |
agent_display_name, agent_avatar_url | Display name and avatar URL for the agent. |
created_at | When the message was sent, formatted as ISO 8601. |
curl https://ottla.ai/api/v1/escalation/messages \
-H "Authorization: Bearer YOUR_BROWSER_KEY" \
-H "Origin: https://shop.example" \
-H "Content-Type: application/json" \
-d '{"channel_secret": "q7Rk2VbN9xT4mLs8DfW3hJc6YpZ1aGe5uKo0iXv7BnM2tQr4", "since_id": 77120}'
<?php
// $client as in the handoff example above
$response = $client->post('escalation/messages', [
'headers' => ['Authorization' => 'Bearer YOUR_BROWSER_KEY', 'Origin' => 'https://shop.example'],
'json' => ['channel_secret' => $secret, 'since_id' => $sinceId],
]);
$messages = json_decode((string) $response->getBody(), true)['messages'];
Leave contact details while waiting
Adds the shopper’s email address, and a phone number if they like, to their open conversation while they wait, so your team can still reply by email if the shopper leaves. Shares the escalation rate limit group.
- Key
Authorization: Bearerwith thefeedback:writescope- Origin
- One of the key’s allowed origins
- Call from
- The browser or your server
- Rate limit
escalationgroup, 20 a minute- Retries
- Safe with
Idempotency-Key
Headers and parameters
| Field | Description |
|---|---|
Origin
|
Your storefront’s address, which must be one of the key’s allowed origins. Browsers send it themselves; a server must send it too. |
Idempotency-Key
|
Makes a retry safe: the same key, path and body within 24 hours returns the first response again. A key is shared by every API key and store in the workspace, so it must be unique to each request (a random id, not a row number from one store’s database): reusing the key with a different body is refused with 409. Servers only. |
X-Ottla-Client-Ip
|
The shopper’s public IP address, when your server calls on a shopper’s behalf, so each shopper has their own allowance. Read only for a key marked “Used by a store connector or another server” in the console, which also needs allowed IP addresses; ignored for any other key. |
X-Ottla-Request-Id
|
Your own id for this request, returned in the response header. Ottla creates one when you send none. Servers only. |
Responses
-
201 Created
Saved.
-
401 Unauthorised
No API key was sent (
unauthenticated), or the key is unknown, revoked or expired (invalid_api_key). -
403 Forbidden
The key cannot be used for this request (as for any storefront operation), or
channel_secretdoes not match an open conversation (not_authorised). The response does not say which, so it cannot be used to guess conversations.Error codes:
forbidden_scopeip_not_allowedtenant_suspendedorigin_not_configuredorigin_requiredorigin_invalidorigin_not_allowed -
409 Conflict
The
Idempotency-Keywas used before with a different body (idempotency_key_reused), or a request with it is still running (idempotency_in_flight). -
422 Invalid
The request is not valid (
validation_failed, witherrorskeyed by field), or theIdempotency-Keyheader is malformed (invalid_idempotency_key). -
429 Rate limited
A rate limit was reached: this key’s limit for the operation’s group (
rate_limited), the workspace’s limit across all its keys (tenant_rate_limited), the limit for one network address (ip_rate_limited) or for one shopper (shopper_rate_limited). Waitretry_afterseconds.
| Field | Description |
|---|---|
channel_secret
|
The secret from POST /escalation. |
email
|
The shopper’s email address, up to 320 characters. |
phone
|
A phone number, up to 64 characters. |
Saved details answer 201 with status: "captured".
Rate the conversation
Records the shopper’s satisfaction with the conversation, from 1 (poor) to 5 (excellent). Ratings show in your Support inbox and are sent as the escalation.rated webhook. Shares the escalation rate limit group.
- Key
Authorization: Bearerwith thefeedback:writescope- Origin
- One of the key’s allowed origins
- Call from
- The browser or your server
- Rate limit
escalationgroup, 20 a minute- Retries
- Safe with
Idempotency-Key
Headers and parameters
| Field | Description |
|---|---|
Origin
|
Your storefront’s address, which must be one of the key’s allowed origins. Browsers send it themselves; a server must send it too. |
Idempotency-Key
|
Makes a retry safe: the same key, path and body within 24 hours returns the first response again. A key is shared by every API key and store in the workspace, so it must be unique to each request (a random id, not a row number from one store’s database): reusing the key with a different body is refused with 409. Servers only. |
X-Ottla-Client-Ip
|
The shopper’s public IP address, when your server calls on a shopper’s behalf, so each shopper has their own allowance. Read only for a key marked “Used by a store connector or another server” in the console, which also needs allowed IP addresses; ignored for any other key. |
X-Ottla-Request-Id
|
Your own id for this request, returned in the response header. Ottla creates one when you send none. Servers only. |
Responses
-
201 Created
Rated.
-
401 Unauthorised
No API key was sent (
unauthenticated), or the key is unknown, revoked or expired (invalid_api_key). -
403 Forbidden
The key cannot be used for this request (as for any storefront operation), or
channel_secretdoes not match an open conversation (not_authorised). The response does not say which, so it cannot be used to guess conversations.Error codes:
forbidden_scopeip_not_allowedtenant_suspendedorigin_not_configuredorigin_requiredorigin_invalidorigin_not_allowed -
409 Conflict
The
Idempotency-Keywas used before with a different body (idempotency_key_reused), or a request with it is still running (idempotency_in_flight). -
422 Invalid
The request is not valid (
validation_failed, witherrorskeyed by field), or theIdempotency-Keyheader is malformed (invalid_idempotency_key). -
429 Rate limited
A rate limit was reached: this key’s limit for the operation’s group (
rate_limited), the workspace’s limit across all its keys (tenant_rate_limited), the limit for one network address (ip_rate_limited) or for one shopper (shopper_rate_limited). Waitretry_afterseconds.
| Field | Description |
|---|---|
channel_secret
|
The secret from POST /escalation. |
rating
|
1 to 5. |
A rating answers 201 with status: "rated".
Errors
| Status | Code | What to do |
|---|---|---|
| 401 | unauthenticated, invalid_api_key | Send a valid key. |
| 403 | not_authorised | The channel_secret is wrong, or the conversation has closed. The response deliberately doesn’t say which. Stop polling and offer a new handoff. |
| 403 | forbidden_scope and the origin_* codes | The key needs feedback:write, and the call needs an allowed Origin. |
| 409 | idempotency_key_reused, idempotency_in_flight | See Idempotency. |
| 422 | validation_failed | Fix the fields in errors, such as an invalid email or a rating outside 1 to 5. |
| 429 | rate_limited and the other limit codes | Wait retry_after seconds. Slow your polling while nobody is typing. |
FAQ
Questions developers ask
How do I get new messages?
Poll /escalation/messages every few seconds with the highest message id you have as since_id.
Where should I keep channel_secret?
With that one conversation and nowhere else: in the shopper’s session on your server, or in session storage if your storefront keeps the chat in the browser. It’s returned once, when the conversation opens.
Why do I get 403 not_authorised?
The secret is incorrect or the conversation has ended. We do not tell you which, to prevent probing.
What is the handoff channel?
When your team forwards handoffs to its own help desk, channel is handoff and the escalation.opened webhook carries the details. Set it up under Customer chat → Support settings.
Related
Live chat handoff guide
Learn more about our whole handoff flow, from offer to rating.
Conversations
Returns a full conversation from both the assistant and your team.
Webhook events
escalation.opened, escalation.message, escalation.resolved and escalation.rated.
Live chat
Learn more about what your team has access to when using live chat, on Growth and above.