> ## Documentation Index
> Fetch the complete documentation index at: https://docs.socialsell.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Rotacionar secret

> Gera um novo secret de assinatura sem recriar a assinatura nem perder o histórico.

## Endpoint

```
POST /v1/webhooks/{id}/rotate-secret
```

**Escopo necessário:** `write:webhooks`

Use quando o secret vazou ou quando sua política de segurança pede rotação periódica. A assinatura, os eventos assinados e o log de entregas permanecem intactos.

## Exemplo de requisição

```bash theme={null}
curl -X POST https://api.socialsell.ai/v1/webhooks/664f1a2b3c4d5e6f78901234/rotate-secret \
  -H "Authorization: Bearer sk_live_..."
```

## Exemplo de resposta

```json theme={null}
{
  "data": {
    "id": "664f1a2b3c4d5e6f78901234",
    "name": "Integração ERP",
    "url": "https://meusistema.com/webhooks/socialsell",
    "events": ["deal.won", "channel.disconnected"],
    "status": "active",
    "secret": "whsec_9a8b7c6d5e4f3a2b1c0d9e8f7a6b5c4d3e2f1a0b9c8d7e6f",
    "last_delivery_at": "2026-08-20T14:30:00.000Z",
    "last_failure_at": null,
    "consecutive_failures": 0,
    "created_at": "2026-07-01T10:00:00.000Z",
    "updated_at": "2026-08-20T15:00:00.000Z"
  }
}
```

<Warning>
  O secret anterior **para de valer imediatamente** e o novo só aparece nesta resposta. Atualize a
  variável de ambiente do seu backend antes de rotacionar; entregas rejeitadas na janela de troca são
  retentadas automaticamente e podem ser reenviadas pelo log.
</Warning>

## Erros

| Status | Código       | Quando acontece                           |
| ------ | ------------ | ----------------------------------------- |
| `400`  | `INVALID_ID` | O `id` não é um identificador válido      |
| `404`  | `NOT_FOUND`  | A assinatura não existe nesta organização |
