Idempotency
Three requests save something for a consumer: POST /v1/favorites, POST /v1/saved-shapes and
POST /v1/saved-searches. A fourth saves something for the account:
POST /v1/webhook-endpoints (below).
If the answer to one never arrives (a dropped connection, a timeout), sending it again could save
twice. Send an Idempotency-Key header and the repeat is safe:
POST /v1/saved-shapes
Idempotency-Key: <a new random UUID for this action>
The rules
- The key is 1 to 255 printable ASCII characters. Use a new random value, such as a UUID,
for each action, and repeat it only to retry that same request unchanged. Never build the key
from the action itself: two visitors saving the same listing would then send the same key.
A key outside those limits is
400 validation_failedonheader.Idempotency-Key. - A repeat with the same key and the same request, after the first succeeded, returns the
first answer again, with its status and its
data, and the headerIdempotency-Replayed: true. Nothing is saved a second time. The envelope'smeta.requestIdis the repeat's own. "The same request" means the same route, the same consumer and the same JSON body; spacing and the order of an object's keys don't matter. - A different request under a used key is
409 idempotency_conflict. So is the same key from another consumer of your account: keys are reserved per account, and one consumer's stored answer is never shown to another. - A repeat while the first is still running is
409 idempotency_conflictwithRetry-After: 1. Retry after that and you get the stored answer. - Only successes are kept. A request that ended in a 4xx or 5xx leaves nothing behind, so sending it again runs it again.
- A key answers for 24 hours. After that it is free, and a request under it runs as new.
- Records are deleted with the consumer (
DELETE /v1/clients/{clientId}).
Other routes ignore the header. In the browser, Idempotency-Key may be sent and
Idempotency-Replayed read (CORS allows both).
Webhook endpoints
POST /v1/webhook-endpoints accepts the header too. It acts for the account, not for a
consumer, and two things differ:
- A repeat never returns the secret. A repeat of a registration that succeeded returns the
same endpoint with
Idempotency-Replayed: trueand withoutsecret: the secret is shown once and is never kept where it could be shown again. If the first answer was lost and you don't have the secret, delete the endpoint (DELETE /v1/webhook-endpoints/{id}) and create it again with a new key. - Registration takes time, because it waits for your endpoint to answer a ping. A repeat
that arrives while the first request is still pinging is
409 idempotency_conflictwithRetry-After: 1, and only one ping is sent. A registration that failed (the ping was refused or not answered) leaves nothing behind: the same key runs it again.
Without a key
Both requests are already safe to repeat in the simple case: saving a listing the consumer has
saved before returns the existing favorite with 200. A saved shape has no such natural
identity, so a repeat without a key saves a second shape. Send the key.