Idempotency
Networks fail. A request can time out after GioSMS has accepted your send. Without care, retrying it would send the Messages twice and charge you twice. An idempotency key stops that.
Send an Idempotency-Key
POST /v1/messages needs an Idempotency-Key header of 1 to 100 characters. Without one, GioSMS refuses the request with 400 idempotency_key_required.
Use a key that names the send in your own system, such as order-1001-shipped, so a retry of the same send uses the same key. Use a new key for each new send.
What a repeat gets
GioSMS remembers each key for 24 hours.
| You repeat a request with the same key | GioSMS answers |
|---|---|
| and the same body | the first response again, with the header Idempotent-Replayed: true. Nothing is sent or charged again. |
| and a different body | 422 idempotency_key_reused. Nothing is sent. |
| while the first is still being handled | 409 idempotency_key_in_progress. Wait a moment and retry. |
The body must match byte for byte, so send the retry exactly as you sent the first request.
Errors on our side
When the first request fails with a 5xx error, GioSMS forgets its key. Retry with the same key: it runs as if it were the first.
Retrying well
- Retry timeouts,
409,429and5xxresponses, waiting a little longer each time. - Do not retry
4xxresponses other than409and429unchanged: fix the request first. - Keep the same key for every retry of one send.