Idempotency
Safely retry mutating B2B API requests with the X-Idempotency-Key header.
Network timeouts and dropped responses can leave your integration unsure whether a POST, PUT, PATCH, or DELETE request succeeded. Send an X-Idempotency-Key header on mutating B2B requests so retries replay the original response instead of creating duplicate records or returning 409 Conflict.
Header Requirements
| Property | Specification |
|---|---|
| Header name | X-Idempotency-Key (case-insensitive; allowed on CORS preflight) |
| Format | 16–255 characters matching ^[A-Za-z0-9_-]{16,255}$ (for example, a UUID v4 or prefixed UUID such as va-create-550e8400-e29b-41d4-a716-446655440000) |
| Methods | Applies to POST, PUT, PATCH, and DELETE requests (GET/HEAD/OPTIONS ignore the header) |
| Scope | Scoped to (route path, HTTP method, authenticated account, X-Idempotency-Key) |
| Retention | Cached for 1 hour (3,600 seconds) by default when X-Idempotency-Key is provided |
How Replay & Locking Work
- In-flight lock: HoneyCoin acquires an exclusive lock for the scoped key before executing the handler. If a concurrent retry arrives while the first request is still running, HoneyCoin immediately returns
409 ConflictwitherrorCode: "IDEMPOTENCY_IN_PROGRESS"and aRetry-After: 1header. Wait and retry with the sameX-Idempotency-Key. - Canonical payload fingerprinting: HoneyCoin computes a key-order-independent fingerprint over the request's body, query parameters, and path parameters. Reordering JSON keys (e.g.
{"a":1,"b":2}vs{"b":2,"a":1}) is treated as the same request. - Key reuse protection: If you reuse an
X-Idempotency-Keywith a different request payload, HoneyCoin rejects it with422 Unprocessable Entity(errorCode: "IDEMPOTENCY_KEY_REUSED"). Always generate a fresh key for a new operation or after modifying a failed request. - Status caching rules:
- With
X-Idempotency-Key: Successful (2xx) and deterministic client error (4xx) responses are cached and replayed for the retention window. Server errors (5xx) are not cached so you can retry with the same key once the upstream recovers. - Without
X-Idempotency-Key(legacy fallback): Endpoints that do not yet require the header fall back to payload-based deduplication for2xxresponses only (short default window, or 5 minutes on virtual account application create/update/submit endpoints). Always passX-Idempotency-Keyexplicitly for new integrations so two intentional identical writes can use distinct keys and retries have the full 1-hour replay window.
- With
Error Responses
400 VALIDATION_ERROR — Malformed Header
400 VALIDATION_ERROR — Malformed HeaderReturned when X-Idempotency-Key is shorter than 16 characters, longer than 255 characters, contains disallowed characters (such as spaces or commas from duplicate headers), or is empty.
{
"success": false,
"message": "x-idempotency-key must be 16-255 characters: letters, digits, \"-\" or \"_\".",
"errorCode": "VALIDATION_ERROR"
}409 IDEMPOTENCY_IN_PROGRESS — Request Already Running
409 IDEMPOTENCY_IN_PROGRESS — Request Already RunningReturned with Retry-After: 1 when an earlier request with the same key is still executing. Retry with the same key after a short backoff.
{
"success": false,
"message": "A request with this idempotency key is already in progress. Retry shortly.",
"errorCode": "IDEMPOTENCY_IN_PROGRESS"
}422 IDEMPOTENCY_KEY_REUSED — Payload Mismatch
422 IDEMPOTENCY_KEY_REUSED — Payload MismatchReturned when the same X-Idempotency-Key is sent with a different body, query, or path parameters than the original request. Generate a new key if you intend to make a different request.
{
"success": false,
"message": "This idempotency key was already used for a different request.",
"errorCode": "IDEMPOTENCY_KEY_REUSED"
}Example Request
curl --request POST \
--url https://api-v2.honeycoin.app/api/b2b/virtual-accounts/applications/app_01JXYZ123456/submit \
--header 'Authorization: Bearer YOUR_BEARER_TOKEN' \
--header 'X-Idempotency-Key: va-submit-550e8400-e29b-41d4-a716-446655440000'Best Practices
- Generate one UUID v4 per logical operation (for example, per application creation, draft update, submission, or customer creation) and persist it before sending the HTTP request.
- Reuse the exact same
X-Idempotency-Keyand payload on network timeouts,5xxresponses, or409 IDEMPOTENCY_IN_PROGRESSresponses. - Generate a new
X-Idempotency-Keyafter modifying a request payload to fix a4xxvalidation error. - On payment endpoints that also accept
externalReference, continue sending a uniqueexternalReferencealongsideX-Idempotency-Key.
Updated about 18 hours ago
