Send an Idempotency-Key header with a write (POST, PUT, PATCH or
DELETE), and you can retry it without the work being done twice. You need
this most after a timeout, when you never saw the response. Use a new
unique value, such as a UUID, for each operation:
Idempotency-Key: 1f8e6b1a-9c4d-4a2e-8b3a-2f6d0c9e7a51
Where it is required
The key is required wherever a repeat could do real harm.
Calls that reach a carrier need it, because a repeat could place a second real order:
- placing, answering, changing or cancelling an order
- submitting a bundle
- ordering a number
- reserving, changing or cancelling a technician appointment
- the carrier service tests and health reports, and a new Opticomm session history test
- a batch qualification
- Opticomm’s static IP call.
Calls that bill or send need it, because a repeat could charge you twice or send something twice:
- creating a SIP trunk
- ordering a residential line (
POST /residential-lines) - requesting a port (
POST /ports) - ordering a fax plan
- sending a fax
- requesting an NBN quote
- sending an SMS (
POST /smsandPOST /sms/bulk) - ordering colocation
- handing a step of a port or data order to a person, which emails them a live link
- rotating a webhook secret.
Some writes on our side need it, because they must not run twice:
- recording an end user’s usage (
POST /end-users/{endUser}/usageandPOST /usage/batch), which would bill them twice - importing end users, which would import the file twice
- rotating your own API key
- a bulk change to numbers (
POST /numbers/bulk), which could release them twice - linking data services to an end user in bulk
(
POST /data/services/assign) - hanging up a call
- inviting a user (
POST /account/users), which would send a second invitation email and cancel the link in the first.
The reference lists the header as required on each of these.
Without it, they all answer 400 with the same body.
Every other write accepts the key and honours it, but also runs without one. We don’t deduplicate a write you send without the key.
How a key behaves
| You send | You get |
|---|---|
| A new key | The request runs, and we store its response. |
| The same key and the same request | The stored response, with Idempotent-Replayed: true. Nothing runs again. |
| The same key with a different request | 422 idempotency_key_reused. |
| The same key while its first request is still running | 409 idempotency_in_progress, with Retry-After. Retry after that time. |
| A key longer than 255 characters | 400. |
We store a 5xx like any other response. Retrying with the same key
returns the same 5xx, and the write does not run again.
A request that timed out may still have succeeded, so its key stays spent. Once you know the operation did not happen, send it again under a new key.
If a key keeps answering 409 long after the first call, contact us. We
never release a key on our own, because we can’t tell a slow request from
one that stopped.
Keys belong to your API key, and we keep them for 30 days.
The client libraries send a new key with every write for you.