Idempotency

With an idempotency key, a request is idempotent, so retrying it after a network failure doesn’t run the operation twice.

POST, PATCH and DELETE requests accept an idempotency-key header. When a key is reused, Bias returns the original response with an idempotency-replay: true header instead of running the operation again. Use a new key, such as a UUID, for each operation.

Errors are replayed too, so trying again after an error takes a new key. Rate limit and idempotency errors aren’t saved.

The SDKs send a new key with every POST and PATCH request and reuse it on retries. To retry safely across your own process restarts, set the key with the TypeScript SDK’s idempotencyKey option:

const payment = await bias.payments.create(
    {
        amount: 1000,
        customer: "cus_aB4DEXqbFGOlpEOxwp0Fx1",
        payment_method: "pm_VQ9SaYquIZTG2l0uRsmUr4",
    },
    { idempotencyKey: "0d234c20-bc41-4cae-bfeb-4e4bbd7d8ce4" },
);

Idempotency errors

A reused key must match the first request’s endpoint, method, query parameters and body. When a key can’t be used, Bias returns an idempotency error with HTTP status 409 and one of these codes:

CodeMeaning
idempotency_key_in_useThe first request is still running. Retry once it finishes.
idempotency_params_mismatchThe key was used for a different request. Use a new key.
idempotency_outcome_unknownThe first request’s outcome is unknown. Check whether it happened before using a new key.