KashuDocs

Errors

When Kashu cannot carry out a request, it answers with an HTTP status of 400 or more and one error object. Every error the API can return is in the table at the end of this page, and every error's doc_url links to its row.

{
  "error": {
    "type": "invalid_request_error",
    "code": "parameter_invalid",
    "message": "A parameter has an invalid value.",
    "param": "amount",
    "request_id": "req_...",
    "doc_url": "https://docs.kashupay.com/api/errors#parameter_invalid"
  }
}

Read the error

Every response carries the same id in its Request-Id header, errors included.

A declined card is not an error

When a card is declined, the payment is still made, with status failed, and the request answers 201. The payment's failure_code and decline_code say why. Payments explains what to do next.

Decide whether to retry

Stay under the rate limits

Writes are limited for each account and mode, a minute at a time:

RequestsA minute, per account and mode
Writes that move money (an Idempotency-Key is required)60
Other writes30

Every write answers with a RateLimit-Policy header that names its limit. A request over the limit answers 429 rate_limited, with Retry-After in seconds and a RateLimit header. Reads are limited too, and answer the same way.

Every error code

CodeStatusTypeMessage
api_key_missing401authentication_errorNo API key was provided. Send it as a Bearer token in the Authorization header.
api_key_invalid401authentication_errorThe API key provided is not valid.
api_key_expired401authentication_errorThe API key provided has been revoked or has expired.
livemode_unavailable403permission_errorLive mode is not available yet. Use a test key.
insufficient_scope403permission_errorThe API key does not have the access this request needs.
publishable_key_not_allowed403permission_errorA publishable key cannot make this request. Use a secret or restricted key.
route_not_found404invalid_request_errorThere is no endpoint at this path.
method_not_allowed405invalid_request_errorThis endpoint does not accept that HTTP method.
resource_missing404invalid_request_errorNo such object.
invalid_json400invalid_request_errorThe request body must be a JSON object.
parameter_missing400invalid_request_errorA required parameter is missing.
parameter_invalid400invalid_request_errorA parameter has an invalid value.
parameter_unknown400invalid_request_errorThe request has a parameter this endpoint does not accept.
cursor_invalid400invalid_request_errorThe cursor is not valid for this list. Pass back next_cursor unchanged, with the same filters and limit.
cursor_expired400invalid_request_errorThe cursor has expired. Start the list again.
api_version_invalid400invalid_request_errorThe Kashu-Version header names no known API version.
idempotency_key_missing400idempotency_errorThis endpoint moves money, so it needs an Idempotency-Key header.
idempotency_key_invalid400idempotency_errorThe Idempotency-Key header must be 1 to 255 printable ASCII characters.
idempotency_key_reused400idempotency_errorThis Idempotency-Key was already used with a different endpoint or different parameters.
idempotency_key_in_use409idempotency_errorA request with this Idempotency-Key is still running. Retry once it has finished.
payment_unexpected_state400invalid_request_errorThe payment's status does not allow this request.
amount_too_large400invalid_request_errorThe amount is more than the payment has left to capture or refund.
operation_in_progress409invalid_request_errorAnother request is changing this object. Retry once it has finished.
payments_not_enabled403permission_errorThis account cannot take payments yet.
subscription_unexpected_state400invalid_request_errorThe subscription's status does not allow this request.
feature_unavailable403permission_errorThis feature is not available for this account yet.
token_already_used400invalid_request_errorThis card token has already been used. Collect the card again for a new token.
token_expired400invalid_request_errorThis card token has expired. Collect the card again for a new token.
checkout_session_unexpected_state400invalid_request_errorThe checkout session's status does not allow this request: it is complete, expired, or its payment is still processing.
webhook_endpoint_limit400invalid_request_errorThis mode already has the most webhook endpoints it may have. Delete one first.
rate_limited429rate_limit_errorToo many requests. Retry after the time in the Retry-After header.
api_error500api_errorSomething went wrong on Kashu's side. Retry with the same Idempotency-Key.