Idempotency

The API supports idempotency, which enables you to safely retry requests without unintended side-effects. This is helpful when handling network failures and retries.

Idempotency in the Bias API works by saving responses to requests made with idempotency keys and returning them for subsequent requests with the same key. Requests are idempotent when:

  • They are made with the same idempotency key.
  • They contain identical request bodies, query parameters, and headers.
  • They are made after the first request has completed.

Requests made with the same idempotency key that do not have identical parameters or are made in parallel with the first request will be returned an idempotency error.

Making idempotent requests

Requests with methods GET, PUT, and DELETE are idempotent by default. You can include idempotency-key header on other requests to make them idempotent. We recommend using a UUID or other collision-resistant identifier for the this value.

When using the client libraries, an idempotency key is automatically added to each request, although it can be overridden by setting the idempotencyKey option:

TypeScript

const response = await bias.payments.create(
	paymentDetails,
	{ idempotencyKey: '0d234c20-bc41-4cae-bfeb-4e4bbd7d8ce4' }
);