Configurar webhook da conta
POST https://api.avista.global/api/webhooks
Requer um Bearer token no header Authorization. Veja Gerar Token para obter um.
Configura ou atualiza a URL de webhook para um tipo de evento específico. Se já existir um webhook configurado para o mesmo tipo de evento, ele será atualizado (comportamento de upsert).
Requer token Bearer no header Authorization.
Evento Descrição cash_inPIX recebido cash_outPIX enviado refund_inEstorno de recebimento (devolução solicitada) refund_outDevolução recebida med_createdMED (Mecanismo Especial de Devolução) aberto contra uma transação med_acceptedSolicitação de devolução MED aprovada med_rejectedSolicitação de devolução MED rejeitada
Campo Tipo Obrigatório Descrição urlstring Sim URL HTTPS do endpoint que receberá os webhooks eventTypestring Sim Tipo de evento: cash_in, cash_out, refund_in, refund_out, med_created, med_accepted, med_rejected headersarray Não Headers customizados para autenticação (máximo 5). Headers bloqueados: host, content-length, connection, transfer-encoding, content-type, user-agent headers[].keystring Sim Nome do header headers[].valuestring Sim Valor do header
{
"url" : "https://api.example.com/webhooks/pix" ,
"eventType" : "cash_in" ,
"headers" : [
{ "key" : "Authorization" , "value" : "Bearer token123" },
{ "key" : "X-Webhook-Secret" , "value" : "abc123" }
]
}
curl -X POST "https://api.avista.global/api/webhooks" \
-H "Authorization: Bearer $AVISTA_TOKEN " \
-H "Content-Type: application/json" \
-d '{
"url": "https://api.example.com/webhooks/pix",
"eventType": "cash_in",
"headers": [
{ "key": "Authorization", "value": "Bearer token123" },
{ "key": "X-Webhook-Secret", "value": "abc123" }
]
}'
JavaScript Python PHP Java
const axios = require ( 'axios' );
const response = await axios. post ( 'https://api.avista.global/api/webhooks' ,
{
"url" : "https://api.example.com/webhooks/pix" ,
"eventType" : "cash_in" ,
"headers" : [
{ "key" : "Authorization" , "value" : "Bearer token123" },
{ "key" : "X-Webhook-Secret" , "value" : "abc123" }
]
},
{
headers: {
'Authorization' : `Bearer ${ process . env . AVISTA_TOKEN }` ,
'Content-Type' : 'application/json' ,
},
}
);
console. log (response.data); import os, requests
response = requests.post(
'https://api.avista.global/api/webhooks' ,
headers = {
'Authorization' : f 'Bearer { os.environ[ "AVISTA_TOKEN" ] } ' ,
'Content-Type' : 'application/json' ,
},
json = {
"url" : "https://api.example.com/webhooks/pix" ,
"eventType" : "cash_in" ,
"headers" : [
{ "key" : "Authorization" , "value" : "Bearer token123" },
{ "key" : "X-Webhook-Secret" , "value" : "abc123" }
]
},
)
print (response.json()) $ch = curl_init ( 'https://api.avista.global/api/webhooks' );
curl_setopt_array ($ch, [
CURLOPT_RETURNTRANSFER => true ,
CURLOPT_POST => true ,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv ( 'AVISTA_TOKEN' ),
'Content-Type: application/json' ,
],
CURLOPT_POSTFIELDS => '{
"url": "https://api.example.com/webhooks/pix",
"eventType": "cash_in",
"headers": [
{ "key": "Authorization", "value": "Bearer token123" },
{ "key": "X-Webhook-Secret", "value": "abc123" }
]
}' ,
]);
$response = curl_exec ($ch);
curl_close ($ch);
echo $response; String body = """
{
"url": "https://api.example.com/webhooks/pix",
"eventType": "cash_in",
"headers": [
{ "key": "Authorization", "value": "Bearer token123" },
{ "key": "X-Webhook-Secret", "value": "abc123" }
]
}
""" ;
HttpRequest request = HttpRequest. newBuilder ()
. uri (URI. create ( "https://api.avista.global/api/webhooks" ))
. header ( "Authorization" , "Bearer " + System. getenv ( "AVISTA_TOKEN" ))
. header ( "Content-Type" , "application/json" )
. POST (HttpRequest.BodyPublishers. ofString (body))
. build ();
HttpResponse< String > response = HttpClient. newHttpClient ()
. send (request, HttpResponse.BodyHandlers. ofString ());
System.out. println (response. body ());
Campo Tipo Descrição successboolean Indica se a operação foi bem-sucedida messagestring Mensagem descritiva do resultado
{
"success" : true ,
"message" : "Webhook configurado com sucesso"
}
Status Descrição 400 Dados inválidos (URL não e HTTPS, tipo de evento inválido, etc.) 401 Token não fornecido ou inválido 404 Conta não encontrada 500 Erro interno ao configurar webhook