Criar webhook
curl --request POST \
--url https://api.nasten.net/v1/webhook \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "https://seusite.com.br/webhooks/nasten",
"events": [
"transaction_created",
"transaction_paid",
"transaction_refunded",
"transaction_updated",
"transfer_completed"
],
"name": "Webhook principal",
"isActive": true,
"productIds": [
"<string>"
],
"productId": "<string>"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: 'https://seusite.com.br/webhooks/nasten',
events: [
'transaction_created',
'transaction_paid',
'transaction_refunded',
'transaction_updated',
'transfer_completed'
],
name: 'Webhook principal',
isActive: true,
productIds: ['<string>'],
productId: '<string>'
})
};
fetch('https://api.nasten.net/v1/webhook', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.nasten.net/v1/webhook"
payload = {
"url": "https://seusite.com.br/webhooks/nasten",
"events": ["transaction_created", "transaction_paid", "transaction_refunded", "transaction_updated", "transfer_completed"],
"name": "Webhook principal",
"isActive": True,
"productIds": ["<string>"],
"productId": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.nasten.net/v1/webhook",
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://seusite.com.br/webhooks/nasten',
'events' => [
'transaction_created',
'transaction_paid',
'transaction_refunded',
'transaction_updated',
'transfer_completed'
],
'name' => 'Webhook principal',
'isActive' => true,
'productIds' => [
'<string>'
],
'productId' => '<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://api.nasten.net/v1/webhook"
payload := strings.NewReader("{\n \"url\": \"https://seusite.com.br/webhooks/nasten\",\n \"events\": [\n \"transaction_created\",\n \"transaction_paid\",\n \"transaction_refunded\",\n \"transaction_updated\",\n \"transfer_completed\"\n ],\n \"name\": \"Webhook principal\",\n \"isActive\": true,\n \"productIds\": [\n \"<string>\"\n ],\n \"productId\": \"<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://api.nasten.net/v1/webhook")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://seusite.com.br/webhooks/nasten\",\n \"events\": [\n \"transaction_created\",\n \"transaction_paid\",\n \"transaction_refunded\",\n \"transaction_updated\",\n \"transfer_completed\"\n ],\n \"name\": \"Webhook principal\",\n \"isActive\": true,\n \"productIds\": [\n \"<string>\"\n ],\n \"productId\": \"<string>\"\n}")
.asString();{
"success": true,
"data": {
"id": 42,
"name": "Webhook principal",
"isActive": true,
"signatureSecret": "<string>",
"mtlsCapable": true,
"url": "https://seusite.com.br/webhooks/nasten",
"events": [
"transaction_created"
],
"productIds": [
"<string>"
],
"productId": "<string>",
"createdAt": "2023-11-07T05:31:56Z"
}
}{
"success": false,
"message": "Descrição do erro",
"code": "NST-400-3f7a",
"errors": [
{
"path": "customer.document",
"message": "Documento inválido"
}
]
}{
"success": false,
"message": "Token inválido ou expirado",
"code": "NST-401-rcp9"
}{
"success": false,
"message": "Descrição do erro",
"code": "NST-400-3f7a"
}{
"success": false,
"message": "Descrição do erro",
"code": "NST-400-3f7a"
}{
"success": false,
"message": "Descrição do erro",
"code": "NST-400-3f7a",
"error": "Too Many Requests",
"retryAfterMs": 42000,
"limit": 1800,
"window": "1 minute"
}{
"success": false,
"message": "Internal server error",
"code": "NST-500-9e2b"
}Webhooks
Criar webhook
Antes de gravar, a Nasten envia um POST de teste com o corpo {"test": true}, sem assinatura.
A URL precisa responder 2xx. Até 5 webhooks por empresa, contando os desligados.
Não há rota de edição: remova e crie de novo, ou edite pelo painel.
POST
/
v1
/
webhook
Criar webhook
curl --request POST \
--url https://api.nasten.net/v1/webhook \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "https://seusite.com.br/webhooks/nasten",
"events": [
"transaction_created",
"transaction_paid",
"transaction_refunded",
"transaction_updated",
"transfer_completed"
],
"name": "Webhook principal",
"isActive": true,
"productIds": [
"<string>"
],
"productId": "<string>"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: 'https://seusite.com.br/webhooks/nasten',
events: [
'transaction_created',
'transaction_paid',
'transaction_refunded',
'transaction_updated',
'transfer_completed'
],
name: 'Webhook principal',
isActive: true,
productIds: ['<string>'],
productId: '<string>'
})
};
fetch('https://api.nasten.net/v1/webhook', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.nasten.net/v1/webhook"
payload = {
"url": "https://seusite.com.br/webhooks/nasten",
"events": ["transaction_created", "transaction_paid", "transaction_refunded", "transaction_updated", "transfer_completed"],
"name": "Webhook principal",
"isActive": True,
"productIds": ["<string>"],
"productId": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.nasten.net/v1/webhook",
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://seusite.com.br/webhooks/nasten',
'events' => [
'transaction_created',
'transaction_paid',
'transaction_refunded',
'transaction_updated',
'transfer_completed'
],
'name' => 'Webhook principal',
'isActive' => true,
'productIds' => [
'<string>'
],
'productId' => '<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://api.nasten.net/v1/webhook"
payload := strings.NewReader("{\n \"url\": \"https://seusite.com.br/webhooks/nasten\",\n \"events\": [\n \"transaction_created\",\n \"transaction_paid\",\n \"transaction_refunded\",\n \"transaction_updated\",\n \"transfer_completed\"\n ],\n \"name\": \"Webhook principal\",\n \"isActive\": true,\n \"productIds\": [\n \"<string>\"\n ],\n \"productId\": \"<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://api.nasten.net/v1/webhook")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://seusite.com.br/webhooks/nasten\",\n \"events\": [\n \"transaction_created\",\n \"transaction_paid\",\n \"transaction_refunded\",\n \"transaction_updated\",\n \"transfer_completed\"\n ],\n \"name\": \"Webhook principal\",\n \"isActive\": true,\n \"productIds\": [\n \"<string>\"\n ],\n \"productId\": \"<string>\"\n}")
.asString();{
"success": true,
"data": {
"id": 42,
"name": "Webhook principal",
"isActive": true,
"signatureSecret": "<string>",
"mtlsCapable": true,
"url": "https://seusite.com.br/webhooks/nasten",
"events": [
"transaction_created"
],
"productIds": [
"<string>"
],
"productId": "<string>",
"createdAt": "2023-11-07T05:31:56Z"
}
}{
"success": false,
"message": "Descrição do erro",
"code": "NST-400-3f7a",
"errors": [
{
"path": "customer.document",
"message": "Documento inválido"
}
]
}{
"success": false,
"message": "Token inválido ou expirado",
"code": "NST-401-rcp9"
}{
"success": false,
"message": "Descrição do erro",
"code": "NST-400-3f7a"
}{
"success": false,
"message": "Descrição do erro",
"code": "NST-400-3f7a"
}{
"success": false,
"message": "Descrição do erro",
"code": "NST-400-3f7a",
"error": "Too Many Requests",
"retryAfterMs": 42000,
"limit": 1800,
"window": "1 minute"
}{
"success": false,
"message": "Internal server error",
"code": "NST-500-9e2b"
}Body
application/json
Eventos assinados, ao menos um
Minimum array length:
1Available options:
transaction_created, transaction_paid, transaction_refunded, transaction_updated, transfer_created, transfer_completed, transfer_canceled, transfer_updated, infraction, card_declined, sale_lost, cart_abandoned, product_canceled Example:
[
"transaction_created",
"transaction_paid",
"transaction_refunded",
"transaction_updated",
"transfer_completed"
]

