ARCNM

Building blocks

Idempotency

How to retry safely: the Idempotency-Key header, the 24-hour window, what makes two requests the same, and uploads, so a retry never bills a calculation twice.

Send an Idempotency-Key header on every mutating request and ARCNM dedupes safe retries — a dropped connection or client retry never bills the same calculation twice. It is the only protection: every calculation that succeeds is billed, and an identical request sent again without the key is a new calculation.

POST /api/v1/calculations/quote
Idempotency-Key: 9c5f0a40-5a8b-4d18-9f4e-c4e1f6d8b6e9

The first request with a given key succeeds normally. A later request with the same key and the same request within the window replays the original response — without re-running the work, without re-charging. That holds at any size, CAD uploads included.


How it works

  1. Client generates a UUIDv4 idempotency key per logical operation.
  2. The server fingerprints (method, path, caller, org, body) and looks it up in a short-lived cache.
  3. Cache hit, completed, same request: we replay the original status code, headers, and body, and add Idempotent-Replayed: true.
  4. Cache hit, in-flight: we return 409 (idempotency_in_flight) so you don't double-create while the original is still processing.
  5. Same key, different request: we return 409 (idempotency_conflict) — the server refuses to overwrite a different operation with the same key. Pick a new key.
  6. Cache miss: we execute, store the response, and write the cache entry with a 24h TTL.

Only the response is stored, never your request body. A 4xx stores nothing: the key is released so you can fix the request and resend it under the same key. A server error (5xx) may be pinned to the key, because whether the work happened is unknown: a retry then answers the same error with Idempotent-Replayed: true for 24 hours. Look the result up (GET /calculations) before you send it again under a new key.

What's in the fingerprint

  • method + path — the query string is not part of it; send a new key when you change a query parameter
  • caller — your whole API key, or your bearer token's user, grant and organization once its signature and expiry check out (a refreshed token is the same caller). A bearer token that is expired or invalid proves nothing and counts for nothing: sent beside your API key, the key is the caller, as it is for the request itself. A request without a credential that proves itself is not deduplicated: nothing is stored for it, and it is answered as if it carried no key
  • org — your X-Org-Slug / tenant context
  • the body, by its kind:
    • multipart/form-data (uploads) — the parts, not the bytes on the wire: each part's field name, filename, content type and the SHA-256 of its content, with the fields in any order. A field sent more than once keeps the order of its values: A, B and B, A are different requests. Your HTTP client draws a new boundary for every request; the boundary does not count, so a retry of the same upload is the same request. Another file, filename, content type or field value is a different request (409 idempotency_conflict). A body that is not well-formed multipart, has more than 2,000 parts or a part whose headers exceed 16 KiB counts by its exact bytes.
    • Everything else, JSON included — the exact bytes, whitespace and key order included. Retry with the bytes you sent the first time: a retry that serialises the same object again with another key order or spacing is a different request.

Uploads of any size

A CAD upload to /calculations/upload-and-quote, a dataset upload or a drawing gets the same contract as a small JSON request, whatever its size:

  • A retry after the first upload completed answers the stored response with Idempotent-Replayed: true — for upload-and-quote the same 202 with the same calculation id. Nothing is stored, created or billed again.
  • A retry while the first is still running gets 409 (idempotency_in_flight). Wait a moment and retry under the same key.
  • A retry sends the whole file again; only the first upload's work counts. To send a large file once and keep every retry small, use the presigned upload: the file goes straight to storage, and attaching and quoting it are small JSON requests, each retried under its own key.

Which verbs honour it

Idempotency-Key is honoured on POST, PUT, PATCH, and DELETE whenever the header is present. GET / HEAD ignore it (reads don't mutate). A mutation without a key still works — we just can't dedupe. Send one anyway.


Key format

  • Any string up to a few hundred bytes; UUIDv4 is conventional.
  • Must be globally unique per logical operation. If you generate one key per "shipment of CAD files to ARCNM", every retry of that shipment reuses the same key.
  • Treat it as opaque.

A naming convention that works well with upstream ids:

<system>-<verb>-<external_id>
e.g.  erp-quote-rfq-2026-05-9012

Concurrency

A second request with the same key arriving while the first is still in flight gets:

{
  "error": {
    "code": "idempotency_in_flight",
    "message": "Request with this Idempotency-Key is currently being processed."
  }
}

Wait briefly and retry. Once the first request completes, a retry of the same request — of any size — replays the original response (with Idempotent-Replayed: true).


Example

curl -X POST https://api.arcnm.io/api/v1/calculations/quote \
  -H "X-API-Key: $ARCNM_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: erp-quote-rfq-2026-05-9012" \
  -d '{ "part_revision_id":"…", "costing_environment_id":"…", "lot_size":50 }'

The same header works on a multi-environment grid (costing_environment_ids on /quote or /calculations/batch): a retry under the same key replays the original response, including the same batch_id. A retry without the header creates a new batch, and every cell of it is a new calculation, billed when it succeeds — the same part, environment and configuration run earlier does not answer it (see Pricing, rule 5). The Idempotency-Key is the only thing that turns a resent request into a replay, so send it on every retry.

On POST /calculations/quote and /calculations/upload-and-quote-json the key is declared in the API reference. The MCP tools quote_part and upload_and_quote take it as the argument idempotency_key: 1 to 128 letters, digits, ., _, : or -; a tool call with another value is refused before it is sent.


See also

  • Errors — idempotency_in_flight, idempotency_conflict.
  • Rate limits — pair idempotency with retries.
  • Webhooks — the event id is the dedup key for delivery-side consumers.