1. Guides
Casharc
Merchant
  • Merchant
  • Getting Started
    • Introduction
    • Authentication
    • Quickstart
  • Guides
    • Idempotency
    • Statuses
    • Reason Codes
  • Payments
    • Create Payment
      POST
    • List Payments
      GET
    • Retrieve Payment
      GET
    • Claim Payment
      POST
    • Cancel Payment
      POST
    • Refund Payment
      POST
  • Payouts
    • Create Payout
      POST
    • List Payouts
      GET
    • Retrieve Payout
      GET
    • Cancel Payout
      POST
  • Appeals
    • Create Appeal
      POST
    • List Appeals
      GET
    • Retrieve Appeal
      GET
    • Cancel Appeal
      POST
  • Balance
    • Retrieve Balance
      GET
  • Webhook
    • On Status Change
  1. Guides

Idempotency

Idempotency lets you safely retry requests without risk of performing the same operation twice. This is useful when a request is interrupted by a network error or a timeout: you can retry it with confidence, knowing that the operation runs at most once.
Casharc supports idempotency for all POST requests — any request that creates a payment or changes its state. GET requests are naturally idempotent and never require a key.

Sending an idempotency key#

To make a request idempotent, provide a unique value in the Idempotency-Key header. The key may be any string up to 255 characters; we recommend a UUID.
Send a distinct key for each distinct operation. Reusing a single key across different operations on the same payment — for example, creating it and later refunding it — is not supported, because each operation carries a different request body.
The first request with a given key is executed and its response is stored. Any later request with the same key returns that stored response — including the same status code and body — instead of running the operation again.

How keys behave#

SituationResult
Same key, same request bodyReturns the stored response of the original request.
Same key, different request bodyReturns an error: the key has already been used with different parameters.
Same key while the first request is still in progressReturns an error: a request with this key is already being processed.
Key reused after it has expiredTreated as a new request.
Idempotency keys are stored for 24 hours. After a key expires, it can be used again for a new request.
Keys are scoped to your account, so they never collide with keys used by other accounts.

Which requests to send a key with#

We recommend sending an idempotency key with every POST request. It is strongly recommended for requests that move money — creating a payment or issuing a refund — where an accidental retry would otherwise result in a duplicate operation.
Lifecycle actions such as claiming or canceling a payment are already guarded by the payment's status, but sending a key still protects against duplicate submissions and is recommended.
Previous
Quickstart
Next
Statuses
Built with