Skip to Content
Error Codes

Error Codes

All API errors follow a standard envelope format. The HTTP status code indicates the error category, and the response body provides details.

Error Response Structure

{ "error": { "type": "invalid_request_error", "code": "invalid_param", "message": "Amount must be a positive integer in cents.", "param": "amount", "request_id": "req_abc123" } }
FieldTypeDescription
typestringError category (see Error Types below).
codestringMachine-readable error code.
messagestringHuman-readable description.
paramstringThe request parameter that caused the error (if applicable).
connector_codestringRaw error code from the payment processor (for connector errors).
request_idstringUnique identifier for the request (use in support tickets).
debugstringAdditional debug information (only with X-Debug header and admin role).

Error Types

TypeHTTP StatusDescription
invalid_request_error400, 404, 409The request was malformed, missing required parameters, or references a resource that does not exist.
authentication_error401No valid API key was provided, or the key has been revoked.
authorization_error403The API key does not have permission for the requested operation.
rate_limit_error429Too many requests. Back off and retry after the indicated period.
validation_error400Request parameters failed validation rules.
connector_error502The downstream payment processor returned an error.
idempotency_error409, 422Conflict with idempotency key usage.
timeout_error504The payment processor did not respond within the allowed time.

Error Codes Reference

CodeTypeHTTPDescription
invalid_paraminvalid_request_error400A request parameter is missing or invalid.
invalid_requestinvalid_request_error400The request body or format is invalid.
missing_idempotency_keyinvalid_request_error400The Idempotency-Key header is required but was not provided.
payment_intent_not_foundinvalid_request_error404The specified PaymentIntent does not exist.
invalid_state_transitioninvalid_request_error409The PaymentIntent is not in the correct status for this operation.
refund_exceeds_amountinvalid_request_error400The refund amount exceeds the remaining refundable balance.
authentication_requiredauthentication_error401No API key was provided in the Authorization header.
invalid_api_keyauthentication_error401The API key is invalid or has been revoked.
authentication_failedauthentication_error401Authentication credentials are incorrect.
insufficient_permissionsauthorization_error403The API key does not have the required role or scope.
rate_limit_exceededrate_limit_error429Rate limit exceeded. Retry after the indicated number of seconds.
validation_failedvalidation_error400One or more request parameters failed validation.
connector_errorconnector_error502The payment processor returned an error. Check connector_code for details.
idempotency_conflictidempotency_error409Another request with this idempotency key is currently being processed.
idempotency_param_mismatchidempotency_error422This idempotency key was already used with different request parameters.
idempotency_erroridempotency_error409General idempotency conflict.
connector_timeouttimeout_error504The payment processor did not respond within the allowed time.
timeouttimeout_error504The request timed out.

Handling Errors

Check the type field first to determine the error category, then use code for specific handling:

try { await client.payments.authorize(params); } catch (err) { if (err instanceof GatelithixError) { switch (err.type) { case "authentication_error": // Check API key configuration break; case "invalid_request_error": if (err.code === "payment_intent_not_found") { // Payment not found -- check the ID } else if (err.code === "invalid_state_transition") { // Payment is in wrong status for this operation } else { // Fix the request parameter indicated by err.param } break; case "rate_limit_error": // Back off and retry break; case "connector_error": // Processor issue -- check err.connector_code break; case "timeout_error": // Retry with the same idempotency key break; } } }

HTTP Status Code Summary

StatusMeaning
200Success
201Created
400Bad request (invalid parameters)
401Unauthorized (missing or invalid API key)
403Forbidden (insufficient permissions)
404Not found
409Conflict (state transition or idempotency)
422Unprocessable (idempotency parameter mismatch)
429Rate limit exceeded
502Connector error (processor failure)
504Timeout (processor did not respond)