API reference
API reference
The conventions every Ottla endpoint shares, and where each endpoint is documented.
On this page
Our REST API is the same API our widget and Magento module use. It can be used to ask questions, show search results and recommendation rows, hand off conversations to your team, report what shoppers do and keep your catalogue up to date. Some features that require a signed-in shopper, such as trade prices and buy it again, only work if you are using our Magento module. If you are looking for an AI shopping assistant API for your headless or custom storefront, this is the place to start. If you are on Magento or Adobe Commerce, you don’t need to use our API, as our module does this for you.
Base URLs
| Base URL | Use it for |
|---|---|
| https://ottla.ai/api/v1 | Every request. Use this one in new code and in every example on these pages. |
| https://uk.ottla.ai/api/v1 | The same API. The Magento module uses this address, and either one works. |
Your data is hosted in the UK (London). Answers come from our AI service in London; if it is unavailable, the assistant can fall back to Mistral AI in the EU (France). We will be adding EU and US regions in the near future, and when we do, we will add their addresses to this page. We currently have one version of our API, version 1, which is included in the path. Versioning and changes explains how it grows without breaking your code.
Authentication
Send your API key as a bearer token in the Authorization header:
Authorization: Bearer YOUR_BROWSER_KEY
You create keys in the console under Storefront → API keys. Each key is shown once, when you create it, and starts with osk_live_. A server may send the key in X-API-Key instead; browsers can’t send that header to Ottla, so stick to Authorization in page scripts.
Each endpoint states what scope it requires. There are 3 scopes that cover our API:
ask:readasks questions, searches, reads recommendations, starter questions and conversations, signs shoppers up for alerts and reports orders from your server.feedback:writesends answer ratings, storefront events and handoffs to your team.ingest:writesends and removes catalogue and content, checks progress and asks for a shopper’s data to be erased.
A Storefront widget key carries the first two, for calls made on shoppers’ behalf, and is locked to your storefront’s address. A Server import key carries ingest:write and must never leave your servers. Authentication has the full scope list, and API keys and allowed origins covers choosing and locking keys.
Conventions
| Convention | What it means for your code |
|---|---|
| JSON in, JSON out | Send Content-Type: application/json. Every response body is JSON, apart from 204 responses, which have no body. |
| POST for most reads | Most endpoints use POST, reads included, because Ottla accepts only GET and POST from browsers. |
| Products by your own id | Identify a product by your platform’s product id (external_id) or by its sku. Where both work, external_id is preferred. |
| Dates | ISO 8601 with a time zone, for example 2026-10-21T10:42:00Z. |
| Money | Price fields hold decimal amounts such as 129.00. Fields ending _minor hold whole minor units: pence for GBP, so £129.00 is 12900. |
| website_id | Ottla’s id for one of your websites, not your platform’s. A key bound to one website, as every storefront key is, ignores it. |
| Markets and languages | scope_ref is your own code for the market the shopper is browsing, such as uk. locale and currency set the language and currency of the reply. |
Request ids
Every response carries an X-Ottla-Request-Id header. Quote it when you contact us and we can find the call straight away. Your server can also send its own id in the same header, 8 to 64 characters of letters, digits, -, _ and ., to tie a call to your own logs. Ottla returns it unchanged, and creates one for you when you don’t send it.
POST /api/v1/ask HTTP/1.1
Host: ottla.ai
Authorization: Bearer YOUR_BROWSER_KEY
Origin: https://shop.example
Content-Type: application/json
X-Ottla-Request-Id: pdp-ask.7f3e9a12
HTTP/1.1 200 OK
Content-Type: application/json
X-Ottla-Request-Id: pdp-ask.7f3e9a12
X-Ottla-Platform-Contract: 10
X-RateLimit-Limit: 120
X-RateLimit-Remaining: 119
Idempotency
Networks drop connections at the worst moments. To retry a write without doing the work twice, send an Idempotency-Key header from your server: any unique value of 8 to 128 characters, using letters, digits, -, _, . and :. A fresh UUID for each logical request works well, and you reuse it for every retry of that request.
| You send | Ottla answers |
|---|---|
| The same key and the same body within 24 hours | The first response again, with Idempotency-Replay: true. Nothing runs twice. |
| The same key with a different body | 409 idempotency_key_reused. A new request needs a new key. |
| The same key while the first request is still running | 409 idempotency_in_flight. Wait a moment, then retry with the same key. |
| A key that breaks the format rules | 422 invalid_idempotency_key. |
| A retry after a 422, 429 or 5xx response | The request runs again. Those responses are never stored, so fix the request or wait, then retry under the same key. |
Browsers can’t send this header to Ottla, so idempotency is a server tool. It’s honoured on /ask, /compare, /search, /recommendations, /suggested-questions, /feedback, /track, /escalation, /escalation/message, /escalation/rate, /escalation/contact, /attribution/ingest, every /ingest/* write and /privacy/shopper-erasure.
It’s ignored on reads and on calls that are safe to repeat anyway: /product-search, /autocomplete, /search/events, /product-questions, /product-alerts, /conversation, /conversations, /conversations/delete, /escalation/messages and /ingest/acks.
curl https://ottla.ai/api/v1/ingest/products \
-H "Authorization: Bearer YOUR_SERVER_KEY" \
-H "Idempotency-Key: products-2026-10-21-batch-0042" \
-H "Content-Type: application/json" \
-d @batch-0042.json
import { randomUUID } from 'node:crypto';
export async function sendProducts(items) {
const key = randomUUID(); // one key for this batch, reused on every retry
for (let attempt = 1; attempt <= 5; attempt++) {
const res = await fetch('https://ottla.ai/api/v1/ingest/products', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_SERVER_KEY',
'Content-Type': 'application/json',
'Idempotency-Key': key,
},
body: JSON.stringify({ items }),
});
const body = await res.json().catch(() => ({}));
const retry = res.status >= 500 || res.status === 429 || body.error === 'idempotency_in_flight';
if (!retry) return { status: res.status, body };
const seconds = body.retry_after ?? 2 ** attempt;
await new Promise((resolve) => setTimeout(resolve, seconds * 1000));
}
throw new Error('Batch not accepted after 5 attempts');
}
<?php
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://ottla.ai/api/v1/', 'http_errors' => false]);
$key = bin2hex(random_bytes(16)); // one key for this batch, reused on every retry
for ($attempt = 1; $attempt <= 5; $attempt++) {
$response = $client->post('ingest/products', [
'headers' => [
'Authorization' => 'Bearer YOUR_SERVER_KEY',
'Idempotency-Key' => $key,
],
'json' => ['items' => $items],
]);
$status = $response->getStatusCode();
$body = json_decode((string) $response->getBody(), true) ?? [];
$retry = $status >= 500 || $status === 429 || ($body['error'] ?? null) === 'idempotency_in_flight';
if (! $retry) {
break;
}
sleep((int) ($body['retry_after'] ?? 2 ** $attempt));
}
Response headers
| Header | Sent on | What it tells you |
|---|---|---|
| X-Ottla-Request-Id | Every response | This call’s id. Quote it when you contact us. |
| X-Ottla-Platform-Contract | Every response | The revision of these conventions, currently 10. |
| X-RateLimit-Limit | Responses within your limit | Requests a minute this key has for the endpoint’s group. |
| X-RateLimit-Remaining | Responses within your limit | Requests left in the current minute. |
| Retry-After | 429 and 503 | Seconds to wait before you try again. |
| Idempotency-Replay | A repeated Idempotency-Key | true when this is the stored first response. |
| X-Ottla-Ingest | Accepted catalogue and content writes | The write was accepted and will be processed shortly. |
Errors
Every error is JSON with a stable error code and a readable message. Branch on error, never on message, which we may reword. Validation errors add errors, keyed by field. Errors lists every code with what to do next.
{
"error": "validation_failed",
"message": "The question field is required.",
"errors": {
"question": ["The question field is required."]
}
}
When the assistant is paused
If a workspace uses all of its monthly answered questions and has no credits left, Ottla pauses the assistant until credits are added, the plan changes or the next month starts. Your storefront keeps working. Instead of errors, the storefront reads return empty results, so rows and suggestions quietly stay hidden.
| Endpoint | Response while paused |
|---|---|
| /ask | 402 plan_limit_exceeded, with metric, used, limit and upgrade_url. |
| /recommendations | recommendations is empty and strategy is disabled. |
| /search | results is empty, strategy is disabled and latency_ms is 0. |
| /product-search | An empty page of products, with strategy disabled. |
| /autocomplete | suggestions is empty. |
| /search/events | 200 with stored 0 and strategy disabled. |
| /product-questions | questions is empty. |
| /product-alerts | status is disabled. |
| The widget | Removes itself from the page until the assistant is back. |
A different case: when a payment is overdue, or a free trial ends without a plan, the assistant, search, recommendation, order and catalogue endpoints answer 402 account_past_due until the workspace owner sorts out billing. Feedback, storefront events and handoffs keep flowing meanwhile, so you don’t lose data.
Endpoints
| Operation | Scope | Documented on |
|---|---|---|
| POST /ask | ask:read | Ask |
| POST /compare | ask:read | Ask |
| POST /product-search | ask:read | Search |
| POST /autocomplete | ask:read | Search |
| POST /search | ask:read | Search |
| POST /search/events | ask:read | Search |
| POST /recommendations | ask:read | Recommendations and alerts |
| POST /product-alerts | ask:read | Recommendations and alerts |
| POST /suggested-questions | ask:read | Suggested questions |
| POST /product-questions | ask:read | Suggested questions |
| POST /feedback | feedback:write | Feedback |
| POST or PATCH /feedback/{feedback} | feedback:write | Feedback |
| POST /track | feedback:write | Events and revenue attribution |
| POST /attribution/ingest | ask:read | Events and revenue attribution |
| GET or POST /conversation | ask:read | Conversations |
| POST /conversations, /conversations/delete | ask:read | Conversations |
| POST /escalation | feedback:write | Escalations |
| POST /escalation/message, /messages, /contact, /rate | feedback:write | Escalations |
| POST /ingest/products, /ingest/products/deindex | ingest:write | Ingestion |
| POST /ingest/categories, /ingest/categories/deindex | ingest:write | Ingestion |
| POST /ingest/cms-pages, /faqs, /reviews, /blog-posts | ingest:write | Ingestion |
| POST /ingest/documents, /ingest/deindex | ingest:write | Ingestion |
| POST /ingest/orders, /ingest/acks | ingest:write | Ingestion |
| POST /privacy/shopper-erasure | ingest:write | Ingestion |
| GET /reviews, /reviews/{review_id} | reviews:read | Reviews and questions |
| GET /review-insights | reviews:read | Reviews and questions |
| POST /reviews/{review_id}/reply | reviews:write | Reviews and questions |
| GET /questions, /questions/queue | questions:read | Reviews and questions |
| POST /questions/{question_id}/answer | questions:write | Reviews and questions |
| GET /health | None | Health check |
Shopper-facing endpoints
Ask
Answer a question from a shopper and show them products to compare.
Search
Search results, listings for a category, autocomplete and search events.
Recommendations and alerts
Show product rows on any page. Sign up for back in stock and price drop alerts.
Suggested questions
Questions to start a chat with and approved questions and answers for a product page.
Feedback
Rate an answer with a thumbs up or down and tell us why.
Events and revenue attribution
Track clicks and adds to basket on your storefront, and orders from your server.
Conversations
Reload a conversation. See a shopper’s previous chats and delete a chat.
Escalations
Transfer a chat to your team. Use the live chat within your own UI.
Data and monitoring
Ingestion
Push and delete products, content and orders. Erase a shopper’s data.
Reviews and questions
Read your published reviews and product questions from your own systems, save reply drafts and answer questions.
Health check
An unauthenticated request to check if our API is up. Useful for an uptime monitor.
FAQ
Questions developers ask
Which base URL should I use?
https://ottla.ai/api/v1. The address https://uk.ottla.ai/api/v1 serves the same API, and the Magento module uses it, so either works.
Is there a GraphQL API?
No. The Ottla API is REST with JSON bodies. Most endpoints take a POST with a small JSON body, reads included.
For headless Magento implementations, the Ottla GraphQL module (ottla/module-graph-ql) is currently in beta and can be installed and configured with help from Ottla support. It allows the products query in Magento to return product positions as ranked by Ottla, and under Platform Contract 10, product Q&As/reviews and a new query ottlaProductPage. All are disabled by default and can be toggled in Magento.
Are there SDKs?
No. We provide code snippets on every reference page for curl and PHP. Node.js is also provided for jobs that you may run on your server. All requests are simple HTTPS requests that can be made by any HTTP client.
How do I retry a request safely?
Send an Idempotency-Key from your server and reuse it on every retry. Responses with status 5xx, 429 and 422 aren’t stored, so a retry with the same key runs the request again. See Idempotency.
Why can’t my browser code read X-RateLimit-Remaining?
Ottla doesn’t expose its rate limit headers to page scripts. When you hit a limit, read retry_after from the 429 body and wait that many seconds.