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

An invalid request error indicates that the parameters, format, or nature of the request are invalid. Examples include missing required parameters or incorrect parameter types. Actions that conflict with the current state of a resource may also result in an invalid request error.

Name
object
Type
"error",
Name
error
Type
object,
Child properties
Name
type
Type
"invalid_request_error",
Name
live
Type
boolean or null,
Name
code
Type
enum or null,
Array item properties
Name
message
Type
string,
Name
param
Type
string or null,
Name
issues
Type
array or 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