Guide 7/12
Idempotency
Networks fail. With an Idempotency-Key, a repeated POST never creates a second record.
- Send a unique key (8–120 characters, a UUID is ideal) per operation.
- For 24 h the same key + same body returns the stored response with
Idempotency-Replayed: true. - Same key + different body →
409 idempotencia_conflito; same key still running →409 idempotencia_em_curso. - Keys are per credential: two integrations never collide.
curl -X POST "https://anagen.pt/api/v1/tarefas" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 6c1d9a42-2b1f-4f7e-9a51-1b2d3c4e5f60" \
-d '{"titulo":"Ligar à Rita Matos","prazo":"2026-10-29T10:00:00+00:00","prioridade":"alta"}'
# A mesma chave e o mesmo corpo devolvem a mesma resposta (cabeçalho Idempotency-Replayed: true).
# A mesma chave com outro corpo devolve 409 idempotencia_conflito.