Voltar ao site
Webhook endpoints

Criar webhook endpoint

POST/v1/webhook-endpoints

Cria um endpoint que recebe eventos assinados. Credencial de organização sem X-Merchant-Id cria ORGANIZATION; com o header (ou credencial de merchant) cria MERCHANT; escopo e merchantId não mudam depois. URL https na porta 443 ou 8443, sem fragmento nem userinfo, que não resolva para IP privado. Até 10 endpoints por escopo e ambiente. O secret aparece só nesta resposta; o replay devolve 201 com o mesmo id e secret: null.

X-Merchant-Id é opcional: credencial de organização sem o header atua no escopo ORGANIZATION (organização e todos os merchants do tenant); com o header, no escopo MERCHANT daquele merchant. Credencial de merchant atua sempre no próprio merchant.

Authorization

kodanoOAuth webhooks:endpoints:write
headerAuthorizationBearer <token>

Token obtido no Zitadel do ambiente (POST /oauth/v2/token), fora do host da API, e enviado em Authorization: Bearer <access_token>.

  • Sandbox: https://kodano-uat-p55zt6.us1.zitadel.cloud/oauth/v2/token
  • Produção: https://kodano-prod-qe8hbt.us1.zitadel.cloud/oauth/v2/token

Use sempre o tokenUrl devolvido na emissão da credencial. Duas variantes: private_key_jwt (preferida; grant urn:ietf:params:oauth:grant-type:jwt-bearer com assertion RS256 assinada pela chave da credencial, iss = sub = userId, aud = authority do Zitadel, kid = keyId) e client_secret (grant client_credentials). O OpenAPI só modela a segunda.

O parâmetro scope do token é OIDC, não os escopos da API: openid urn:zitadel:iam:org:project:id:<projectId da API>:aud urn:zitadel:iam:user:resourceowner. Sem o :aud a API responde 401 AUTH.TOKEN_INVALID; sem resourceowner, 403 AUTH.TENANT_MISMATCH.

Os 28 escopos abaixo são os entitlements concedidos à credencial pelos produtos de integração (produto:recurso:ação; write não implica read), avaliados a cada requisição; não são pedidos no token. O tenant vem da organização do token; o merchant, de X-Merchant-Id. Revogar a credencial nega os tokens já emitidos em até 60 s.

Scope: webhooks:endpoints:write

Header Parameters

X-Merchant-Id?string

Opcional. Credencial de organização sem o header atua no nível da organização; com o header, no merchant indicado. Fora do tenant, inexistente ou diferente do merchant da credencial de merchant → 403 MERCHANT.FORBIDDEN.

Match^mrc_[0-9a-f]{32}$
Idempotency-Key*string

UUID, retido por 24 h a partir da primeira chamada. Escopo: (tenant, merchant, rota-template, chave). Mesma chave e mesmo corpo → resposta original (2xx ou 4xx) com X-Idempotent-Replay: true; corpo ou path concreto diferente → 409 IDEMPOTENCY.CONFLICT; em execução ou desfecho desconhecido → 409 IDEMPOTENCY.IN_PROGRESS com resourceId e Retry-After: 2. Ausente ou não-UUID → 422 IDEMPOTENCY.KEY_REQUIRED.

Formatuuid
X-Correlation-Id?string

Opcional, sempre ecoado na resposta e repetido em correlationId do Problem. Ausente ou inválido → o serviço gera UUID v7.

Match^[A-Za-z0-9._-]{1,64}$

Request Body

application/json
  1. body
url*string
Formaturi
Lengthlength <= 500
events*array<>
Items1 <= items <= 20
description?string
Lengthlength <= 255

Response Body

Endpoint criado (ou replay com secret: null).

application/json
  1. response
id*string
Match^whe_
url*string

https, porta 443 ou 8443, sem fragmento nem userinfo.

Formaturi
Lengthlength <= 500
description*|
Lengthlength <= 255
events*array<>
Items1 <= items <= 20
status*string
Value in"ACTIVE""DISABLED"
scope*string

Imutável.

Value in"ORGANIZATION""MERCHANT"
merchantId*|

mrc_… no escopo MERCHANT; null no ORGANIZATION; imutável.

failureCount*integer

Falhas de entrega desde o último 2xx (exclui TEST).

lastSuccessAt*|
Formatdate-time
lastFailureAt*|
Formatdate-time
disabledAt*|
Formatdate-time
disabledReason*|
Value in"MANUAL""AUTO_FAILURES"null
previousSecretExpiresAt*|

Fim da janela em que o segredo anterior ainda assina.

Formatdate-time
createdAt*string
Formatdate-time
updatedAt*string
Formatdate-time
secret*|

Exibido uma única vez; null no replay de idempotência.

Match^whsec_[A-Za-z0-9_-]{43}$
Example Request
curl -X POST 'https://api.sandbox.kodano.com.br/v1/webhook-endpoints' \  -H 'X-Merchant-Id: mrc_e3cc4727054da558273162251e310d29' \  -H 'Idempotency-Key: 4b2e8c1a-9d7f-4e3b-a6c5-0f1e2d3c4b5a' \  -H 'X-Correlation-Id: erp-7f3a-0010' \  -H 'Content-Type: application/json' \  -d '{  "url": "https://hooks.parceiro.com.br/kodano",  "events": [    "payment.succeeded",    "payment.failed",    "payment.refunded"  ],  "description": "ERP financeiro"}'
Example Response
{  "id": "whe_zQ7EUbzgd8SsjEVUqldLn3OYxujoQHxr",  "url": "https://hooks.parceiro.com.br/kodano",  "description": "ERP financeiro",  "events": [    "payment.succeeded",    "payment.failed",    "payment.refunded"  ],  "status": "ACTIVE",  "scope": "MERCHANT",  "merchantId": "mrc_e3cc4727054da558273162251e310d29",  "failureCount": 0,  "lastSuccessAt": null,  "lastFailureAt": null,  "disabledAt": null,  "disabledReason": null,  "previousSecretExpiresAt": null,  "createdAt": "2026-10-16T12:40:00Z",  "updatedAt": "2026-10-16T12:40:00Z",  "secret": "whsec_XsH9ts25IljV8jgbNWhU4DWlbQzMdJ3q_Sc4GTU51tY"}