Errors

The API uses standard HTTP status codes to indicate the success or failure of an API request. In general: Codes in the 2xx range indicate success. Codes in the 4xx range indicate an error with the parameters provided (like a missing parameter or a card decline). Codes in the 5xx range indicate an error in our infrastructure.

Invalid request (4xx) errors that can be handled programmatically include an enum code that allows you to respond to the error.

The Error object

Idempotency errors are returned when a request is made with an invalid idempotency key. Examples include using an idempotency key that was previously used on one resource on another or sending multiple requests at the same time with a single idempotency key.

Name
object
Type
"error",
Name
error
Type
object,
Child properties
Name
type
Type
"idempotency_error",
Name
live
Type
boolean or null,
Name
code
Type
null,
Name
message
Type
string,
Name
param
Type
null,

or

Handling errors

Errors of type server_error and rate_limit_error can be retried with reasonable backoffs. Errors of type payment_error can be retried by the user or automatically if the user is not present. Be mindful as additional authorization attempts will incur fees.

See Idempotency for best practices and information on making idempotent requests. These requests can safely be retried without additional consequences. They return the cached response for additional unretryable requests instead of creating a duplicate action.

Errors in the SDK

API responses in TypeScript SDK are typed as a union of the possible errors and the successful response:

const customer = await bias.customers.create();
customer satisfies
    | Customer
    | InvalidRequestError
    | IdempotencyError
    | RateLimitError
    | ServerError;

if (customer.object === "error") {
    throw new Error(customer.error.message);
}
PreviousNext

Created by Bias in California