Skip to main content
Network failures leave you in the worst spot on a write: you don’t know whether the request took effect. Retrying blindly risks creating a duplicate candidate or sending an interview invite twice. The v2 API solves this with the standard Idempotency-Key request header: send the same key on a retry and, when the operation’s successful response is JSON under 100KB, the API runs it at most once.

How it works

Attach an Idempotency-Key header to any POST request:
The first request with a given key executes normally and, when it succeeds with a JSON body under 100KB, its response is recorded. Any later POST carrying the same key within the retention window doesn’t re-execute — it gets the recorded status and JSON body back, with an extra header marking it as a replay:
  • Only POST requests are affected. The header is ignored on GET/PATCH/PUT/DELETE.
  • Without the header, nothing changes — POSTs behave as before (at-least-once under retries).
  • Idempotency runs after authentication and rate limiting: a replay never bypasses either check, and a rate-limited retry still counts against your request budget.

Key rules

Keys are unique across your whole organization, so never derive them from something that can repeat across operations (like a bare candidate email). Prefix them (send-interview-{candidateId}) or use UUIDs. If a key is reused on a different endpoint, the API rejects it with 422 unprocessable rather than replaying the wrong response.

Replay semantics

The concurrent-conflict body looks like:
Treat this 409 like a short-lived 429: back off for a second or two, then retry with the same key. Once the first request finishes you’ll get its replayed response.

What’s stored, and for how long

  • Retention is 24 hours. After that a key expires and the same key would execute a fresh request. Retry loops operate on the scale of seconds to minutes, so this is ample — don’t rely on keys for long-term dedupe.
  • Only JSON bodies up to 100KB are stored. A response that is larger or isn’t JSON is not stored at all: the key is released, and a retry with the same key re-executes the handler. In practice every v2 write response is JSON and well under the cap.
  • Only successful 2xx outcomes are cached. 4xx and 5xx outcomes discard the stored key so later attempts can be evaluated again.
  • Idempotency is best-effort by design: if the idempotency store itself is briefly unavailable, your request still executes (without replay protection) rather than failing.

Using the TypeScript SDK

Every write method on @classet/api-client accepts a trailing options object with idempotencyKey. Supplying it sends the header, and on a POST it also unlocks automatic retries — the SDK never retries a write it cannot prove is safe. Because server-side idempotency covers POST only, a key on PATCH/PUT/DELETE is still sent but does not enable retries:
If you manage retries yourself, generate the key once per logical operation — outside the retry loop — so every attempt carries the same key:

Repeats without a key

force_create skips the duplicate check, so a client that sets it on every create and re-posts after an error would make a new candidate, and start a new interview, on every retry. Two rules stop that whether or not you send an Idempotency-Key. Both look back 12 hours on the same job.
  • A repeated create returns the existing candidate. If the API created a candidate for the same person in the last 12 hours, POST /v2/candidates with force_create: true returns that candidate with 200 and data.replayed: true, in place of 201. No candidate is created.
    • “The same person” means the same phone, email and name. Two people who share a phone are two candidates.
    • data.interview_status is the candidate’s interview status: not_sent, in_progress or completed. data.call_id is the call the candidate already has.
    • If your request asks for outreach and that candidate was never contacted (the first create had no send flags, or its send failed), the outreach is started on the existing candidate and interview_status is in_progress. You are never told “replayed” for a send that did not happen.
    • POST /v2/calls works the same way for a phone number and name, with or without force_create.
  • One outreach per destination per job. A request that would text or call a phone number, or email an address, that was contacted in the last 12 hours through another candidate record returns 409 with code: "recently_contacted". Nothing is created or sent. Retry-After and data.retry_at say when a send is accepted again. To add the record without contacting them, create it without send flags.
After 12 hours force_create creates a new candidate again, as documented. A candidate created by an ATS sync or a careers-page application is never returned as a replay: force_create on top of one still creates. Two requests for the same person on the same job sent at the same moment are handled one at a time: the second gets 409 with code: "request_in_progress" and Retry-After: 2, and on retry it sees what the first one did. This is best-effort (if the lock store is unreachable the requests run unprotected), so an Idempotency-Key is still the guarantee. The Idempotency-Replayed header is set only for a key-based replay, not by these rules.

When to use it

  • Always on interview-sending POSTs (POST /v2/candidates with send flags, POST /v2/candidates/:id/interview) — a double-send reaches a real person and burns an invite slot.
  • On any POST issued from a job queue, webhook handler, or cron that might redeliver.
  • Whenever you retry a 5xx on a write — see Error handling.

Quick rules

  • One fresh key (UUID) per logical operation; same key on every retry of it.
  • Keys are org-unique and endpoint-bound — reuse on a different endpoint gets a 422.
  • 409 conflict whose error says already in progress = original still running; wait and resend the same key. Any other 409 is not a key conflict. Matching the text is a stopgap until the in-flight case gets its own code.
  • Replays carry Idempotency-Replayed: true; 5xx outcomes never replay.
  • Keys expire after 24 hours — they’re for retry windows, not permanent dedupe.