Skip to Content
Payrudder

Errors

Read any API error the same way, decide whether to retry, and look up every error key and usage event code.

Every error of the tenant API has the same shape, whatever went wrong:

{
  "error": {
    "code": "INVALID_ARGUMENT",
    "key": "gateway.request.invalid",
    "message": "…",
    "details": [{ "field": "events", "description": "…" }],
    "request_id": "…"
  }
}
keystringrequired

Stable and always there: dotted, the service first (billing.credit_note.not_paid). An error with no key of its own gets common.<reason>. Translate the key, not the message: the message is English text for a log, and its wording can change; keys do not.

codestringrequired

The class of the error. It decides the HTTP status.

detailsarray

Points at the fields that were wrong. Left out when there is nothing to point at.

request_idstring

The X-Request-Id of the call. Quote it when you ask for help.

Status and what to do

CodeHTTPMeaningRetry?
INVALID_ARGUMENT400the request is malformed or a field is not validno: fix the request
UNAUTHENTICATED401the key is missing, wrong or endedno: see Authentication
PERMISSION_DENIED403the key may not do this, or the environment is not open for itno
NOT_FOUND404there is no such objectno
ALREADY_EXISTS, ABORTED, FAILED_PRECONDITION409the object exists, or its state does not allow this nowno: read the state, then decide
REQUEST_TOO_LARGE413the body is over 1 MiB (usage events: also over 500 events)no: send less per request
RESOURCE_EXHAUSTED429you are over a rate limit or a quotayes, after the seconds in Retry-After
UNAVAILABLE503a dependency is not readyyes, with the same idempotency key
DEADLINE_EXCEEDED504the call took too longyes, with the same idempotency key

An INTERNAL error never carries its cause in the message, and neither does an UNAVAILABLE, DEADLINE_EXCEEDED, RESOURCE_EXHAUSTED or ABORTED error that comes from the network or a database rather than from Payrudder's own rules. Its message is a plain sentence that quotes the request_id, and the key (common.unavailable, common.timeout, common.rate_limited, common.conflict) is what to branch on. An error Payrudder wrote itself for these codes (a quota, an invitation limit) keeps its own message.

A request that timed out may or may not have been done: retry it only with an idempotency key, or read the state first. The SDKs retry 429 and 5xx for you with the same key.

Rejected usage events

A usage event is judged on its own inside a 202 answer: an event that cannot be counted is rejected with an error_code (the list is below) and does not fail the others. See Usage metering.

You do not have to catch a rejection in the answer to see it later. Every rejected event is kept for 14 days (at most 10 000 per environment, the oldest dropped first) and can be read back:

  • in the console, in the Rejected events section of the Connect page, with the hint for each code;
  • with GET /v1/rejected-events (filter by error_code and meter, page with page_token) and GET /v1/rejected-events/summary (the last 24 hours by code and by hour), for a key with the usage:read permission.

A row holds the code and the message, the meter code and the customer id as you sent them, the event time and the idempotency key. The properties and the quantity are never stored.

A row is written just after the answer, best effort, so it can be a moment late and, under a burst of rejections or a database problem, a rejection can be missing from the list: the answer you got is the record. The sandbox's log is emptied by a sandbox reset.

In the SDKs and the command line

The SDKs turn the status into one typed error and keep the fields of the envelope on it (status, code, key, message, details, request id, Retry-After). Branch on the type or on the key, never on the message.

StatusGo (Error.Kind)TypeScriptPythonPHP (Payrudder\Exception\…)
401KindAuthenticationAuthenticationErrorAuthenticationErrorAuthenticationException
403KindPermissionPermissionErrorPermissionDeniedErrorPermissionException
404KindNotFoundNotFoundErrorNotFoundErrorNotFoundException
400, 422KindValidationValidationErrorValidationErrorValidationException
409KindConflictConflictErrorConflictErrorConflictException
429KindRateLimitRateLimitErrorRateLimitErrorRateLimitException
5xxKindServerServerErrorServerErrorServerException
no answer (DNS, refused, reset, timeout)KindConnectionConnectionError, TimeoutErrorAPIConnectionError, APITimeoutErrorConnectionException, TimeoutException
any otherKindAPIPayrudderErrorAPIErrorApiException

A rejected usage event is not an error of the call: it is a result with status: "rejected" and an error_code, in all four SDKs.

The command line prints an API error as payrudder: 404 customer.not_found: … (request <id>) and exits 1. A rejected event prints its error_code and exits 1. A command line it cannot understand exits 2 without sending anything. When you ask for help, quote the request id.

The catalogue

The list below is generated from the code (docs/error-keys.md, written by the test of pkg/errkey when UPDATE_ERROR_KEYS=1 is set, and checked by it otherwise) and so is always complete. It leaves out the keys of the operator's and the console's own routes (admin, identity, support), which an integration of the tenant API never receives.

Usage event error codes

An event the API refuses comes back rejected with one of these codes and does not fail the rest of the batch. The console shows the same advice under the test event and next to each entry of the Rejected events list on the Connect page (the list is also GET /v1/rejected-events).

error_codeMeaningWhat to do
UNKNOWN_METERNo meter has this code. Create the meter first.No meter has this code. Create the meter on the Meters page, or fix meter_code.
UNKNOWN_CUSTOMERNo customer has this external id. Create the customer first.No customer has this id. Create the customer first, or fix customer_external_id.
EVENT_TOO_OLDThe event_time is more than 35 days in the past.The event is more than 35 days old. Send usage soon after it happens; older usage cannot be counted.
EVENT_IN_FUTUREThe event_time is more than 5 minutes ahead of the server's clock.event_time is more than 5 minutes ahead of Payrudder's clock. Check your server's clock and send the moment the usage happened.
INVALID_EVENT_TIMEThe event_time is missing or is not an RFC 3339 instant.Send event_time as an RFC 3339 instant, for example 2026-11-03T10:15:00Z.
INVALID_QUANTITYThe quantity is not a non-negative decimal.Send quantity as a non-negative decimal, as text such as "1" or "1.25".
INVALID_QUANTITY_PRECISIONThe quantity has more decimal places than the meter's quantity_scale.The quantity has more decimal places than the meter allows. Round it to the meter's quantity_scale.
IDEMPOTENCY_KEY_REQUIREDA live key sent the event without an idempotency_key.A live key must send an idempotency_key with every event. Derive it from what happened (an order id) so a retry counts once.
IDEMPOTENCY_KEY_INVALIDThe idempotency_key is not 1 to 128 characters of letters, digits and _ . : -.Use 1 to 128 characters: letters, digits and _ . : -.
IDEMPOTENCY_KEY_REUSEDThe idempotency_key was used before for a different event.This key was used for a different event. Use a new key for a new event; retry the same event with the same key and the same content.
INVALID_PROPERTIESThe properties are too many or too large, or a UNIQUE meter's property is missing.Send at most 32 properties and 4 KiB in total, with text values, and include the property a UNIQUE meter counts.
INVALID_CORRECTIONA correction needs a reason of 1 to 500 characters, and the key of the event it corrects (not its own).A correction needs a reason of 1 to 500 characters and the key of the event it corrects (not its own key).
CORRECTION_UNKNOWN_EVENTNo event with the key in corrects is known: it was never accepted, or it is older than idempotency keys are kept (at least 45 days).No event with that key was found. It may never have been accepted, or it is older than idempotency keys are kept (at least 45 days).
CORRECTION_MISMATCHThe customer or the meter is not that of the event being corrected.A correction must name the same customer and the same meter as the event it corrects.
CORRECTION_UNSUPPORTED_METEROnly events of SUM and COUNT meters without a property filter can be corrected.Only events of SUM and COUNT meters without a property filter can be corrected.
CORRECTION_OF_CORRECTIONThe event is itself a correction: correct the original again, with the quantity it should have.The event is itself a correction. Correct the original event again, with the quantity it should have.

All error keys

520 keys in 15 areas. The meaning is the English message the console shows for the key; the API's own message may be worded differently.