Skip to main content
Network failures happen. If your server sends a POST /v1/checkout request and the connection drops before you receive a response, you don’t know whether PayBridgeNP created the session or not. Retrying blindly can create duplicate checkout sessions for the same order. PayBridgeNP supports idempotency keys on POST /v1/checkout to make retries safe.

How it works

Pass a unique Idempotency-Key header with your request:
If the request succeeds, PayBridgeNP stores the key and response. If you retry with the same key, PayBridgeNP returns the original response without creating a new session - even if the original request completed successfully.

Key rules

  • Use UUID v4 - random, unguessable, one per logical operation (not per HTTP request)
  • Keys are scoped to your project and live or sandbox mode
  • Responses are retained for at least 24 hours - never reuse a key for a different operation
  • A key belongs to one request - sending a key you already used with a different endpoint or method returns 409 with code idempotency_key_already_used, and nothing runs. The invoice endpoints refuse a different body the same way. On the other endpoints, the same key sent again to the same endpoint with a different body still returns the first response; treat that as a bug in your integration, because it will be refused too in a future change
  • Limit refusals are not stored - a request refused because of a plan limit (402), a feature your plan does not include, a rate limit (429), or a spend cap is evaluated again when you retry with the same key, so it can succeed once the limit clears. Other error responses, such as validation errors, are returned again as they were
  • Supported on these endpoints - POST /v1/checkout, POST /v1/mobile/session, POST /v1/refunds, POST /v1/webhooks, POST /v1/payment-links, POST /v1/qr/fonepay, POST /v1/qr/{id}/refresh, and these billing endpoints: POST /v1/billing/plans, /customers, /customers/{id}/credit, /subscriptions, /subscriptions/{id}/invoice-items, /invoices/{id}/qr, /coupons, /promotion-codes, and /dunning/policies. Other write endpoints ignore the header. GET requests are idempotent by design and ignore the key

Generating a UUID v4

Using with the SDK

On retry, pass the same key that was stored with the order:

Concurrent request conflict

If two requests with the same key arrive at exactly the same time, one of them will receive a 409 Conflict:
This is safe to retry after a short delay - it means a parallel request is already in flight.

Key reused for a different request

A key you already used with one endpoint or method cannot be used with another (on the invoice endpoints, nor with a different body). The second request is refused before anything runs, and the first request’s stored answer is not changed:
Do not retry this with the same key. Generate a new key for the new operation.

When to use idempotency keys