Skip to content
Support
← Back to IdempotencyUse Print, then choose Save as PDF to keep a copy.

Skeduler Support · For developers

Idempotency

Retry safely without doubling up.

3 pages

Safe retries with idempotency keys

Send an Idempotency-Key header on writes, so retrying after a dropped connection never creates a second contact, job or payment.

Owner, Admin · Last checked 24 November 2026 · 2 min read

A network can drop the answer to a write that actually worked. If you retry it, you could create a second contact or job. Send an Idempotency-Key header, and a retry with the same key does nothing twice.

It works on POST /contacts, PATCH /contacts/{id}, POST /jobs, PATCH /jobs/{id}, PATCH /jobs/{id}/status, POST /visits, PATCH /visits/{id}, POST /visits/{id}/cancel, POST /estimates, POST /invoices, POST /invoices/{id}/payments, POST /webhooks/subscriptions and DELETE /webhooks/subscriptions/{id}.

On POST /invoices/{id}/payments the header is required, because money is recorded there.

curl -s -X POST "$SKEDULER_API/api/v1/contacts" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Idempotency-Key: 6f1c0b5e-2c1a-4f3e-9a52-0d3c9f1d7a10" \
  -H "Content-Type: application/json" \
  -d '{"first_name":"Sam","last_name":"Rivera","email":"sam@example.com"}'

How idempotency keys work

  • The key is yours: 1 to 255 printable ASCII characters. A UUID is a good choice.
  • Use a new key for each write, and the same key when you retry that write.
  • Keys belong to your app, so two apps never collide.
  • A repeat with the same key and the same request (method, URL and body) returns the stored answer, with Idempotent-Replayed: true. Nothing is created again.
  • Answers are kept for 24 hours.

Which answers are kept for a retry

Successful answers (2xx), and 422s for a malformed request (a field that fails validation), are kept and replayed.

A 422 that the record's state caused, such as a payment on a draft invoice or above the amount due, isn't kept, and nor is a 422 from a check that reads your data or today's date, such as an id that doesn't exist yet: fix the cause, then send the same request with the same key and it runs for real.

Anything else that can change (a 500, a 429, an auth failure, a 404) isn't kept either, so a retry with the same key really tries again.

If a payment was refused (say the invoice was still a draft), fix the cause and send the payment with a new key.

Idempotency key errors

Statuserror.codeMeaning
422invalid_idempotency_keyThe key isn't 1 to 255 printable ASCII characters, or it's missing on a payment.
422idempotency_key_reusedThe key was already used for a different request. Use a new key.
409idempotency_in_progressThe first request with this key hasn't finished. Wait a moment and retry.
409idempotency_replay_unavailableThe first answer for this key can no longer be replayed. Retry with a new Idempotency-Key.

My request fails with idempotency_key_reused

A 422 idempotency_key_reused means you sent an Idempotency-Key that was already used for a different request. Use a new key for each new write.

Owner, Admin · Last checked 24 November 2026 · 2 min read

What you see

A write answers 422 with:

{ "error": { "code": "idempotency_key_reused", "message": "This Idempotency-Key was already used for a different request." } }

Why it happens

  1. Your code reuses one key for different writes, for example a fixed key, or one made from something that repeats, like the customer's id.
  2. The retry isn't the same request. Skeduler compares the method, the URL (with its query string) and the body. The order of keys in a JSON object doesn't matter, but any changed value, or a changed order in a list, makes it a different request.
  3. The first try was refused with a 422 for a malformed body (for example validation_failed), and you fixed the body but kept the key. That 422 is stored against the key like a success. A 422 the record's state caused, such as a payment on a draft invoice, isn't stored, so the same request can be sent again once you've fixed the cause.

How to fix it

  1. Make a new key for each new write, such as a random UUID, and store it with the write so a retry can send it again.
  2. When you retry, send exactly the same method, URL and body with the same key. Build the body once and reuse it, rather than building it again.
  3. After fixing a refused request, send it with a new key.

Keys belong to your app and are kept for 24 hours. After that, Skeduler forgets the key.

Other idempotency errors

Statuserror.codeWhyFix
422invalid_idempotency_keyThe key isn't 1 to 255 printable ASCII characters, or it's missing on POST /invoices/{id}/payments, which needs one.Send a valid Idempotency-Key header.
409idempotency_in_progressThe first request with this key hasn't finished. A request that died part-way stops blocking the key after 10 minutes.Wait a moment and retry the same call.
409idempotency_replay_unavailableThe stored answer for this key can't be returned.Retry with a new key.

See Safe retries with idempotency keys.

What if I reuse an idempotency key with a different body?

You get 422 idempotency_key_reused. Use a new key for each different write.

Owner, Admin · Last checked 24 November 2026 · 1 min read

You get 422 with error.code of idempotency_key_reused: the key was already used for a different request (another method, URL or body).

The same key with the same request returns the stored answer with Idempotent-Replayed: true, so nothing is done twice. Keys belong to your app, and answers are kept for 24 hours. Use a new key for each distinct write, and the same key only when you retry that write. After a 422, fix the request and send it with a new key.

See My request fails with idempotency_key_reused and Safe retries with idempotency keys.