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.
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.
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: Bearerwith theask:readscope- Origin
- One of the key’s allowed origins
- Call from
- The browser or your server
- Rate limit
recommendationsgroup, set by your plan- Retries
- Safe with
Idempotency-Key
Headers and parameters
| Field | Description |
|---|---|
Origin
|
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
|
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
|
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
|
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 addsmetric,usedandlimit).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 atupgrade_url. -
403 Forbidden
The key cannot be used for this request:
forbidden_scope,ip_not_allowedortenant_suspendedas for any key, or theOrigincheck failed:origin_not_configured,origin_required,origin_invalidororigin_not_allowed. -
409 Conflict
The
Idempotency-Keywas 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, witherrorskeyed by field), or theIdempotency-Keyheader 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). Waitretry_afterseconds. -
503 Unavailable
This capability is temporarily paused by Ottla (
feature_disabled). Try again afterRetry-Afterseconds;help_urlshows the service status.
Request fields
| Field | Description |
|---|---|
strategy
|
Which row: similar (the default), bought_together, coview, bestsellers, trending or recently_viewed. See Strategies below. |
external_id
|
The product the row is about, by your platform’s product id. Preferred over sku. |
sku
|
The product the row is about, by SKU. |
external_ids
|
Several products, up to 50: the basket for bought_together, or the products the shopper viewed, newest first, for recently_viewed. |
skus
|
As external_ids, by SKU. |
slot
|
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
|
For trending only: trending products in this category and its subcategories. |
exclude_external_ids
|
For recently_viewed only: products to leave out, such as the one on the page. Up to 50. |
context
|
For similar with no product: text describing what the shopper is looking at, up to 2,000 characters. |
| Field | Description |
|---|---|
limit
|
How many products, 1 to 50. Default 6. |
vid
|
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
|
badges adds social proof badges to each card. |
website_id
|
Ottla’s id for the website. Ignored for a key bound to one website, as every storefront key is. |
scope_ref
|
Your code for the market or language the shopper is browsing, such as uk. |
locale
|
The shopper’s language, such as en-GB. |
currency
|
The currency to show prices in, such as GBP. |
store_view_id
|
The store view, for a catalogue organised by store view. |
Strategies
| 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"}'
<?php
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://ottla.ai/api/v1/']);
$response = $client->post('recommendations', [
'headers' => [
'Authorization' => 'Bearer YOUR_BROWSER_KEY',
'Origin' => 'https://shop.example',
],
'json' => [
'strategy' => 'bought_together',
'external_id' => '1187',
'limit' => 4,
'slot' => 'pdp_bought_together',
],
]);
$row = json_decode((string) $response->getBody(), true);
Response
{
"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"
}
| Field | What it holds |
|---|---|
recommendations | The 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). |
reasons | On each card: a short line saying why it’s shown, such as “Often bought together”, in the shopper’s language. |
strategy | How the row was chosen, for diagnostics, such as copurchase, coview, bestsellers or trending. Values may be added, so don’t build logic on them. |
heading | The 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
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: Bearerwith theask:readscope- Origin
- One of the key’s allowed origins
- Call from
- The browser or your server
- Rate limit
product_alertsgroup, 60 a minute
Headers and parameters
| Field | Description |
|---|---|
Origin
|
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
|
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
|
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 addsmetric,usedandlimit).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 atupgrade_url. -
403 Forbidden
The key cannot be used for this request:
forbidden_scope,ip_not_allowedortenant_suspendedas for any key, or theOrigincheck failed:origin_not_configured,origin_required,origin_invalidororigin_not_allowed. -
422 Invalid
The request is not valid (
validation_failed, witherrorskeyed by field), or theIdempotency-Keyheader 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). Waitretry_afterseconds. -
503 Unavailable
This capability is temporarily paused by Ottla (
feature_disabled). Try again afterRetry-Afterseconds;help_urlshows the service status.
| Field | Description |
|---|---|
type
|
back_in_stock or price_drop. |
email
|
The shopper’s email address, up to 320 characters. |
consent
|
Must be true: the shopper agreed to be emailed about this product. |
marketing_consent
|
true only when the shopper also ticked a separate marketing box. Never tick that box for them. |
external_id
|
The product, by your platform’s product id. |
sku
|
The product, by SKU. Required when you don’t send external_id. |
website_id
|
Ottla’s id for the website. Ignored for a key bound to one website. |
scope_ref
|
Your code for the market or language, such as uk. |
currency
|
The currency for a price drop alert, such as GBP. |
store_view_id
|
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}'
<?php
// $client as in the recommendations example above
$response = $client->post('product-alerts', [
'headers' => [
'Authorization' => 'Bearer YOUR_BROWSER_KEY',
'Origin' => 'https://shop.example',
],
'json' => [
'type' => 'price_drop',
'sku' => 'TENT-2P',
'email' => $email,
'consent' => true,
'marketing_consent' => false,
],
]);
$status = json_decode((string) $response->getBody(), true)['status'];
| status | What to tell the shopper |
|---|---|
pending_confirmation | Check 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. |
unavailable | The product isn’t in your catalogue, or a price drop alert can’t be set because the product has no price. |
disabled | The 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.
Errors
| Status | Code | What to do |
|---|---|---|
| 401 | unauthenticated, invalid_api_key | Ensure you are sending a valid key. |
| 402 | account_past_due, account_suspended | Your billing needs attention. You should hide this row or form until this is resolved. |
| 403 | forbidden_scope and the origin_* codes | Your key needs the ask:read scope. You also need to send an allowed Origin. |
| 409 | idempotency_key_reused, idempotency_in_flight | Only when calling the /recommendations endpoint and you have sent an Idempotency-Key from your server. |
| 422 | validation_failed | Please fix any errors returned in the errors array. For alerts, this is most commonly a missing or false consent field, or no product. |
| 429 | rate_limited and the other rate limit codes | Please wait retry_after seconds. |
| 503 | feature_disabled | We 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.
Related
Events and revenue attribution
Report when a shopper clicks a recommended product and any subsequent orders.
Search
List your products with filters and search as you type on a custom storefront.
Recommendations
Learn what you can configure for product rows.
Stock and price alerts
Learn how back in stock and price drop alerts work.