Pular para o conteúdo
Última atualização

Idempotência

GET, PUT e DELETE já são idempotentes por padrão HTTP. Para POST e PATCH em recursos sensíveis (tarefas, OS, tickets), siga as práticas abaixo.

Correlação por externalId

  • Envie um identificador gerado pelo seu sistema em externalId (ex.: ID do ERP). Antes de criar, chame o GET correspondente filtrando por externalId.
  • Se existir, atualize via PATCH; se não, crie via POST.

Chave de idempotência por entrega (Webhooks)

  • Use deliveryId do payload para deduplicar do seu lado (write-once em tabela webhook_deliveries).

Política de retry segura

async function postWithSafety(body) {
  const existing = await findByExternalId(body.externalId);
  if (existing) return existing;
  try {
    return await api.post('/tasks', body);
  } catch (err) {
    if (err.status === 409) {
      return findByExternalId(body.externalId);
    }
    throw err;
  }
}

Em roadmap

  • Suporte nativo a Idempotency-Key (padrão Stripe-like) — acompanhe o changelog.