Base URLhttps://ottla.ai/api/v1

API reference

Escalations

Allow your team to take over a conversation. Continue the chat within your own UI.

Updated 18 min read

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.

A chat passed to the team

The calls in order

  1. The shopper chats with the assistant through /ask until they ask for a person, or an answer comes back with fallback: true and you offer one.
  2. Call POST /escalation, with mode: "live" if you want a live chat, and keep the channel_secret.
  3. If channel is live, send the shopper’s messages with /escalation/message and poll /escalation/messages for replies. Meanwhile /ask answers human_active, so nothing talks over your team.
  4. If nobody has joined yet, offer to take an email address with /escalation/contact, so the reply still reaches the shopper.
  5. When the conversation closes, ask for a rating with /escalation/rate.

Hand the conversation to your team

POST /api/v1/escalation 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: Bearer with the feedback:write scope
Origin
One of the key’s allowed origins
Call from
The browser or your server
Rate limit
escalation group, 20 a minute
Retries
Safe with Idempotency-Key

Headers and parameters

POST /escalation: headers and parameters
FieldDescription
Origin string (uri) header Required 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 string header Optional 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 string header Optional 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 string header Optional 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_allowed or tenant_suspended as for any key, or the Origin check failed: origin_not_configured, origin_required, origin_invalid or origin_not_allowed.

  • 409 Conflict

    The Idempotency-Key was 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, with errors keyed by field), or the Idempotency-Key header 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). Wait retry_after seconds.

Request fields
FieldDescription
question string Optional What the shopper needs help with, up to 2,000 characters. It becomes the subject.
session_id string Optional The chat’s session_id, up to 128 characters, so your team sees the conversation.
shopper_contact string Optional An email address for the reply, up to 320 characters.
shopper_name string Optional The shopper’s name, up to 191 characters.
opened_reason string Optional shopper_request (the default) when the shopper asked for a person; fallback or no_answer when the assistant couldn’t help.
mode string Optional ticket (the default) or live to ask for a live chat.
context object Optional Further facts for your team as key and value pairs, up to 50 keys, such as the basket value.
website_id integer Optional 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"}'
201 response
{
  "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"
}
FieldWhat it holds
escalation_idThe handoff’s id in your Support inbox.
channelHow 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).
messageA line to show the shopper, in their language.
channel_secretThe 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.

Support inbox with the AI conversation shown above the agent’s reply Example data
Your team sees the whole conversation, the assistant’s part included, before they reply.

Send a message

POST /api/v1/escalation/message Send a live chat 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: Bearer with the feedback:write scope
Origin
One of the key’s allowed origins
Call from
The browser or your server
Rate limit
escalation_message group, 120 a minute
Retries
Safe with Idempotency-Key

Headers and parameters

POST /escalation/message: headers and parameters
FieldDescription
Origin string (uri) header Required 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 string header Optional 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 string header Optional 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 string header Optional 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_secret does 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-Key was 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, with errors keyed by field), or the Idempotency-Key header 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). Wait retry_after seconds.

Request fields
FieldDescription
channel_secret string Required The secret from POST /escalation, up to 64 characters.
body string Required The shopper’s message, up to 4,000 characters.

A sent message answers 201 with status: "sent" and its message_id.

Read new messages

POST /api/v1/escalation/messages Read live chat 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: Bearer with the feedback:write scope
Origin
One of the key’s allowed origins
Call from
The browser or your server
Rate limit
escalation_message group, 120 a minute

Headers and parameters

POST /escalation/messages: headers and parameters
FieldDescription
Origin string (uri) header Required 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 string header Optional 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 string header Optional 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_secret does 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, with errors keyed by field), or the Idempotency-Key header 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). Wait retry_after seconds.

Request fields
FieldDescription
channel_secret string Required The secret from POST /escalation.
since_id integer Optional The highest message id you already have. 0 or absent returns the whole conversation.
Message fieldDescription
idThe message id. Use the highest id you have received as your since_id when polling for more messages.
sendershopper, agent or system. Agents are team members on your store.
bodyThe body of the message. Can be null for some system messages.
event_kindPresent on system messages about the conversation, such as agent_joined or transferred.
agent_display_name, agent_avatar_urlDisplay name and avatar URL for the agent.
created_atWhen 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}'

Leave contact details while waiting

POST /api/v1/escalation/contact Leave contact details

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: Bearer with the feedback:write scope
Origin
One of the key’s allowed origins
Call from
The browser or your server
Rate limit
escalation group, 20 a minute
Retries
Safe with Idempotency-Key

Headers and parameters

POST /escalation/contact: headers and parameters
FieldDescription
Origin string (uri) header Required 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 string header Optional 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 string header Optional 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 string header Optional 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_secret does 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-Key was 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, with errors keyed by field), or the Idempotency-Key header 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). Wait retry_after seconds.

Request fields
FieldDescription
channel_secret string Required The secret from POST /escalation.
email string Required The shopper’s email address, up to 320 characters.
phone string Optional A phone number, up to 64 characters.

Saved details answer 201 with status: "captured".

Rate the conversation

POST /api/v1/escalation/rate 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: Bearer with the feedback:write scope
Origin
One of the key’s allowed origins
Call from
The browser or your server
Rate limit
escalation group, 20 a minute
Retries
Safe with Idempotency-Key

Headers and parameters

POST /escalation/rate: headers and parameters
FieldDescription
Origin string (uri) header Required 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 string header Optional 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 string header Optional 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 string header Optional 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_secret does 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-Key was 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, with errors keyed by field), or the Idempotency-Key header 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). Wait retry_after seconds.

Request fields
FieldDescription
channel_secret string Required The secret from POST /escalation.
rating integer Required 1 to 5.

A rating answers 201 with status: "rated".

Errors

StatusCodeWhat to do
401unauthenticated, invalid_api_keySend a valid key.
403not_authorisedThe channel_secret is wrong, or the conversation has closed. The response deliberately doesn’t say which. Stop polling and offer a new handoff.
403forbidden_scope and the origin_* codesThe key needs feedback:write, and the call needs an allowed Origin.
409idempotency_key_reused, idempotency_in_flightSee Idempotency.
422validation_failedFix the fields in errors, such as an invalid email or a rating outside 1 to 5.
429rate_limited and the other limit codesWait 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.

Try Ottla on your own store

Start a 14-day free trial with no card needed. The trial has every Pro feature, with lower limits, so you can install the module or the widget, connect your catalogue and try the assistant on your own products.

14 days free. No card needed.