Skip to main content
Networks fail. A request can time out after we’ve done the work but before you got the answer. An Idempotency-Key makes the retry safe: we recognize the key, and instead of running the request again we return the original response.

Send a key on every write

Every POST accepts an Idempotency-Key header. Two require it, because a duplicate would reach the insured: POST /v1/applications/{id}/send and POST /v1/applications/{id}/void. Without one they answer 400 IDEMPOTENCY_KEY_REQUIRED. On every other write it’s optional, and we recommend it on every call. GET requests are naturally safe to repeat and ignore it.
  • One key per operation. Generate a new key (a UUID v4 is ideal) when you decide to do something, and reuse that same key for every retry of it.
  • Format: 1 to 255 printable ASCII characters. Anything else is 400 IDEMPOTENCY_KEY_INVALID.
  • Scope: keys belong to the API key that sent them, so two integrations can’t collide.
  • Lifetime: 24 hours. After that the key is forgotten and can be used again.

What a retry gets back

“Same request” means the same method, path, query string and body bytes, sent by the same API key acting as the same broker, at the same API version (your Bridgeline-Version header, or your key’s version when you send none). Serialize the body once and resend those exact bytes; re-serializing can reorder keys or change spacing, and that counts as a different request. A request we reject in authentication or request validation (a 401 or 403 about the key, a malformed body, a 422 on the shape of the request, a 429) doesn’t use up its key. Fix the problem and send it again with the same key. An error raised while handling the request is different: it is stored under the key, like any other answer. On accept that covers a 422 for an option_id the quote doesn’t have, 409 QUOTE_EXPIRED, 409 QUOTE_NOT_ACCEPTABLE and 404. The same key replays that answer, and a corrected request has a different body, so send it with a new key.

Accepting a quote

POST /v1/quotes/{id}/accept can only happen once per quote, with or without a key. The key decides what a repeat gets back:
  • The same key and body: whatever the first call stored. Normally that is the 201 and the application. If the first call ended in a 500, a retry with the same key either replays that 500 or runs the call again. Either way, read the quote if you still have no 201: status: accepted with an application_id means the application exists, and that id names it.
  • A different key, or no key: 409 QUOTE_ALREADY_ACCEPTED, with the application’s id in error.application_id. That application may come from a different call than yours.
So send a key, and keep it until you have the answer. The accept reference has the full table of answers.

Accept, with recovery

A client that follows that table: one key per attempt, reused on every retry of it, and a read of the quote when the key can’t succeed.
Accept, with recovery

When the response was lost

Very rarely, a request finishes its work but we fail to record the response. The key is then stuck: we can’t replay an answer we don’t have, and we won’t run the request again in case it already took effect. A retry with that key, once the original has been gone for two minutes, gets 500 IDEMPOTENCY_RECORD_LOST. It has no Retry-After, because retrying the same key won’t help. What to do depends on the endpoint:
  • POST /v1/quotes: the quote may or may not exist, and there’s no way to look it up yet. Create it again with a new key. An extra quote is harmless: nothing is sent to anyone, and it expires on its own. It does count toward your daily quote limit.
  • POST /v1/quotes/{id}/hosted-link: the link may or may not have been replaced. Call it again with a new key; that revokes whichever link is current and gives you a fresh one.
  • POST /v1/applications/{id}/send and POST /v1/applications/{id}/void: read the application. Its agreement says whether an agreement is out; see the retries table on send or void.
  • POST /v1/quotes/{id}/accept: read the quote with GET /v1/quotes/{id}. If its status is accepted and it has an application_id, the application exists and that id names it. (accepted with application_id: null means the application was later deleted; create a new quote.) If the quote isn’t accepted, accept again with a new key. Either way you can’t end up with two applications.

Retry rules

A sketch of a retrying client:

Without a key

A write sent without a key is never deduplicated (send and void refuse to run without one). Retrying a timed-out POST /v1/quotes without one can create a second quote, and retrying POST /v1/quotes/{id}/hosted-link replaces the link again, so the first new link you might have stored stops working. Retrying POST /v1/quotes/{id}/accept without one is safe but less convenient: the second call is a 409 QUOTE_ALREADY_ACCEPTED instead of the application.