Guides›Idempotency
Idempotency
Retry any write safely with an Idempotency-Key.
Retries without doubles
Send an Idempotency-Key header (any unique string, up to 255 characters) on POSTs. It is required on swaps, withdrawals, transfers, payouts and buys.
- A retry with the same key and the same request within 24 hours gets the first answer back, with the header
Idempotent-Replayed: true. Nothing happens twice. - The same key with a different request is refused with 409 (
conflict). - So is the same key while the first request is still running.
Make a new key for each new operation, and reuse it only to retry that one.
curl -X POST https://sandbox-api.solacefi.co/platform/v1/withdrawals \ -H "Authorization: Bearer $SOLACE_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{"end_user":"eu_4kPq9Zm2xV7b","asset":"USDC","network":"ethereum","address":"0x3fA9e2C7b1d84E5a9c0F6e2B7d4A8c1E5f9b8c21","amount":"25"}'
const res = await fetch('https://sandbox-api.solacefi.co/platform/v1/withdrawals', { method: 'POST', headers: { Authorization: `Bearer ${process.env.SOLACE_KEY}`, 'Content-Type': 'application/json', 'Idempotency-Key': crypto.randomUUID(), }, body: JSON.stringify({ "end_user": "eu_4kPq9Zm2xV7b", "asset": "USDC", "network": "ethereum", "address": "0x3fA9e2C7b1d84E5a9c0F6e2B7d4A8c1E5f9b8c21", "amount": "25" }), }); const data = await res.json();