curl --request POST \
--url https://v4pay-api.vercel.app/webhook-endpoints \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "https://meusite.com/webhooks/v4pay",
"name": "<string>",
"events": [],
"secret": "<string>"
}
'import requests
url = "https://v4pay-api.vercel.app/webhook-endpoints"
payload = {
"url": "https://meusite.com/webhooks/v4pay",
"name": "<string>",
"events": [],
"secret": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: 'https://meusite.com/webhooks/v4pay',
name: '<string>',
events: [],
secret: '<string>'
})
};
fetch('https://v4pay-api.vercel.app/webhook-endpoints', 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://v4pay-api.vercel.app/webhook-endpoints",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'url' => 'https://meusite.com/webhooks/v4pay',
'name' => '<string>',
'events' => [
],
'secret' => '<string>'
]),
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://v4pay-api.vercel.app/webhook-endpoints"
payload := strings.NewReader("{\n \"url\": \"https://meusite.com/webhooks/v4pay\",\n \"name\": \"<string>\",\n \"events\": [],\n \"secret\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", 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.post("https://v4pay-api.vercel.app/webhook-endpoints")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://meusite.com/webhooks/v4pay\",\n \"name\": \"<string>\",\n \"events\": [],\n \"secret\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://v4pay-api.vercel.app/webhook-endpoints")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"https://meusite.com/webhooks/v4pay\",\n \"name\": \"<string>\",\n \"events\": [],\n \"secret\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "Loja principal",
"events": [
"charge.created"
],
"version": "v1",
"url": "https://meusite.com/webhooks/v4pay",
"secret": "whsec_a1b2c3d4...",
"active": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
}{
"error": {
"message": "<string>"
}
}{
"error": "Token JWT ou chave de API ausente"
}Cadastrar webhook do lojista
Endpoint que recebe eventos da V4 Pay (ex.: charge.paid) com assinatura HMAC-SHA256 do corpo no header X-V4Pay-Signature.
curl --request POST \
--url https://v4pay-api.vercel.app/webhook-endpoints \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "https://meusite.com/webhooks/v4pay",
"name": "<string>",
"events": [],
"secret": "<string>"
}
'import requests
url = "https://v4pay-api.vercel.app/webhook-endpoints"
payload = {
"url": "https://meusite.com/webhooks/v4pay",
"name": "<string>",
"events": [],
"secret": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: 'https://meusite.com/webhooks/v4pay',
name: '<string>',
events: [],
secret: '<string>'
})
};
fetch('https://v4pay-api.vercel.app/webhook-endpoints', 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://v4pay-api.vercel.app/webhook-endpoints",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'url' => 'https://meusite.com/webhooks/v4pay',
'name' => '<string>',
'events' => [
],
'secret' => '<string>'
]),
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://v4pay-api.vercel.app/webhook-endpoints"
payload := strings.NewReader("{\n \"url\": \"https://meusite.com/webhooks/v4pay\",\n \"name\": \"<string>\",\n \"events\": [],\n \"secret\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", 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.post("https://v4pay-api.vercel.app/webhook-endpoints")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://meusite.com/webhooks/v4pay\",\n \"name\": \"<string>\",\n \"events\": [],\n \"secret\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://v4pay-api.vercel.app/webhook-endpoints")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"https://meusite.com/webhooks/v4pay\",\n \"name\": \"<string>\",\n \"events\": [],\n \"secret\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "Loja principal",
"events": [
"charge.created"
],
"version": "v1",
"url": "https://meusite.com/webhooks/v4pay",
"secret": "whsec_a1b2c3d4...",
"active": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
}{
"error": {
"message": "<string>"
}
}{
"error": "Token JWT ou chave de API ausente"
}Authorizations
Token JWT obtido em /auth/login, enviado no cabeçalho Authorization no formato Bearer <token>.
Body
"https://meusite.com/webhooks/v4pay"
Nome para identificar na lista
Eventos a receber. Omitido ou vazio = todos.
charge.created, charge.paid, subscription.charged, withdrawal.completed, withdrawal.rejected Opcional — segredo de assinatura gerado do SEU lado (ex.: no navegador, para o lojista ver antes de salvar). Só no formato exato whsec_ + 32 hexadecimais minúsculos; fora disso, ou com os 32 caracteres iguais, 400. IMPORTANTE: a API confere o FORMATO, não a aleatoriedade — este valor assina o X-V4Pay-Signature dos seus eventos, então gere-o com um gerador criptográfico (crypto.getRandomValues/randomBytes), nunca um valor fixo ou derivado de senha: secret previsível é evento forjável. Omitido, a API gera (com entropia garantida).
^whsec_[0-9a-f]{32}$Response
Endpoint cadastrado (o secret vem na resposta).
Endpoint do lojista que recebe eventos da V4 Pay.
Show child attributes
Show child attributes