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

API reference

Conversations

Retrieve a full conversation from a session. View a shopper’s previous chats on this device.

Updated 9 min read

On this page

Shoppers want to know that their chat persists after reloading a page. They may even come back the next day wanting to see that conversation about walking boots. Our chat history API allows you to build your own chat UI that can reload a conversation from a session, list previous chats from a visitor and delete a chat. Every chat is linked to a visitor id. Ottla sets the visitor id only when the shopper’s privacy mode allows it: after a yes, or, on stores outside the UK and the EU, until the shopper says no.

An example chat on Kestrel & Fell’s store. A note in the chat says: “Your chats on this device”.

Read a conversation

GET /api/v1/conversation Read a conversation

The whole conversation for a session_id, oldest first: the shopper’s questions, the assistant’s answers and any messages with your team. Use it to restore a chat after a page load, or poll with since for new messages. Send the fields as query parameters.

Key
Authorization: Bearer with the ask:read scope
Call from
The browser or your server
Rate limit
conversation_read group, set by your plan

Headers and parameters

GET /conversation: headers and parameters
FieldDescription
session_id string query Required
since integer query Optional Return only messages after this cursor.
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

    The conversation (empty when there is none).

  • 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: it lacks the scope (forbidden_scope), it is limited to other IP addresses (ip_not_allowed), or the workspace is not active (tenant_suspended).

  • 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.

POST /api/v1/conversation Read a conversation (POST)

The same, with the fields in a JSON body. Use whichever suits your client.

Key
Authorization: Bearer with the ask:read scope
Call from
The browser or your server
Rate limit
conversation_read group, set by your plan
Request fields
FieldDescription
session_id string Required The conversation’s session_id, up to 128 characters.
since integer Optional The cursor from an earlier response, to fetch only newer messages. 0 or absent returns the whole conversation.
FieldWhat it holds
messagesOldest first. Each has sort_key, created_at, role and payload.
roleWho wrote it: shopper, the assistant (ai), a person from the store’s team (agent) or system.
payloadA shopper question has body. An answer has answer_id and blocks, which you render as you would an answer from /ask. A message in a handoff conversation has the same fields as /escalation/messages returns.
cursorSend it as since next time to fetch only newer messages.

Chats created by a signed-in customer via our Magento module are only returned to that customer, meaning you receive an empty array when making a direct call. This is deliberate, to prevent anyone reading a signed-in shopper’s chat by guessing a session id.

List a visitor’s chats

POST /api/v1/conversations List a visitor’s chats

The chats held under one visitor id, most recent first, with titles only. Fetch a whole chat with /conversation. Without a visitor id the list is empty.

Key
Authorization: Bearer with the ask:read scope
Call from
The browser or your server
Rate limit
conversation_read group, set by your plan

Headers and parameters

POST /conversations: headers and parameters
FieldDescription
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

    The visitor’s chats.

  • 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: it lacks the scope (forbidden_scope), it is limited to other IP addresses (ip_not_allowed), or the workspace is not active (tenant_suspended).

  • 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
ottla_vid string Optional The visitor id the chats were held under: the vid you send with /ask. Up to 128 characters.
website_id integer Optional Ottla’s id for the website. Ignored for a key bound to one website.

The response holds conversations, each with session_id, title (usually the first question), last_activity_at and message_count.

Remove a chat

POST /api/v1/conversations/delete Remove a chat

Removes one of a visitor’s chats from their list. Send the visitor id it was held under; without it nothing is removed. The answer is always 204, whether or not the chat existed, so the response never reveals which chats there are.

Key
Authorization: Bearer with the ask:read scope
Call from
The browser or your server
Rate limit
conversation_read group, set by your plan

Headers and parameters

POST /conversations/delete: headers and parameters
FieldDescription
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

  • 204 No content

    Done.

  • 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: it lacks the scope (forbidden_scope), it is limited to other IP addresses (ip_not_allowed), or the workspace is not active (tenant_suspended).

  • 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
session_id string Required The chat to remove, up to 128 characters.
ottla_vid string Optional The visitor id the chat was held under. Without it, nothing is removed.

Example: restore, list and remove

curl "https://ottla.ai/api/v1/conversation?session_id=sess_8f2c1&since=0" \
  -H "Authorization: Bearer YOUR_BROWSER_KEY"

Errors

StatusCodeWhat to do
401unauthenticated, invalid_api_keyEnsure you are sending a valid key.
403forbidden_scope, ip_not_allowedYour key needs the ask:read scope, or it is restricted to other IP addresses.
422validation_failedPlease send a session_id that is 128 characters or less.
429rate_limited and the other rate limit codesPlease wait retry_after seconds. Try polling at a lower rate if there is no activity in the chat.

FAQ

Questions developers ask

Why does delete always return 204?

This means you never know if a chat exists or not. If someone were to guess session ids, they would learn nothing.

How long are conversations kept?

There’s no set period. The chat history these endpoints return is kept until that shopper’s data is erased or your workspace is deleted, and removing a chat with /conversations/delete only hides it from the visitor’s list. To erase a shopper’s data, use the shopper erasure endpoint. Retention periods for everything else are on the data and privacy page.

Do I need consent for chat history?

Yes, on UK and EU stores. Previous chats are listed by visitor id, and Ottla sets the visitor id only when the shopper’s privacy mode allows it: after a yes, or on stores outside the UK and the EU until the shopper says no. Without it, the current chat still works during that session but does not appear in the list later.

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.