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

PropertySpecification
Header nameX-Idempotency-Key (case-insensitive; allowed on CORS preflight)
Format16–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)
MethodsApplies to POST, PUT, PATCH, and DELETE requests (GET/HEAD/OPTIONS ignore the header)
ScopeScoped to (route path, HTTP method, authenticated account, X-Idempotency-Key)
RetentionCached for 1 hour (3,600 seconds) by default when X-Idempotency-Key is provided

How Replay & Locking Work

  1. 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 Conflict with errorCode: "IDEMPOTENCY_IN_PROGRESS" and a Retry-After: 1 header. Wait and retry with the same X-Idempotency-Key.
  2. 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.
  3. Key reuse protection: If you reuse an X-Idempotency-Key with a different request payload, HoneyCoin rejects it with 422 Unprocessable Entity (errorCode: "IDEMPOTENCY_KEY_REUSED"). Always generate a fresh key for a new operation or after modifying a failed request.
  4. 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 for 2xx responses only (short default window, or 5 minutes on virtual account application create/update/submit endpoints). Always pass X-Idempotency-Key explicitly for new integrations so two intentional identical writes can use distinct keys and retries have the full 1-hour replay window.

Error Responses

400 VALIDATION_ERROR — Malformed Header

Returned 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

Returned 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

Returned 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-Key and payload on network timeouts, 5xx responses, or 409 IDEMPOTENCY_IN_PROGRESS responses.
  • Generate a new X-Idempotency-Key after modifying a request payload to fix a 4xx validation error.
  • On payment endpoints that also accept externalReference, continue sending a unique externalReference alongside X-Idempotency-Key.