Search documentation

Search titles, headings, and page summaries.

Errors and retries

Every v1 API error code, whether to retry it, and how to retry without double counting.

Updated 2026-12-05

Every /api/v1 endpoint reports problems the same way, so one piece of error handling covers them all. Branch on error.code: it is stable. error.message is written for people and may change.

JSON
{  "error": {    "code": "invalid_payload",    "message": "The request body doesn't match the schema. See details.",    "requestId": "req_9mVb2Kx7QwLp3TzA",    "details": [{ "path": "params.plan", "issue": "too_long" }]  }}

details points at the field (path) and names the problem (issue). requestId is also sent in the Request-Id header. Log it, and include it if you contact support: it identifies the exact request.

Error codes

CodeStatusRetry?Meaning
invalid_payload400NoThe body isn't valid JSON, isn't application/json, or a field breaks a rule. See details.
stale_event400NoThe eventId or occurredAt is more than 24 hours old or more than 5 minutes ahead.
unauthorized401NoThe key is missing, unknown, or revoked.
forbidden403NoThe key is real but has the other purpose. Use a Custom events key for events and a Stripe attribution key for payments.
identity_mode_limited409NoPayment attribution only: a visitorId was sent for a cookieless website. Send a userId instead.
stripe_not_connected409NoPayment attribution only: connect Stripe for this website first.
checkout_incomplete409NoPayment attribution only: the Checkout Session has no completed payment.
payment_intent_unavailable409NoPayment attribution only: the connected Stripe account has no such payment.
metadata_conflict409NoPayment attribution only: the payment is already linked to a different visitor or user.
payload_too_large413NoThe body is over the limit: 16 KB for one event, 256 KB for a batch.
rate_limited429YesToo many requests. Wait for Retry-After.
quota_exceeded429After Retry-AfterThe workspace reached its tracked-event limit. retryAfter in the body gives the same wait in seconds.
internal_error500YesSomething failed on Graytower's side.
unavailable503YesA service Graytower depends on is briefly unavailable. Wait for Retry-After.

Network errors, timeouts, and responses you can't read count as temporary: retry them.

How to retry

Retries are safe because each eventId counts once per website for 24 hours. Follow these rules:

What happenedWhat to do
acceptedDone
duplicateDone. Graytower already had the event, often from an earlier attempt whose response was lost.
rejected in a batch, or a 4xx other than 429Don't retry. Log the code and details once, and fix the cause.
rate_limited, unavailable, or any 5xxRetry every unconfirmed event with the same eventIds, after Retry-After when it's present.
quota_exceededWait for Retry-After, then retry. Events sent before then are refused, not stored later.
Timeout, connection reset, unreadable responseTreat as temporary and retry with the same eventIds.

Never generate a new eventId for a retry. A new ID is a new event: it counts again and uses more of your allowance.

Back off between attempts, for example 1, 2, 4, then 8 seconds, plus a little randomness, and stop after a few minutes. Because eventIds expire after 24 hours, an event queued for longer than that can no longer be sent.

Response headers

HeaderMeaning
Request-IdUnique per request. The same value as error.requestId.
X-RateLimit-LimitRequests allowed per minute for this website.
X-RateLimit-RemainingRequests left in the current minute.
X-RateLimit-ResetWhen the current minute ends, in Unix seconds.
Retry-AfterOn 429 and 503: seconds to wait before retrying.
DateThe server's clock. Compare it with yours when you see stale_event.

A batch uses one request from the rate limit per event in it.

Clock problems

Only Graytower judges whether an event is too old or too far ahead, so don't drop events by your own clock. If new events get stale_event with issue: "in_future" or "too_old", compare details.serverTime with details.eventTime: a large gap means the clock of the machine that created the eventId is wrong. Enable time sync on that machine.