Skip to main content
xPay API supports idempotency for safely retrying requests without accidentally performing the same operation twice. When using an idempotency key, if a connection error occurs, you can safely repeat the request without risk of creating a second object or performing the update twice.

How It Works

To perform an idempotent request, provide an additional Idempotency-Key header to your request. xPay’s idempotency works by saving the resulting status code and body of the first request made for any given idempotency key, regardless of whether it succeeds or fails. Subsequent requests with the same key return the same result. A merchant generates an idempotency key, which is a unique key that the server uses to recognize subsequent retries of the same request.

Important considerations

  • Key scope: Idempotency keys cannot be shared across different idempotent APIs.
  • Key expiration: Idempotency keys expire after 24 hours in our system.
  • A unique key for making the request idempotent. Must match pattern: ^[a-zA-Z0-9\-_:\.]+$ and not exceed 255 characters.
  • Concurrent requests: If a duplicate request is sent while the original request is still being processed, the API will return a 400 Bad Request response indicating that the initial request is still in progress.
  • Unsupported endpoints: Only a few POST APIs support idempotency. Passing the Idempotency-Key header in unsupported APIs will result in a 400 Bad Request error.
  • Parameter matching: The idempotency layer compares incoming parameters to those of the original request and errors if they’re not the same to prevent accidental misuse.