Registrar webhook
curl --request POST \
--url https://api.speedsellx.io/v2/public/webhooks \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"url": "<string>",
"token": "<string>",
"product_id": 123,
"order_payment_approved": true,
"order_payment_pending": true,
"order_payment_failed": true,
"order_payment_refunded": true,
"order_subscription_approved": true,
"order_subscription_pending": true,
"order_subscription_failed": true,
"order_subscription_refunded": true,
"order_subscription_canceled": true,
"order_subscription_trial_started": true,
"active": true
}
'import requests
url = "https://api.speedsellx.io/v2/public/webhooks"
payload = {
"url": "<string>",
"token": "<string>",
"product_id": 123,
"order_payment_approved": True,
"order_payment_pending": True,
"order_payment_failed": True,
"order_payment_refunded": True,
"order_subscription_approved": True,
"order_subscription_pending": True,
"order_subscription_failed": True,
"order_subscription_refunded": True,
"order_subscription_canceled": True,
"order_subscription_trial_started": True,
"active": True
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
url: '<string>',
token: '<string>',
product_id: 123,
order_payment_approved: true,
order_payment_pending: true,
order_payment_failed: true,
order_payment_refunded: true,
order_subscription_approved: true,
order_subscription_pending: true,
order_subscription_failed: true,
order_subscription_refunded: true,
order_subscription_canceled: true,
order_subscription_trial_started: true,
active: true
})
};
fetch('https://api.speedsellx.io/v2/public/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.speedsellx.io/v2/public/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([
'url' => '<string>',
'token' => '<string>',
'product_id' => 123,
'order_payment_approved' => true,
'order_payment_pending' => true,
'order_payment_failed' => true,
'order_payment_refunded' => true,
'order_subscription_approved' => true,
'order_subscription_pending' => true,
'order_subscription_failed' => true,
'order_subscription_refunded' => true,
'order_subscription_canceled' => true,
'order_subscription_trial_started' => true,
'active' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>"
],
]);
$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.speedsellx.io/v2/public/webhooks"
payload := strings.NewReader("{\n \"url\": \"<string>\",\n \"token\": \"<string>\",\n \"product_id\": 123,\n \"order_payment_approved\": true,\n \"order_payment_pending\": true,\n \"order_payment_failed\": true,\n \"order_payment_refunded\": true,\n \"order_subscription_approved\": true,\n \"order_subscription_pending\": true,\n \"order_subscription_failed\": true,\n \"order_subscription_refunded\": true,\n \"order_subscription_canceled\": true,\n \"order_subscription_trial_started\": true,\n \"active\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
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.speedsellx.io/v2/public/webhooks")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"<string>\",\n \"token\": \"<string>\",\n \"product_id\": 123,\n \"order_payment_approved\": true,\n \"order_payment_pending\": true,\n \"order_payment_failed\": true,\n \"order_payment_refunded\": true,\n \"order_subscription_approved\": true,\n \"order_subscription_pending\": true,\n \"order_subscription_failed\": true,\n \"order_subscription_refunded\": true,\n \"order_subscription_canceled\": true,\n \"order_subscription_trial_started\": true,\n \"active\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.speedsellx.io/v2/public/webhooks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"<string>\",\n \"token\": \"<string>\",\n \"product_id\": 123,\n \"order_payment_approved\": true,\n \"order_payment_pending\": true,\n \"order_payment_failed\": true,\n \"order_payment_refunded\": true,\n \"order_subscription_approved\": true,\n \"order_subscription_pending\": true,\n \"order_subscription_failed\": true,\n \"order_subscription_refunded\": true,\n \"order_subscription_canceled\": true,\n \"order_subscription_trial_started\": true,\n \"active\": true\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": 123,
"user_id": 123,
"url": "<string>",
"token": "<string>",
"product_id": 123,
"active": true,
"order_payment_approved": true,
"order_payment_pending": true,
"order_payment_failed": true,
"order_payment_refunded": true,
"order_subscription_approved": true,
"order_subscription_pending": true,
"order_subscription_failed": true,
"order_subscription_refunded": true,
"order_subscription_canceled": true,
"order_subscription_trial_started": true,
"created_at": "<string>",
"updated_at": "<string>"
}
}{
"status": "error",
"error": "unauthenticated"
}{
"status": "error",
"error": "insufficient_scope"
}{
"status": "error",
"error": "idempotency_in_progress"
}{
"message": "<string>",
"errors": {}
}Webhooks
Registrar webhook
Registra um destino de webhook
POST
/
public
/
webhooks
Registrar webhook
curl --request POST \
--url https://api.speedsellx.io/v2/public/webhooks \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"url": "<string>",
"token": "<string>",
"product_id": 123,
"order_payment_approved": true,
"order_payment_pending": true,
"order_payment_failed": true,
"order_payment_refunded": true,
"order_subscription_approved": true,
"order_subscription_pending": true,
"order_subscription_failed": true,
"order_subscription_refunded": true,
"order_subscription_canceled": true,
"order_subscription_trial_started": true,
"active": true
}
'import requests
url = "https://api.speedsellx.io/v2/public/webhooks"
payload = {
"url": "<string>",
"token": "<string>",
"product_id": 123,
"order_payment_approved": True,
"order_payment_pending": True,
"order_payment_failed": True,
"order_payment_refunded": True,
"order_subscription_approved": True,
"order_subscription_pending": True,
"order_subscription_failed": True,
"order_subscription_refunded": True,
"order_subscription_canceled": True,
"order_subscription_trial_started": True,
"active": True
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
url: '<string>',
token: '<string>',
product_id: 123,
order_payment_approved: true,
order_payment_pending: true,
order_payment_failed: true,
order_payment_refunded: true,
order_subscription_approved: true,
order_subscription_pending: true,
order_subscription_failed: true,
order_subscription_refunded: true,
order_subscription_canceled: true,
order_subscription_trial_started: true,
active: true
})
};
fetch('https://api.speedsellx.io/v2/public/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.speedsellx.io/v2/public/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([
'url' => '<string>',
'token' => '<string>',
'product_id' => 123,
'order_payment_approved' => true,
'order_payment_pending' => true,
'order_payment_failed' => true,
'order_payment_refunded' => true,
'order_subscription_approved' => true,
'order_subscription_pending' => true,
'order_subscription_failed' => true,
'order_subscription_refunded' => true,
'order_subscription_canceled' => true,
'order_subscription_trial_started' => true,
'active' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>"
],
]);
$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.speedsellx.io/v2/public/webhooks"
payload := strings.NewReader("{\n \"url\": \"<string>\",\n \"token\": \"<string>\",\n \"product_id\": 123,\n \"order_payment_approved\": true,\n \"order_payment_pending\": true,\n \"order_payment_failed\": true,\n \"order_payment_refunded\": true,\n \"order_subscription_approved\": true,\n \"order_subscription_pending\": true,\n \"order_subscription_failed\": true,\n \"order_subscription_refunded\": true,\n \"order_subscription_canceled\": true,\n \"order_subscription_trial_started\": true,\n \"active\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
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.speedsellx.io/v2/public/webhooks")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"<string>\",\n \"token\": \"<string>\",\n \"product_id\": 123,\n \"order_payment_approved\": true,\n \"order_payment_pending\": true,\n \"order_payment_failed\": true,\n \"order_payment_refunded\": true,\n \"order_subscription_approved\": true,\n \"order_subscription_pending\": true,\n \"order_subscription_failed\": true,\n \"order_subscription_refunded\": true,\n \"order_subscription_canceled\": true,\n \"order_subscription_trial_started\": true,\n \"active\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.speedsellx.io/v2/public/webhooks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"<string>\",\n \"token\": \"<string>\",\n \"product_id\": 123,\n \"order_payment_approved\": true,\n \"order_payment_pending\": true,\n \"order_payment_failed\": true,\n \"order_payment_refunded\": true,\n \"order_subscription_approved\": true,\n \"order_subscription_pending\": true,\n \"order_subscription_failed\": true,\n \"order_subscription_refunded\": true,\n \"order_subscription_canceled\": true,\n \"order_subscription_trial_started\": true,\n \"active\": true\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": 123,
"user_id": 123,
"url": "<string>",
"token": "<string>",
"product_id": 123,
"active": true,
"order_payment_approved": true,
"order_payment_pending": true,
"order_payment_failed": true,
"order_payment_refunded": true,
"order_subscription_approved": true,
"order_subscription_pending": true,
"order_subscription_failed": true,
"order_subscription_refunded": true,
"order_subscription_canceled": true,
"order_subscription_trial_started": true,
"created_at": "<string>",
"updated_at": "<string>"
}
}{
"status": "error",
"error": "unauthenticated"
}{
"status": "error",
"error": "insufficient_scope"
}{
"status": "error",
"error": "idempotency_in_progress"
}{
"message": "<string>",
"errors": {}
}Requer o escopo
Os eventos são um booleano cada, no primeiro nível do corpo:
webhooks:create e o header HTTP Idempotency-Key. Responde 201.
string
required
O destino das entregas.
string | null
O segredo com que você confere que a entrega veio da SpeedSellX.
integer | null
Restringe as entregas a um produto.
null significa todos os produtos da conta.boolean
Registra a assinatura já muda. Esta é a única escrita que lê
active: depois disso, ligar e desligar é com o toggle.| Evento | Quando dispara |
|---|---|
order_payment_approved | Pagamento avulso aprovado |
order_payment_pending | Pagamento avulso pendente |
order_payment_failed | Pagamento avulso recusado |
order_payment_refunded | Pagamento avulso reembolsado |
order_subscription_approved | Cobrança de assinatura aprovada |
order_subscription_pending | Cobrança de assinatura pendente |
order_subscription_failed | Cobrança de assinatura recusada |
order_subscription_refunded | Cobrança de assinatura reembolsada |
order_subscription_canceled | Assinatura cancelada |
order_subscription_trial_started | Período de teste iniciado |
order_subscription_trial_started é novo: a API antiga tinha nove eventos, esta tem dez.Authorizations
A chave de API da conta, no formato sk_{modo}_{prefixo}.{segredo}.
Headers
Chave única da operação. Obrigatória em toda requisição que altera dados; sem ela a resposta é 422 idempotency_key_required. Um reenvio com a mesma chave e o mesmo corpo repete a resposta guardada.
Maximum string length:
255Body
application/json
Body of POST /v2/public/webhooks. Registration is the one write that reads
active, so a caller can register a subscription muted; afterwards it flips
through the toggle endpoint alone.
Maximum string length:
2048Maximum string length:
255Response
ApiWebhookResource
Show child attributes
Show child attributes
⌘I