curl
curl -X POST 'https://api.velan.app/v1/developer/webhooks' \
-H 'Authorization: Bearer $VELAN_KEY' \
-H 'Idempotency-Key: webhook-erp-producao' \
-H 'Content-Type: application/json' \
-d '{"all_products": true, "events": ["order.paid", "order.refunded"], "name": "ERP", "secret": "um-segredo-longo-e-aleatorio", "url": "https://erp.exemplo.com/velan"}'import requests
url = "https://api.velan.app/v1/developer/webhooks"
payload = {
"all_products": True,
"events": ["order.paid", "order.refunded"],
"name": "ERP",
"secret": "um-segredo-longo-e-aleatorio",
"url": "https://erp.exemplo.com/velan"
}
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({
all_products: true,
events: ['order.paid', 'order.refunded'],
name: 'ERP',
secret: 'um-segredo-longo-e-aleatorio',
url: 'https://erp.exemplo.com/velan'
})
};
fetch('https://api.velan.app/v1/developer/webhooks', 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.velan.app/v1/developer/webhooks",
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([
'all_products' => true,
'events' => [
'order.paid',
'order.refunded'
],
'name' => 'ERP',
'secret' => 'um-segredo-longo-e-aleatorio',
'url' => 'https://erp.exemplo.com/velan'
]),
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.velan.app/v1/developer/webhooks"
payload := strings.NewReader("{\n \"all_products\": true,\n \"events\": [\n \"order.paid\",\n \"order.refunded\"\n ],\n \"name\": \"ERP\",\n \"secret\": \"um-segredo-longo-e-aleatorio\",\n \"url\": \"https://erp.exemplo.com/velan\"\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://api.velan.app/v1/developer/webhooks")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"all_products\": true,\n \"events\": [\n \"order.paid\",\n \"order.refunded\"\n ],\n \"name\": \"ERP\",\n \"secret\": \"um-segredo-longo-e-aleatorio\",\n \"url\": \"https://erp.exemplo.com/velan\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.velan.app/v1/developer/webhooks")
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 \"all_products\": true,\n \"events\": [\n \"order.paid\",\n \"order.refunded\"\n ],\n \"name\": \"ERP\",\n \"secret\": \"um-segredo-longo-e-aleatorio\",\n \"url\": \"https://erp.exemplo.com/velan\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"created": true,
"integration": {
"all_products": true,
"auth": null,
"category": "webhook",
"destination": "https://erp.exemplo.com/…",
"disabled_reason": null,
"events": [
"order.paid",
"order.refunded"
],
"failure_count": 0,
"id": 1,
"is_active": true,
"label": "Webhook",
"last_failure_at": null,
"products": [],
"signed": true,
"title": "ERP",
"type": "webhook"
}
}
}{
"error": {
"type": "validation_error",
"message": "Campos não aceitos nesta rota.",
"fields": {
"confirmm": "Campo desconhecido."
}
}
}{
"error": {
"type": "authentication_error",
"message": "Envie Authorization: Bearer <chave de API>."
}
}{
"error": {
"type": "permission_error",
"message": "Esta chave não tem permissão de escrita em 'webhooks'. Crie uma chave com essa permissão."
}
}{
"error": {
"type": "not_found",
"message": "Assinatura não encontrada."
}
}{
"error": {
"type": "conflict",
"message": "Idempotency-Key já usada com outra requisição. Gere uma chave nova para uma operação nova."
}
}{
"error": {
"type": "unprocessable",
"message": "Descreva o motivo com pelo menos 5 caracteres."
}
}{
"error": {
"type": "rate_limited",
"message": "Limite de 30 alterações por minuto atingido."
}
}Webhooks
Cadastrar webhook
Cadastra um webhook: a cada evento escolhido a Velan faz POST com o JSON do pedido em url. A URL precisa ser https, pública, na porta 443 e sem usuário e senha. Escolha os produtos com product_codes ou envie all_products: true. Com secret, cada envio sai assinado no cabeçalho X-Velan-Signature (sha256= + HMAC do corpo); o segredo não volta em nenhuma resposta (signed: true). Depois, confira com POST /webhooks/{webhook_id}/test.
Permissão: write:webhooks ou write. Idempotency-Key: obrigatório. Prévia: não tem; a chamada executa.
POST
/
webhooks
curl
curl -X POST 'https://api.velan.app/v1/developer/webhooks' \
-H 'Authorization: Bearer $VELAN_KEY' \
-H 'Idempotency-Key: webhook-erp-producao' \
-H 'Content-Type: application/json' \
-d '{"all_products": true, "events": ["order.paid", "order.refunded"], "name": "ERP", "secret": "um-segredo-longo-e-aleatorio", "url": "https://erp.exemplo.com/velan"}'import requests
url = "https://api.velan.app/v1/developer/webhooks"
payload = {
"all_products": True,
"events": ["order.paid", "order.refunded"],
"name": "ERP",
"secret": "um-segredo-longo-e-aleatorio",
"url": "https://erp.exemplo.com/velan"
}
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({
all_products: true,
events: ['order.paid', 'order.refunded'],
name: 'ERP',
secret: 'um-segredo-longo-e-aleatorio',
url: 'https://erp.exemplo.com/velan'
})
};
fetch('https://api.velan.app/v1/developer/webhooks', 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.velan.app/v1/developer/webhooks",
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([
'all_products' => true,
'events' => [
'order.paid',
'order.refunded'
],
'name' => 'ERP',
'secret' => 'um-segredo-longo-e-aleatorio',
'url' => 'https://erp.exemplo.com/velan'
]),
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.velan.app/v1/developer/webhooks"
payload := strings.NewReader("{\n \"all_products\": true,\n \"events\": [\n \"order.paid\",\n \"order.refunded\"\n ],\n \"name\": \"ERP\",\n \"secret\": \"um-segredo-longo-e-aleatorio\",\n \"url\": \"https://erp.exemplo.com/velan\"\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://api.velan.app/v1/developer/webhooks")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"all_products\": true,\n \"events\": [\n \"order.paid\",\n \"order.refunded\"\n ],\n \"name\": \"ERP\",\n \"secret\": \"um-segredo-longo-e-aleatorio\",\n \"url\": \"https://erp.exemplo.com/velan\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.velan.app/v1/developer/webhooks")
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 \"all_products\": true,\n \"events\": [\n \"order.paid\",\n \"order.refunded\"\n ],\n \"name\": \"ERP\",\n \"secret\": \"um-segredo-longo-e-aleatorio\",\n \"url\": \"https://erp.exemplo.com/velan\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"created": true,
"integration": {
"all_products": true,
"auth": null,
"category": "webhook",
"destination": "https://erp.exemplo.com/…",
"disabled_reason": null,
"events": [
"order.paid",
"order.refunded"
],
"failure_count": 0,
"id": 1,
"is_active": true,
"label": "Webhook",
"last_failure_at": null,
"products": [],
"signed": true,
"title": "ERP",
"type": "webhook"
}
}
}{
"error": {
"type": "validation_error",
"message": "Campos não aceitos nesta rota.",
"fields": {
"confirmm": "Campo desconhecido."
}
}
}{
"error": {
"type": "authentication_error",
"message": "Envie Authorization: Bearer <chave de API>."
}
}{
"error": {
"type": "permission_error",
"message": "Esta chave não tem permissão de escrita em 'webhooks'. Crie uma chave com essa permissão."
}
}{
"error": {
"type": "not_found",
"message": "Assinatura não encontrada."
}
}{
"error": {
"type": "conflict",
"message": "Idempotency-Key já usada com outra requisição. Gere uma chave nova para uma operação nova."
}
}{
"error": {
"type": "unprocessable",
"message": "Descreva o motivo com pelo menos 5 caracteres."
}
}{
"error": {
"type": "rate_limited",
"message": "Limite de 30 alterações por minuto atingido."
}
}Authorizations
Headers
Body
application/json
