Skip to main content
A write that times out leaves you unsure whether it happened. Sending it again could pay twice, send a message twice or submit a questionnaire twice. An Idempotency-Key header removes that doubt for the endpoints listed below: send the same key on every attempt, and Hi Doctor runs the operation at most once. Last reviewed: 2026-11-04

Which endpoints accept an Idempotency-Key?

The header is optional. Without it these endpoints behave exactly as before. The published specification declares the header on these operations only; do not rely on deduplication anywhere else. Guided questionnaire answers use expected_revision instead.

How do you use an Idempotency-Key?

1

Create one key per operation

Generate the key when the user asks for the action, for example a UUID, and store it with the pending operation. Keys are 8 to 128 ASCII letters, digits, underscores or hyphens. A malformed key returns 400 with code: "invalid_idempotency_key".
2

Send it with every attempt

Put the same value in the Idempotency-Key header of the first request and of every retry. Keep the method, path, query and body identical.
3

Read the outcome

The first completed attempt returns the normal response. A repeat returns the same HTTP status with Idempotent-Replayed: true and a short body, described below.
Add a short, growing pause between attempts. See errors and recovery for back-off guidance.

What does a replay return?

A replay does not resend the original body. It returns the original HTTP status with:
resource_ids lists the records the original request created or changed. Read them through their normal endpoints to recover the full content, for example a message or a checkout session. response_hash lets you check a stored copy of the original response. A replayed DELETE returns 204 with no body; use the lookup endpoint to see its result. If the first attempt failed with a 4xx or 5xx, that failure is stored too: retrying the same key returns the same status and no change is made. Fix the request and send it with a new key.

Which errors can a key return?

Never generate a new key to get around a 409. That turns one operation into two.

Reconcile an uncertain write

When you cannot tell whether a keyed write completed, look the key up:
The lookup is read-only. It never calls a payment provider and never changes anything. state is in_progress, succeeded or failed; a failed request rolled back its changes. A 404 means the key is unknown, belongs to another account or brand, is older than 30 days, or its request is still running. A request that has not finished is not visible yet, so a 404 straight after a timeout does not prove the write did not happen. Wait, look again, and if you are still unsure, retry the original request with the same key. The lookup endpoint is listed with the other Account endpoints.

What does a key not cover?

  • Effects outside Hi Doctor. succeeded means Hi Doctor stored the operation and accepted any follow-up work. It does not prove that an email arrived, that a payment provider settled a charge or refund, or that a doctor signed a prescription. Check the relevant resource before you tell a patient that something is done.
  • Upload storage. A failed upload can leave an unreferenced file in storage. It is never attached to the patient’s records.
  • Two operations under one key. Starting a conversation and sending its first message are two operations; give each its own key.
  • Clinical decisions. A key makes a retry safe. It does not change who decides: every consultation is reviewed in full by an EU-licensed doctor, who decides on medical grounds only. See Safety.

How long are keys kept?

Keys are kept for 30 days per account and brand. After that the lookup returns 404 and a retry with the old key returns 409 idempotency_key_expired, so an expired key is never silently run again.

Frequently asked questions

Do I have to send an Idempotency-Key?

No. The header is optional, and requests without it behave as before. Send it on any write you might retry, such as checkout, a message or a questionnaire submission.

What should I use as the key?

Generate a random value, such as a UUID, when the user asks for the action, and store it with the pending operation. Keys are 8 to 128 letters, digits, underscores or hyphens.

Can I reuse a key for a different request?

No. A key used for a different request returns 422 with the key reuse code. Use a new key only for a genuinely new operation.

What does a 409 in-progress response mean?

The first attempt is still running. Wait, then retry with the same key; never create a new key to get around it.

Does a successful key prove the payment or email went through?

No. It proves Hi Doctor stored the operation. Check the payment, message or consultation itself before telling the patient that something is done.

How long is a key remembered?

Keys are kept for 30 days per account and brand. After that the lookup returns a not-found error and a retry with the old key is refused as expired.

Next steps