Idempotency
Retry a POST safely: the same Idempotency-Key never does the work twice.
Networks fail. If your request to create a payment or a refund times out, you can't tell whether it was applied. Send an Idempotency-Key header on every POST (create payment, refund, payment link, webhook endpoint) and send the same key when you retry.
curl https://api.klinkpay.net/v1/refunds \
-H "Authorization: Bearer kp_test_…" \
-H "Idempotency-Key: refund-order-1001-1" \
-H "Content-Type: application/json" \
-d '{"payment": "pay_4Nq7xY2mKc8vTz1aB3dE9f", "amount": 5000}'
How it behaves
- The first request with a key is processed normally and its response is saved.
- A repeat with the same key and the same body returns the saved response without doing anything again.
- A repeat with the same key but a different body or endpoint fails with
409 idempotency_conflict.
Choosing keys
Use something unique per operation: a UUID, or a value from your own data like order-1001 for the payment of order 1001. Never reuse a key for a different operation.