DocsPlatform & Reliability

Idempotency & Retries

Safely retry network operations without duplicate message dispatches using the Idempotency-Key header.

4 min readAPI v1

How Idempotency Works in PingStack

Network partitions and client timeouts can cause requests to drop before a response is received. By passing an `Idempotency-Key` header: 1. PingStack computes a SHA-256 hash of the request body and checks for existing processed transactions for your workspace. 2. If found within **24 hours**, PingStack immediately returns the cached response with header `X-Idempotent-Replay: true` without creating duplicate messages or incurring double charges. 3. If an identical key is used with a *different* request payload, PingStack rejects the request with `HTTP 409 Conflict`.

Usage Example Across Languages

curl -X POST https://app.pingstack.in/api/v1/messages \
  -H "Authorization: Bearer ps_secret_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-tx-9941-confirmed" \
  -d '{"to": "919876543210", "template": "order_confirmed", "variables": ["Rahul", "ORD-9941"]}'