Skip to main content
curl -X POST https://api.chargeapi.co/v1/reservations/res_7vS2mQYpLc1aHe8uRk4nDzJfWt0xNbG3/confirm \
  -H "Authorization: Bearer ch_sk_test_..." \
  -H "Idempotency-Key: 5cf66d3e-8f65-4f18-a0ce-3a4972c2a1ee" \
  --json '{
    "payment_method": "pm_A8uQn2ZeMw5kLp1XrT7cHsJvBy4dFoN9"
  }'
Idempotency makes retrying a POST request safe when the first attempt is interrupted by a timeout, connection drop, or other network failure and you cannot tell whether the write already succeeded. To use it, generate an idempotency key in your backend before making the request, send it in the Idempotency-Key header, and reuse that exact same key if you retry the same operation. Charge treats the first request for a given key as the source of truth for that write attempt. If the original request created the resource successfully, a retry with the same key returns that same outcome instead of creating a second resource. An idempotency key is a client-generated identifier for one logical write attempt. In practice, that means one key per action you want to perform, not one key per HTTP attempt. Generate it server-side, use something with strong uniqueness such as UUIDv4, and log it alongside request IDs so retries are easy to trace. Idempotency keys are up to 255 characters long. Charge supports idempotency keys on POST endpoints. There is no reason to send them on GET or DELETE, because those methods are already expected to be safe to repeat without creating a second write.

Header reference

HeaderRequiredTypeDescription
Idempotency-KeyfalsestringUnique key used to make a POST request idempotent across safe retries.