Criar webhook
curl --request POST \
--url https://api.sandbox.z2pay.com/v1/webhooks \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"name": "<string>",
"url": "<string>",
"events": [],
"checkoutLinkIds": [
"<string>"
],
"secret": "<string>"
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
url: '<string>',
events: [],
checkoutLinkIds: ['<string>'],
secret: '<string>'
})
};
fetch('https://api.sandbox.z2pay.com/v1/webhooks', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.sandbox.z2pay.com/v1/webhooks"
payload = {
"name": "<string>",
"url": "<string>",
"events": [],
"checkoutLinkIds": ["<string>"],
"secret": "<string>"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "<string>",
"name": "<string>",
"url": "<string>",
"events": [
"<string>"
],
"checkoutLinkIds": [
"<string>"
],
"isActive": true,
"hasSecret": true,
"secretHint": "<string>",
"autoDisabledAt": "2023-11-07T05:31:56Z",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"secret": "<string>"
}{
"error": {
"code": "VALIDATION_ERROR",
"message": "Validation failed",
"issues": [
{
"path": "status",
"message": "Status inválido. Valores aceitos: pending, waiting_payment, paid, refused, canceled, refunded"
},
{
"path": "startDate",
"message": "Data deve ser ISO 8601 com timezone (ex.: 2026-06-24T00:00:00Z)"
}
]
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid API key"
}
}{
"error": "A request with this idempotency key is already being processed"
}{
"error": "Idempotency key already used with a different request body"
}Webhooks
Criar webhook
Registra um endereço para receber notificações e devolve o secret de assinatura — a única vez que ele aparece.
POST
/
webhooks
Criar webhook
curl --request POST \
--url https://api.sandbox.z2pay.com/v1/webhooks \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"name": "<string>",
"url": "<string>",
"events": [],
"checkoutLinkIds": [
"<string>"
],
"secret": "<string>"
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
url: '<string>',
events: [],
checkoutLinkIds: ['<string>'],
secret: '<string>'
})
};
fetch('https://api.sandbox.z2pay.com/v1/webhooks', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.sandbox.z2pay.com/v1/webhooks"
payload = {
"name": "<string>",
"url": "<string>",
"events": [],
"checkoutLinkIds": ["<string>"],
"secret": "<string>"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "<string>",
"name": "<string>",
"url": "<string>",
"events": [
"<string>"
],
"checkoutLinkIds": [
"<string>"
],
"isActive": true,
"hasSecret": true,
"secretHint": "<string>",
"autoDisabledAt": "2023-11-07T05:31:56Z",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"secret": "<string>"
}{
"error": {
"code": "VALIDATION_ERROR",
"message": "Validation failed",
"issues": [
{
"path": "status",
"message": "Status inválido. Valores aceitos: pending, waiting_payment, paid, refused, canceled, refunded"
},
{
"path": "startDate",
"message": "Data deve ser ISO 8601 com timezone (ex.: 2026-06-24T00:00:00Z)"
}
]
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid API key"
}
}{
"error": "A request with this idempotency key is already being processed"
}{
"error": "Idempotency key already used with a different request body"
}POST /webhooks
Faz parte do recurso Webhooks — o catálogo de eventos e as regras do secret
estão lá.
Registra a URL, define quais eventos ela recebe e devolve 201 com o webhook criado. Já nasce
ativo: se houver evento assinado acontecendo, a primeira entrega sai em seguida.
Copie o
secret desta resposta. É a única vez que ele sai em claro — as leituras devolvem
hasSecret e secretHint no lugar, e nenhuma rota o troca depois. Sem ele guardado, não há
como verificar a assinatura das entregas.Não precisa inventar um segredo. Omita o campo e a plataforma gera um
whsec_… de 256 bits,
que volta nesta mesma resposta — mais forte que a maioria dos valores escolhidos à mão. Enviar o
seu próprio continua valendo, com no mínimo 8 caracteres, para quando o segredo já existe do seu
lado.events vazio, ou omitido, assina TODOS os eventos — inclusive os que forem criados no
futuro. Para receber só o que interessa, liste os códigos do
catálogo; um código fora dele é recusado com 400.A URL precisa ser pública.
localhost, faixas privadas e endereços de metadata de nuvem são
recusados com 400 — a lista completa está na visão geral.Exemplo
curl -X POST https://api.sandbox.z2pay.com/v1/webhooks \
-H "x-api-key: SUA_CHAVE_DE_SANDBOX" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 3f1c8a90-2b7d-4d2e-9b1a-6f0e2c5a9d11" \
-d '{
"name": "Notificações de pagamento",
"url": "https://meusite.com/webhooks/z2pay",
"events": ["transaction.paid", "transaction.refunded"]
}'
Resposta 201
{
"id": "whk_k9clfafnldd96dbbxruh34233",
"name": "Notificações de pagamento",
"url": "https://meusite.com/webhooks/z2pay",
"events": ["transaction.paid", "transaction.refunded"],
"isActive": true,
"hasSecret": true,
"secretHint": "whsec_kQ8v…rS8t",
"secret": "whsec_kQ8vN2pR7mT4wY6zA1bC3dE5fG9hJ0kL2nM4pQ6rS8t",
"autoDisabledAt": null,
"createdAt": "2026-06-24T13:45:00.000Z",
"updatedAt": "2026-06-24T13:45:00.000Z"
}
Body
application/json
Eventos que disparam notificações para este webhook (ex.: transaction.paid, payment.refunded).
Available options:
transaction.created, transaction.waiting_payment, transaction.paid, transaction.partially_paid, transaction.pending, transaction.refused, transaction.failed, transaction.canceled, transaction.waiting_refund, transaction.refunded, transaction.in_protest, transaction.chargeback, payment.created, payment.waiting_payment, payment.paid, payment.pending, payment.refused, payment.failed, payment.canceled, payment.waiting_refund, payment.refunded, payment.in_protest, payment.chargeback, refund.created, refund.approved, refund.refused, refund.processing, refund.refunded, refund.failed, refund.awaiting_bank_details, refund.bank_details_received, refund.invalid_bank_details, refund.ted_processing, chargeback.opened, chargeback.under_review, chargeback.submitted, chargeback.won, chargeback.lost, chargeback.document.uploaded, customer.created, customer.updated, recipient.created, recipient.updated, recipient.approved, recipient.refused, recipient.deleted, recipient.pendency_updated, recipient.contract_requested, recipient.contract_signed, recipient.bank_account.created, recipient.bank_account.validated, recipient.bank_account.ownership_refused, recipient.bank_account.rejected, recipient.bank_account.reactivated, recipient.bank_account.default_changed, recipient.bank_account.removed, withdrawal.requested, withdrawal.paid, withdrawal.rejected, withdrawal.failed, withdrawal.retention_released, invoice.issued, invoice.payment_attempted, invoice.paid, invoice.voided, invoice.refunded, invoice.rescheduled, invoice.payment_refused_final, extra_item.created, extra_item.canceled, extra_item.billed, subscription.created, subscription.trial_started, subscription.activated, subscription.canceled, subscription.completed, subscription.cycle_advanced, subscription.paused, subscription.resumed, subscription.past_due, subscription.unpaid, subscription.restored, subscription.reactivated, subscription.plan_changed, subscription.plan_change_scheduled, subscription.plan_change_canceled, pix_authorization.activated, pix_authorization.canceled, pix_authorization.expired, anticipation.status_changed Response
Webhook criado