curl --request PATCH \
--url https://api-sandbox.beinfi.com/account/webhooks/{endpointID} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"isActive": true,
"events": [],
"active": true
}
'import requests
url = "https://api-sandbox.beinfi.com/account/webhooks/{endpointID}"
payload = {
"isActive": True,
"events": [],
"active": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({isActive: true, events: [], active: true})
};
fetch('https://api-sandbox.beinfi.com/account/webhooks/{endpointID}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-sandbox.beinfi.com/account/webhooks/{endpointID}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'isActive' => true,
'events' => [
],
'active' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-sandbox.beinfi.com/account/webhooks/{endpointID}"
payload := strings.NewReader("{\n \"isActive\": true,\n \"events\": [],\n \"active\": true\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api-sandbox.beinfi.com/account/webhooks/{endpointID}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"isActive\": true,\n \"events\": [],\n \"active\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-sandbox.beinfi.com/account/webhooks/{endpointID}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"isActive\": true,\n \"events\": [],\n \"active\": true\n}"
response = http.request(request)
puts response.read_body{
"id": "we_3Tz8yU1oI4pA7sD0fG2hJk",
"url": "<string>",
"events": [
"<string>"
],
"isActive": true,
"createdAt": "2023-11-07T05:31:56Z"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>",
"resource": "<string>"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>",
"errors": [
{
"field": "<string>",
"value": "<string>",
"constraint": "<string>",
"description": "<string>"
}
]
}Atualizar webhook
Muda os eventos, liga ou desliga o endpoint. Envie isActive, events ou os dois; o que não vier fica como está. events substitui a lista inteira. A URL e o segredo não mudam aqui (o segredo muda em rotate-secret).
curl --request PATCH \
--url https://api-sandbox.beinfi.com/account/webhooks/{endpointID} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"isActive": true,
"events": [],
"active": true
}
'import requests
url = "https://api-sandbox.beinfi.com/account/webhooks/{endpointID}"
payload = {
"isActive": True,
"events": [],
"active": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({isActive: true, events: [], active: true})
};
fetch('https://api-sandbox.beinfi.com/account/webhooks/{endpointID}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-sandbox.beinfi.com/account/webhooks/{endpointID}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'isActive' => true,
'events' => [
],
'active' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-sandbox.beinfi.com/account/webhooks/{endpointID}"
payload := strings.NewReader("{\n \"isActive\": true,\n \"events\": [],\n \"active\": true\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api-sandbox.beinfi.com/account/webhooks/{endpointID}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"isActive\": true,\n \"events\": [],\n \"active\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-sandbox.beinfi.com/account/webhooks/{endpointID}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"isActive\": true,\n \"events\": [],\n \"active\": true\n}"
response = http.request(request)
puts response.read_body{
"id": "we_3Tz8yU1oI4pA7sD0fG2hJk",
"url": "<string>",
"events": [
"<string>"
],
"isActive": true,
"createdAt": "2023-11-07T05:31:56Z"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>",
"resource": "<string>"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>",
"errors": [
{
"field": "<string>",
"value": "<string>",
"constraint": "<string>",
"description": "<string>"
}
]
}Autorizações
Chave secreta da conta: Authorization: Bearer sk_test_… ou sk_live_…. Use só no servidor.
Cabeçalhos
Chave única por operação (um UUID serve). Repetir com a mesma chave devolve a resposta original.
Parâmetros de caminho
^we_[0-9A-Za-z]{22}$"we_3Tz8yU1oI4pA7sD0fG2hJk"
Corpo
true liga, false desliga. Desligado, o endpoint não recebe entregas.
A nova lista de eventos. Pelo menos um.
1checkout.session.created, checkout.session.completed, checkout.session.expired, customer.created, customer.converted, invoice.finalized, invoice.sent, invoice.paid, invoice.voided, invoice.uncollectible, invoice.auto_collection_failed, payment.confirmed, payment.failed, payment.refunded, payment.refund_reversed, payment.chargeback, payment.chargeback_reversed, plan.changed, usage.threshold_reached, credit.balance_low, credit.balance_depleted, subscription.cancel_scheduled, subscription.cancel_unscheduled, subscription.canceled, subscription.past_due, refund_request.created, payment.duplicate_detected, payment.duplicate_refunded, refund_request.declined Grafia antiga de isActive, ainda aceita.
Resposta
O endpoint atualizado.
^we_[0-9A-Za-z]{22}$"we_3Tz8yU1oI4pA7sD0fG2hJk"
URL que recebe as entregas.
Eventos assinados. Qualquer evento emitido pode ser assinado pelo nome, inclusive os que ainda não têm payload documentado.
Se o endpoint está recebendo entregas.