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

API reference

Recommendations and alerts

Show product rows on any page. Allow shoppers to sign up for alerts on products they can’t buy today.

Updated 15 min read

On this page

Our product recommendations API builds rows of products from your real orders and browsing: similar products, frequently bought together, customers also viewed, best sellers, trending and recently viewed. Rows remain empty until we have enough data to build a good row, rather than padding them with whatever is to hand. Any rules your team sets in the console are applied to every row, so a pinned product stays pinned and an excluded one never shows. These endpoints do not use any of your answered questions.

A Customers also bought row on a product page Example data
A bought together row on a product page, filled from /recommendations.

Get recommendations

POST /api/v1/recommendations Get recommendations

Returns product cards for one row: start from a product, a basket or nothing at all (best sellers and trending). Only enabled products the shopper can see are returned, priced as guest prices. Rate limit group recommendations, which grows with your plan.

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
recommendations group, set by your plan
Retries
Safe with Idempotency-Key

Headers and parameters

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

    Recommended products.

  • 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

Anchor and strategy
FieldDescription
strategy string Optional Which row: similar (the default), bought_together, coview, bestsellers, trending or recently_viewed. See Strategies below.
external_id string Optional The product the row is about, by your platform’s product id. Preferred over sku.
sku string Optional The product the row is about, by SKU.
external_ids array Optional Several products, up to 50: the basket for bought_together, or the products the shopper viewed, newest first, for recently_viewed.
skus array Optional As external_ids, by SKU.
slot string Optional A row set up in Merchandising → Recommendation rows, such as pdp_bought_together: up to 48 lowercase letters, digits and underscores. Brings that row’s heading, strategy and pinned products.
category_external_id string Optional For trending only: trending products in this category and its subcategories.
exclude_external_ids array Optional For recently_viewed only: products to leave out, such as the one on the page. Up to 50.
context string Optional For similar with no product: text describing what the shopper is looking at, up to 2,000 characters.
Scope and options
FieldDescription
limit integer Optional How many products, 1 to 50. Default 6.
vid string Optional The visitor id, sent only with the shopper’s consent. Keeps a visitor in the same group when the recently viewed row is in a holdout experiment.
include array Optional badges adds social proof badges to each card.
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, such as uk.
locale string Optional The shopper’s language, such as en-GB.
currency string Optional The currency to show prices in, such as GBP.
store_view_id integer Optional The store view, for a catalogue organised by store view.

Strategies

Values of strategy
Strategy What the row shows What it needs
similar Products like this one. The default. A product, or context text describing what the shopper is looking at.
bought_together Products often bought in the same orders as this product or basket. Order history, from the Magento module or /ingest/orders.
coview Products the same shoppers viewed: a customers also viewed row. Product views from your storefront.
bestsellers Your best sellers. Order history.
trending Products selling faster lately, across the store or in one category. Order history.
recently_viewed The products you list in external_ids, as cards. The ids you send. Keep the list in the shopper’s browser.

Our Magento module also provides rows that require information only it can send, such as who the signed-in shopper is or what’s in their basket: buy it again, time to restock, free delivery suggestions and “What you’ll need” kits. These are not available via a direct call.

Example request

A bought together row on the product page for the Ridgeline 2 tent, using a row your team has set up in your console.

curl https://ottla.ai/api/v1/recommendations \
  -H "Authorization: Bearer YOUR_BROWSER_KEY" \
  -H "Origin: https://shop.example" \
  -H "Content-Type: application/json" \
  -d '{"strategy": "bought_together", "external_id": "1187", "limit": 4, "slot": "pdp_bought_together"}'

Response

200 response, trimmed to one card
{
  "recommendations": [
    {
      "sku": "MAT-SELF",
      "external_id": "1342",
      "name": "Self-Inflating Sleeping Mat",
      "url": "https://shop.example/self-inflating-mat",
      "image_url": "https://shop.example/media/mat.jpg",
      "price": "£45.00",
      "was_price": null,
      "on_sale": false,
      "reasons": [ { "type": "bought_together", "text": "Often bought together" } ],
      "card_v": 1,
      "type": "simple",
      "requires_options": false,
      "pricing": { "amount": 45.0, "currency": "GBP", "tax": "incl", "formatted": "£45.00", "hidden": false },
      "availability": "in_stock",
      "lifecycle": "active"
    }
  ],
  "strategy": "copurchase",
  "heading": "Goes well with"
}
FieldWhat it holds
recommendationsThe cards, best first. Each has name, url, image_url, price as shown (such as £45.00), was_price and on_sale, plus sku, external_id, pricing, availability and requires_options (true when the shopper must pick a size or colour first).
reasonsOn each card: a short line saying why it’s shown, such as “Often bought together”, in the shopper’s language.
strategyHow the row was chosen, for diagnostics, such as copurchase, coview, bestsellers or trending. Values may be added, so don’t build logic on them.
headingThe row’s heading from the console, in the shopper’s language, when the slot has one. Null means use your own.

An empty recommendations list is a normal answer: hide the row. It usually means there isn’t enough data for that strategy yet, and strategy then starts with fallback_ to say why. disabled means the assistant is paused for the workspace.

Sign up for a stock or price alert

POST /api/v1/product-alerts Sign up for a stock or price alert

Signs a shopper up to be emailed when a product is back in stock or its price drops. We currently hold and do not dispatch price drop emails on stores we consider EU-based, due to the requirement to show the lowest price of the 30 days before the reduction in the email, which Ottla does not show yet. Use it on a product page when the shopper can’t buy today, alongside a row of in-stock alternatives. Rate limit group product_alerts: 60 a minute per key, with extra limits per shopper.

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
product_alerts group, 60 a minute

Headers and parameters

POST /product-alerts: 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

    The sign-up’s status.

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

  • 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
type string Required back_in_stock or price_drop.
email string Required The shopper’s email address, up to 320 characters.
consent boolean Required Must be true: the shopper agreed to be emailed about this product.
marketing_consent boolean Optional true only when the shopper also ticked a separate marketing box. Never tick that box for them.
external_id string Optional The product, by your platform’s product id.
sku string Optional The product, by SKU. Required when you don’t send external_id.
website_id integer Optional Ottla’s id for the website. Ignored for a key bound to one website.
scope_ref string Optional Your code for the market or language, such as uk.
currency string Optional The currency for a price drop alert, such as GBP.
store_view_id integer Optional The store view, for a catalogue organised by store view.
curl https://ottla.ai/api/v1/product-alerts \
  -H "Authorization: Bearer YOUR_BROWSER_KEY" \
  -H "Origin: https://shop.example" \
  -H "Content-Type: application/json" \
  -d '{"type": "back_in_stock", "external_id": "1187", "email": "[email protected]", "consent": true, "marketing_consent": false}'
statusWhat to tell the shopper
pending_confirmationCheck your inbox to confirm. Ottla gives the same answer whether or not the address was already signed up, so nobody can test which emails are on your list.
unavailableThe product isn’t in your catalogue, or a price drop alert can’t be set because the product has no price.
disabledThe assistant is paused for the workspace. Hide the form.

Ottla takes care of the rest. We first send an email with a confirmation link (double opt-in), then notify the shopper when the product comes back or gets cheaper. Every email includes an unsubscribe link. Your team can view this demand under Catalogue → Waiting list: which products your shoppers are waiting for, how many and for how long.

The alert.subscribed and alert.notified webhooks carry the shopper’s email only as a SHA-256 hash. If your store has connected Klaviyo, only shoppers who gave marketing consent are passed on to it.

Waiting list in the Ottla console showing products shoppers are waiting for Example data
Demand for out of stock products, without a single shopper email on show.

Errors

StatusCodeWhat to do
401unauthenticated, invalid_api_keyEnsure you are sending a valid key.
402account_past_due, account_suspendedYour billing needs attention. You should hide this row or form until this is resolved.
403forbidden_scope and the origin_* codesYour key needs the ask:read scope. You also need to send an allowed Origin.
409idempotency_key_reused, idempotency_in_flightOnly when calling the /recommendations endpoint and you have sent an Idempotency-Key from your server.
422validation_failedPlease fix any errors returned in the errors array. For alerts, this is most commonly a missing or false consent field, or no product.
429rate_limited and the other rate limit codesPlease wait retry_after seconds.
503feature_disabledWe have temporarily paused this feature. You should hide this row and try again later.

FAQ

Questions developers ask

Why is my row empty?

You likely do not have enough orders or product views yet to build a row for that strategy. If it’s a recently viewed row, the visitor may also be in a holdout experiment. You should hide the row; it fills itself as more data builds up.

Can I pin or exclude products?

Yes. Your team sets rules under Merchandising → Rules, or on the row itself under Merchandising → Recommendation rows. Send that row’s slot and its pins apply.

Do recommendations use answered questions?

No. Product rows and alert sign-ups never use any of your monthly answered questions.

Who sends the alert emails?

We send the confirmation email and the alert for you, both with an unsubscribe link, so you don’t need to build either.

Can alert sign-ups reach Klaviyo?

Yes, when your store has connected Klaviyo, and only for shoppers who ticked the separate marketing box.

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.