Limits and errors
Last changed
Every error the API can return, what caused it, what to do and what the libraries do for you, then the events refused one by one and the limits behind them.
In short
- A failed call answers with an HTTP status and a JSON body holding an error
code: branch on thecode, never on themessage. The body and the full table of codes are in the API reference. - The body's
docs_url(and the libraries' error messages) end with the address of the code's section below. - The libraries retry what can succeed later (
rate_limited,unavailable,internal) when sending events. Errors in the request itself (invalid_request,not_found,too_large) are never retried: fix the call. - A recommendation call is never retried: when recapi is slow, failing or over a limit, the library answers with popular items instead, so your page needs no error handling.
- Request rates and sizes have limits, and monthly calls are capped by the plan: see Limits.
The error body
The body is { "error": { "code", "message", "docs_url" } } (the API reference). Servers before
docs_url, and the codes a library makes itself, send no address.
The libraries report a failure as a RecapiError with the code, the HTTP status, the message and a retryable
flag. It also carries the address (docsUrl, docs_url, DocsURL or DocsUrl, in each language's style), and its
message ends with it, so the line in a browser console or a log is a link to the fix. A few codes come from the
library rather than the API, such as network and timeout.
Errors by code
400 invalid_request
Cause: the body or a field breaks a rule: a value out of range (count above 100), an id or tag that breaks the
rules below, metadata over 2,048 bytes, a body that isn't JSON, malformed gzip, or an unknown field. Unknown fields are
refused on purpose, so a typo such as "tag_any" fails instead of being ignored.
What to do: read the message, which names the field, and the one you likely meant when a single field fits
(unknown field "id", did you mean "item_id"?), and fix the call.
Libraries: not retried. recommend and popular raise it, since it is a bug a developer sees on the first run.
One exception: a product id taken from a visitor's URL that the API would refuse is never sent. The library answers
with popular items and reports the problem.
401 unauthorized
Cause: the API key is missing, mistyped or revoked, or belongs to a deleted environment; the message reads
"missing or invalid API key". A secret key sent in the URL (?key=) also gets 401: secret keys go in the
Authorization header only. A revoked key stops working within a minute.
What to do: check the key against the API keys under the dashboard's Set up and create a new one if needed (authentication).
Libraries: not retried. recommend answers with an empty list at once (a popular list would be refused too), and
the error goes to your error handler or one console line.
403 forbidden
Cause: a public key (rk_pub_) was used for a call that needs the secret key (rk_sec_), such as writing items,
reading a user's history or asking for explain. It also comes back when the shop is suspended.
What to do: call secret-key calls from your server only. If the message says it is suspended, contact us.
Libraries: not retried. recommend answers with an empty list, as for 401.
404 not_found
Cause: the item you asked for doesn't exist (reading or deleting an item), or the path doesn't exist. A wrong base URL is the usual cause of the second.
What to do: check the item id, and that the base URL is the API address your dashboard's quick start shows.
Libraries: not retried, and raised by recommend and popular.
413 too_large
Cause: the body is over the call's size limit (see Limits).
What to do: send smaller batches. The libraries send events in batches of 100 from the browser, and at most 1,000 from a server.
Libraries: not retried. A refused batch of events is dropped and reported.
429 rate_limited
Cause: your shop went over its requests per second, or one visitor address over its limit a minute with your
public key (both counted as in Limits); or a product page's call to
POST /v1/shopify/products:seen or POST /v1/products:seen arrived while another of your shop's was still being written. The answer carries
Retry-After: 1.
What to do: wait the Retry-After delay and retry, with backoff if the header is missing. Send events in batches
rather than one request each.
Libraries: events are retried up to 3 times, with the delay the header asks for. recommend is not retried: it
answers with popular items at once.
429 quota_exceeded
Cause: your organization reached its monthly quota: the free plan's free units for that kind of call, or the spend cap of a paid plan. All environments of an organization count together, so a test environment's calls use it up too. A batch of events that would go over it fails whole, and nothing in it is stored.
What to do: add a payment method on the dashboard's Usage & billing page, or ask us to raise your spend cap (recapi sets caps; there is no dashboard setting). Otherwise the quota resets with the month.
Libraries: not retried. Events refused this way are lost. recommend answers with popular items while that call
is still allowed, else an empty list.
503 unavailable
Cause: recapi is briefly unable to take the call, for example while storing events, or your shop was created
seconds ago and isn't loaded yet. During a traffic peak past what a server can take, recapi answers this at once, with
Retry-After: 1, rather than keep your page waiting for seconds.
What to do: retry after the Retry-After delay when it is sent, else with backoff.
Libraries: events are retried up to 3 times, then kept in the queue for a later try. recommend answers with
popular items.
500 internal
Cause: something failed on recapi's side.
What to do: retry with backoff. If it persists, contact us with the time of the call.
Libraries: handled as for 503.
Events refused one by one
POST /v1/events checks each event on its own. The good ones are stored, and the bad ones are listed in the 202
answer with their position in the batch:
{ "accepted": 1, "rejected": [ { "index": 3, "error": "level must be an integer from -10 to 10" } ] }
These carry a message, not a code. The messages you can meet:
| Message | What to do |
|---|---|
item_id must be 1-256 bytes of UTF-8 (or user_id, anon_id, recommendation_id, event_id) |
send an id of 1 to 256 bytes |
item_id must not contain control characters (or another id field) |
remove tabs, line breaks and other control characters from the id |
level is required |
send a level with each event |
level must be an integer from -10 to 10 |
send a whole number: 3 view, 5 cart, 10 purchase |
timestamp must be RFC 3339 or unix milliseconds |
send 2026-10-23T12:00:00Z or a number of milliseconds, or leave it out |
Past events loaded with POST /v1/events:import can also get timestamp is required on an imported event,
timestamp must be at most 90 days old or timestamp must not be in the future.
The JavaScript library reports refused events as event_rejected; the other libraries log them. A negative level is
not an error: it is a visitor's "not interested" (rejections).
Limits
| Limit | Value | Past it |
|---|---|---|
| Requests per shop | at least 2,000 a second, 4,000 in bursts; per API server, so it grows as recapi adds servers; a batch's events count one per ten, and a several-list call one per list | 429 rate_limited |
| Requests per visitor address, public key | 600 a minute, counted as above; each API server counts on its own | 429 rate_limited |
| Monthly calls | the plan's free units, or the paid plan's spend cap | 429 quota_exceeded |
| Events call | 1 to 1,000 events, 2 MB | 400 or 413 too_large |
| Item batch | up to 1,000 items, 8 MB | 400 or 413 too_large |
One item (PUT, PATCH) |
64 KB, metadata up to 2,048 bytes | 413 or 400 |
| Recommendation call | 256 KB, 1 to 10 lists | 413 or 400 |
count (recommendations and popular) |
1 to 100, 10 by default | 400 |
exclude |
up to 500 item ids | 400 |
tags_any, tags_all |
up to 32 tags each | 400 |
| Items created by events | 50,000 on the free plan, 200,000 on a paid plan | the event is stored, the item isn't created |
Gzip bodies may expand to 4 times the limit.
Ids, tags and placement names follow the rules in the API reference (tags: up to 32 on an item) and concepts.
Event times older than 7 days are moved to 7 days ago, so load older events with the import call (up to 90 days
back). An event repeated with the same event_id within 2 minutes is stored and billed once.
Items created by events: past the cap, the event is still stored and billed but its item isn't created; items you send yourself never count (the API reference). Home warns from 80% (Items created from events).
Monthly quota: each kind of call (events, recommendation calls, popular lists, item writes) has its own free units a month, shown on the Usage & billing page. On the free plan, Home and Usage & billing warn you from 80%. Failed calls are not billed.