Skip to main content

Idempotency

Idempotency ensures that multiple identical requests produce the same result as a single request. By attaching unique idempotency keys to API calls, you prevent duplicate resource creation when requests are retried due to network failures or timeouts. Retried requests with the same key return the original result instead of creating new resources.

Implementation

Provide a unique key in the header. Keys expire after 24 hours.

Idempotency-Key: 550e8400-e29b-41d4-a716-446655440000

Conflict Response (409)

{
"code": 409,
"statusText": "Conflict",
"message": "Request already processed with this idempotency key"
}

Client Examples

const crypto = require('crypto');

function generateIdempotencyKey(data) {
const hash = crypto.createHash('md5').update(JSON.stringify(data)).digest('hex');
return `req_${hash}`;
}