Errors
Every failure is aDarwinError. HTTP errors carry the API’s problem document:
Classes by status:
InvalidRequestError (400), AuthenticationError (401), PaymentRequiredError (402), PermissionDeniedError (403), NotFoundError (404), ConflictError (409), UnprocessableError (422), RateLimitError (429, with retryAfter in seconds), InternalServerError (5xx), ConnectionError and its subclass TimeoutError (no response). Error messages never contain your API key.
Retries
The client retries, up tomaxRetries times (default 2):
- 429: after the
Retry-Afterdelay. If the API asks for more than a minute, the client gives up at once with aRateLimitErrorso you can schedule the work. - 5xx and network errors: with exponential backoff and jitter (about 0.5 s, 1 s, 2 s…).
- 409
idempotency_key_in_use: an earlier attempt is still running; the retry gets its answer.
Idempotency
EveryPOST, PATCH and DELETE carries an Idempotency-Key. The client makes up a random UUID when you do not pass one and reuses it on every retry, so a retried write is applied once. The API keeps a key’s response for 24 hours; a replayed response has the Idempotent-Replayed: true header.
Pass your own key when a write may be repeated across processes or restarts, such as a queue job:
422 idempotency_key_reused. More in Idempotency.
Cancel a call
Cancel a call, and its retry waits, with anAbortSignal: