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

API reference

Ask

Answer a shopper’s question using your catalogue, prices, stock levels, shipping rates and content.

Updated 21 min read

On this page

The Ottla ask API accepts a question and returns a short answer, along with products that can be viewed or added to the basket. If we don’t have the information to answer the question, we say so plainly and can offer to pass the shopper to a team member rather than guess. If a query is vague (“a tent for the Lakes”), we may ask one short clarifying question with 2 to 4 options for the shopper to tap. It’s like having an ecommerce question answering API that only answers from what you’ve given it.

Prices and stock are taken from your store’s own data, synced via our Magento module or sent using the ingestion endpoints. Any mention of price or stock that we cannot back up with that data is removed by guardrails. Delivery options and costs are pulled from your store’s shipping rates, and the assistant does not promise a delivery date that your store has not given.

Each answer uses one answered question from your monthly allowance, polite refusals included. Comparing products with /compare doesn’t use any.

Ask a question

POST /api/v1/ask Ask a question

Answers one shopper question. Send the page the shopper is on, and the same session_id for every question in a conversation, so follow-ups such as “and in green?” make sense. Call it from your server, sending one of the key’s allowed origins as Origin; the ask rate limit group is shared with /compare and /search.

Key
Authorization: Bearer with the ask:read scope
Origin
One of the key’s allowed origins
Call from
The browser or your server
Rate limit
ask group, set by your plan
Retries
Safe with Idempotency-Key

Headers and parameters

POST /ask: 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

  • 200 OK

    The answer, or human_active while a person is handling the chat.

  • 401 Unauthorised

    No API key was sent (unauthenticated), or the key is unknown, revoked or expired (invalid_api_key).

  • 402 Payment required

    Billing needs attention. plan_limit_exceeded: the plan’s allowance and any credits are used up (the body adds metric, used and limit). account_past_due: a payment is overdue, or a trial ended without a plan. account_suspended: the account is suspended. Stop sending until the workspace owner resolves it at upgrade_url.

  • 403 Forbidden

    As for any storefront operation (see the ForbiddenStorefront response), and ip_not_allowed with status: "hidden" when the widget sent is limited to other networks: hide the chat for this shopper.

    Error codes: forbidden_scopetenant_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.

  • 503 Unavailable

    This capability is temporarily paused by Ottla (feature_disabled). Try again after Retry-After seconds; help_url shows the service status.

Request fields

Question and conversation
FieldDescription
question string Required The shopper’s question, up to 2,000 characters.
session_id string Optional Your id for the conversation, up to 128 characters. Reuse it for every question in the chat, and send it with feedback, handoffs and conversation reads.
vid string Optional A stable id for the shopper’s browser, up to 128 characters. Send it only with the shopper’s consent. It lets the shopper reopen their earlier chats.
website_id integer Optional Ottla’s id for the website. Ignored for a key bound to one website, as every storefront key is.
scope_ref string Optional Your code for the market or language the shopper is browsing, up to 64 characters, such as uk. Leave it out to use the website’s default.
locale string Optional The shopper’s language, up to 35 characters, such as en-GB.
currency string Optional The currency to show prices in, up to 8 characters, such as GBP.
store_view_id integer Optional The store view, for a catalogue organised by store view. An older alternative to scope_ref.
widget string Optional Your widget’s public id, up to 64 characters. Applies that widget’s IP allow-list, so a shopper outside it gets 403 ip_not_allowed.
Page and context
FieldDescription
sku string Optional The SKU of the product the shopper is looking at, up to 255 characters.
page_type string Optional The kind of page: home, cms, plp (a listing), search, pdp (a product page), cart (the basket page), checkout, success (order confirmation), account or other.
placement string Optional Where the chat sits on the page: chat, sidebar or inline.
surface string Optional The location on the page that the chat dialog was invoked from, up to 100 characters, such as pdp_questions. An order following a question asked via this can also appear against this feature in Analytics.
page_context object Optional The product on the page with its current details: product.sku, product.name, product.url and product.attributes (up to 50 attributes).
basket object Optional The shopper’s basket, so the assistant can answer questions about it: items (sku, name, qty and the line price as shown), subtotal and grand_total.
context object Optional Further facts about the page as key and value pairs, up to 50 keys.
channel_secret string Optional Only while a live chat is open: the secret from POST /escalation, so the shopper’s message reaches the person handling the chat.

We ignore any fields that attempt to set a customer group or shopper identity, meaning you receive guest prices when making a direct call. Customer group prices can only reach Ottla via our Magento module, as the module can vouch for who a signed-in shopper is.

Example request

curl https://ottla.ai/api/v1/ask \
  -H "Authorization: Bearer YOUR_BROWSER_KEY" \
  -H "Origin: https://shop.example" \
  -H "Content-Type: application/json" \
  -d '{"question": "Will the Ridgeline 2 fit in a 40 litre rucksack?", "session_id": "sess_8f2c1", "sku": "TENT-2P", "page_type": "pdp", "placement": "chat"}'

Response

200 response
{
  "answer_id": 58213,
  "answer": "Yes. The Ridgeline 2 packs down to 45 x 15 cm and weighs 2.1 kg, so it fits in most 40 litre rucksacks.",
  "blocks": [
    {
      "type": "text",
      "version": "1.0",
      "content": "Yes. The Ridgeline 2 packs down to 45 x 15 cm and weighs 2.1 kg, so it fits in most 40 litre rucksacks."
    },
    {
      "type": "product_cards",
      "version": "1.0",
      "items": [
        {
          "sku": "TENT-2P",
          "name": "Ridgeline 2 Person Tent",
          "url": "https://shop.example/ridgeline-2-person-tent",
          "image_url": "https://shop.example/media/tent-2p.jpg",
          "price": "£129.00"
        }
      ]
    },
    {
      "type": "quick_replies",
      "version": "1.0",
      "items": [
        { "label": "How long does it take to pitch?", "value": "How long does it take to pitch?" }
      ]
    }
  ],
  "confidence": "high",
  "suggested_follow_ups": ["How long does it take to pitch?"],
  "recommended_products": [
    {
      "sku": "TENT-2P",
      "name": "Ridgeline 2 Person Tent",
      "url": "https://shop.example/ridgeline-2-person-tent",
      "image_url": "https://shop.example/media/tent-2p.jpg",
      "price": "£129.00"
    }
  ],
  "fallback": false,
  "refusal_reason": null,
  "sources": []
}
Fields in an answer
Field Type What it holds
answer_id integer The answer’s id. Send it with feedback and events about this answer.
answer string The answer as plain text. It always carries the whole answer, so it works on its own.
blocks array What to show, in order. See Answer blocks below.
confidence string high, medium or low: how well your catalogue and content covered the question.
suggested_follow_ups array Short questions the shopper might ask next.
recommended_products array Up to 6 products the answer recommends: sku, name, url, image_url and price with its currency symbol.
fallback boolean true when the assistant couldn’t answer and answer holds your fallback message.
refusal_reason string or null Why the assistant didn’t answer. See Refusal reasons below.
sources array Always empty, kept for later. Each answer in the Questions log shows the sources it used.

Answer blocks

Each block in blocks has a type and a version (currently "1.0"), following the ottla.blocks.v1 set. Blocks add to the written answer rather than replace it, so render the types you support, in order, and skip the rest. A front end that shows only text and product_cards still gives shoppers the full answer. New types may be added at any time.

TypeWhat it shows
textThe answer in words, in content. Always present.
product_cardsProducts as cards, in items, each with a link, image and price.
comparison_tableTwo or more products side by side, attribute by attribute.
quick_repliesReplies to tap, in items (label and value). Send the value back as the next question.
clarificationOne short clarifying question with 2 to 4 options, when the request was vague.
cart_summaryWhat’s in the shopper’s basket, when they ask about it.
order_statusWhere a signed-in shopper’s order has got to. Needs order data from the Magento module.
shipping_estimateDelivery options and costs from your store’s shipping rates.
reviewsWhat reviewers say about a product.
promotionA current offer that applies to the products in the answer.
no_resultsNothing in your catalogue matched, with a way forward.
errorThe assistant couldn’t answer just now. With retry: true it’s safe to ask again.
availabilityStock for a product or its options.
account_summaryDetails from a signed-in shopper’s account. Needs the Magento module.
faqA question and answer from your FAQs that matches.
bundleProducts that go together, such as everything needed for a job.
add_to_cart_confirmConfirms a product went into the basket.
human_handoffAn offer to talk to a person on your team. Sent only to clients that advertise the handoff capability, as Ottla’s own widget does.

Refusal reasons

When the assistant doesn’t answer, fallback is true and refusal_reason says why, so your code can react: offer a person, show a search box or simply display the message. Most reasons point at something missing from your data, which is good news, because you can fix it. Every refusal also appears in AI assistant → Questions log with what to add, and repeated ones are grouped in Catalogue gaps.

ValueWhat happenedWhat to add or check
out_of_scopeThe question isn’t about your store or its products.Nothing. This is the assistant staying on topic.
pricing_not_authoredYour data has no price information that answers it.Check the product’s prices are syncing, or add your pricing policy as a page.
stock_not_knownStock for the product isn’t known.Send stock with the product, or check stock is syncing.
delivery_not_authoredYour data doesn’t cover delivery for this question.Add a delivery information page or your shipping rates.
warranty_not_authoredThere’s no warranty information to answer from.Add your warranty policy or the product’s warranty terms.
compatibility_not_authoredNothing says whether these products work together.Add compatibility details to the product’s attributes or a spec sheet.
safety_guardrailThe answer would have made a safety claim your content doesn’t support.Add the manual, installation guide or spec sheet that states it.
prompt_injectionThe message tried to change how the assistant behaves.Nothing. The instruction was ignored.
no_sourcesNothing in your catalogue or content answers it.Add the missing product details, FAQ or page.
low_confidenceWhat matched wasn’t enough to answer well.Fill out the product’s description and attributes.
not_authoredA claim was removed because your data doesn’t support it.Add the fact to your product data or content.
otherAny other reason.Open the question in the Questions log for detail.

New values may be added. Treat any value you don’t recognise as a refusal and show the message in answer.

Questions log entry showing why the assistant could not answer and what to add Example data
Each refusal comes with what to add, so gaps get fixed rather than repeated.

Other successful responses

Three 200 responses aren’t ordinary answers. Handle them and your chat will never look stuck.

ResponseWhat it meansWhat to do
status is human_active, with escalation_id and messageA person from your team is handling this session’s live chat.Show the message, and send the shopper’s next messages to POST /escalation/message.
fallback is true, the last block is an error block with retry: true, and refusal_reason is nullThe assistant couldn’t answer just now.It’s safe to ask again, ideally after a short pause.
A clarification or quick_replies block with 2 to 4 optionsThe request was vague and the assistant asked one short question.Show the options. Send the one the shopper taps as the next question, with the same session_id.

Errors

StatusCodeWhat to do
401unauthenticated, invalid_api_keySend a valid key. A revoked or expired key needs replacing.
402plan_limit_exceededThe monthly answered questions and credits are used up. The body adds metric, used, limit and upgrade_url. Hide the chat until credits are added, the plan changes or the month resets.
402account_past_due, account_suspendedBilling needs attention. Hide the chat until the workspace owner resolves it at upgrade_url.
403forbidden_scopeThe key doesn’t have ask:read.
403origin_not_configured, origin_required, origin_invalid, origin_not_allowedThe Origin check failed. See API keys and allowed origins.
403ip_not_allowedThe key, or the widget you named, is limited to other networks. When the body has status: "hidden", hide the chat for this shopper.
409idempotency_key_reused, idempotency_in_flightSee Idempotency.
422validation_failed, invalid_idempotency_keyFix the fields listed in errors.
429rate_limited and the other limit codesWait retry_after seconds. See Rate limits.
503feature_disabledOttla has paused this capability for a short time. Try again after Retry-After seconds.

Compare products

POST /api/v1/compare Compare products

Returns two to five products side by side, attribute by attribute, for your own comparison table. There’s no written answer, so no answered question is used. Same scope, Origin check and rate limit group as /ask.

Key
Authorization: Bearer with the ask:read scope
Origin
One of the key’s allowed origins
Call from
The browser or your server
Rate limit
ask group, set by your plan
Retries
Safe with Idempotency-Key

Headers and parameters

POST /compare: 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

  • 200 OK

    The products and the comparison.

  • 401 Unauthorised

    No API key was sent (unauthenticated), or the key is unknown, revoked or expired (invalid_api_key).

  • 402 Payment required

    Billing needs attention. plan_limit_exceeded: the plan’s allowance and any credits are used up (the body adds metric, used and limit). account_past_due: a payment is overdue, or a trial ended without a plan. account_suspended: the account is suspended. Stop sending until the workspace owner resolves it at upgrade_url.

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

  • 503 Unavailable

    This capability is temporarily paused by Ottla (feature_disabled). Try again after Retry-After seconds; help_url shows the service status.

Request fields
FieldDescription
skus array Required The products to compare: 2 to 5 SKUs.
website_id integer Optional Ottla’s id for the website. Ignored for a key bound to one website.
curl https://ottla.ai/api/v1/compare \
  -H "Authorization: Bearer YOUR_BROWSER_KEY" \
  -H "Origin: https://shop.example" \
  -H "Content-Type: application/json" \
  -d '{"skus": ["TENT-2P", "TENT-3P"]}'
200 response
{
  "products": [
    { "id": 4101, "sku": "TENT-2P", "name": "Ridgeline 2 Person Tent", "url": "https://shop.example/ridgeline-2-person-tent", "image_url": "https://shop.example/media/tent-2p.jpg", "attrs_json": { "berths": 2, "weight_kg": 2.1 } },
    { "id": 4102, "sku": "TENT-3P", "name": "Ridgeline 3 Person Tent", "url": "https://shop.example/ridgeline-3-person-tent", "image_url": "https://shop.example/media/tent-3p.jpg", "attrs_json": { "berths": 3, "weight_kg": 2.9 } }
  ],
  "comparison_matrix": [
    { "attribute": "berths", "TENT-2P": 2, "TENT-3P": 3 },
    { "attribute": "weight_kg", "TENT-2P": 2.1, "TENT-3P": 2.9 }
  ]
}

products holds each product’s id, SKU, name, link, image and attributes in attrs_json. comparison_matrix has one row per attribute: attribute, then one key per SKU with that product’s value, or null when it has none. Prices are left out on purpose, because they change more often than attributes: show them from a product card. Hidden and disabled products are never compared. In Ottla’s own chat, shoppers can compare up to 4 products at once.

How the widget shows an answer

If you decide to build your own chat, this is the shape you should be aiming for: the text answer first, then cards and then quick replies.

An example chat on Kestrel & Fell’s store. The shopper asks: “Will the Ridgeline 2 fit in a 40 litre rucksack?”. The assistant answers: “Yes. It packs down to 45 x 15 cm and weighs 2.1 kg, so it fits in most 40 litre rucksacks. If you’re short of space, the Ridgeline 2 Lite packs smaller.”, and shows Ridgeline 2 Person Tent (£129.00) and Ridgeline 2 Lite Tent (£159.00).

FAQ

Questions developers ask

Does every call use an answered question?

Every answer from /ask does, polite refusals included. /compare doesn’t, and nor do search, recommendations or starter questions.

Why is sources always empty?

It’s reserved for future use and always returns an empty array. Your team can see what sources were used to answer each question under AI assistant → Questions log. Shoppers do not see these.

What should I do with block types I don’t support?

Skip them. Every block adds to the written answer, so answer and the text block stand on their own.

Can the assistant quote trade prices through the API?

No. You receive guest prices when making a direct API call. Customer group prices can only be sent via our Magento module, which can vouch for a signed-in shopper.

What happens when the monthly allowance runs out?

/ask answers 402 plan_limit_exceeded until credits are added, the plan changes or the month resets. While the assistant is paused, storefront reads such as search and recommendations return empty results rather than errors, as When the assistant is paused explains.

Check out our AI shopping assistant feature page to learn what shoppers experience and how you can configure it for your store.

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.