Skip to navigation

Idempotency

Safe retries for POST requests via the Idempotency-Key header

View as Markdown

Every POST request to the Admoji API must include an Idempotency-Key header. Duplicate requests carrying the same key within 24 hours return the original result without re-executing the operation — protecting you from double-charges and duplicate records when a client retries after a transient error.

Header format

Idempotency-Key: 3a2ebd06-e52f-47d2-92c4-66a107022f8e

Any unique string up to 48 characters is accepted. A UUID v4 is recommended.

GET, PUT, and DELETE requests are idempotent by definition — the Idempotency-Key header is ignored on those methods.

Why it matters

An API call is idempotent when applying it multiple times produces the same result as applying it once. Without an idempotency key, a client that retries a failed POST /signup-transaction may charge the card twice. With the same key on both attempts, the server recognizes the second request as a retry and returns the cached response of the original.

Generating keys

Use your language’s standard UUID generator. A short list:

LanguageFunction
RubySecureRandom.uuid
PHPRamsey\Uuid\Uuid::uuid4()
JavaUUID.randomUUID()
Pythonuuid.uuid4()
C#Guid.NewGuid()
Node.jscrypto.randomUUID()

Key lifecycle

  • Keys expire 24 hours after first use.
  • Reusing a key outside the 24-hour window creates a new operation.
  • Reusing a key inside the window with a different request payload returns an error — the idempotency layer verifies the payload matches the original request.

Example

Signup transaction with idempotency
curl -X POST 'https://openapi.responsecrm.com/api/v2/open/signup-transaction' \
-H "Authorization: ApiKey secret_492796e421a34666a5695d53cd311111" \
-H "Idempotency-Key: 3a2ebd06-e52f-47d2-92c4-66a107022f8e" \
-H "Content-Type: application/json" \
-d '{ "customerID": 12345, "productID": 678 }'

Retry that exact request with the same header within 24 hours and you get the cached response of the first successful call — no double-charge, no duplicate order.