Create Webhook
curl --request POST \
--url https://api.agentwallex.com/api/v1/webhooks \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"url": "https://your-app.com/webhooks/agentwallex",
"events": [
"payment.completed",
"payment.failed",
"policy.violated"
],
"secret": "whsec_your_signing_secret"
}
'import requests
url = "https://api.agentwallex.com/api/v1/webhooks"
payload = {
"url": "https://your-app.com/webhooks/agentwallex",
"events": ["payment.completed", "payment.failed", "policy.violated"],
"secret": "whsec_your_signing_secret"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: 'https://your-app.com/webhooks/agentwallex',
events: ['payment.completed', 'payment.failed', 'policy.violated'],
secret: 'whsec_your_signing_secret'
})
};
fetch('https://api.agentwallex.com/api/v1/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.agentwallex.com/api/v1/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' => 'https://your-app.com/webhooks/agentwallex',
'events' => [
'payment.completed',
'payment.failed',
'policy.violated'
],
'secret' => 'whsec_your_signing_secret'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-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.agentwallex.com/api/v1/webhooks"
payload := strings.NewReader("{\n \"url\": \"https://your-app.com/webhooks/agentwallex\",\n \"events\": [\n \"payment.completed\",\n \"payment.failed\",\n \"policy.violated\"\n ],\n \"secret\": \"whsec_your_signing_secret\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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.agentwallex.com/api/v1/webhooks")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://your-app.com/webhooks/agentwallex\",\n \"events\": [\n \"payment.completed\",\n \"payment.failed\",\n \"policy.violated\"\n ],\n \"secret\": \"whsec_your_signing_secret\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.agentwallex.com/api/v1/webhooks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"https://your-app.com/webhooks/agentwallex\",\n \"events\": [\n \"payment.completed\",\n \"payment.failed\",\n \"policy.violated\"\n ],\n \"secret\": \"whsec_your_signing_secret\"\n}"
response = http.request(request)
puts response.read_body{
"id": "whk_abc123",
"url": "https://your-app.com/webhooks/agentwallex",
"events": [
"payment.completed",
"payment.failed",
"policy.violated"
],
"status": "active",
"created_at": "2025-06-01T10:00:00Z"
}{
"code": "invalid_request",
"type": "invalid_request_error",
"message": "The request body is missing required fields."
}{
"code": "authentication_failed",
"type": "authentication_error",
"message": "The provided API key is invalid or expired."
}{
"code": "insufficient_permissions",
"type": "authorization_error",
"message": "You do not have permission to perform this action."
}{
"code": "rate_limit_exceeded",
"type": "rate_limit_error",
"message": "Too many requests. Please retry after a short delay."
}{
"code": "server_error",
"type": "internal_error",
"message": "An unexpected error occurred. Please try again later."
}Webhook
Tạo Webhook
Đăng ký endpoint Webhook mới để nhận thông báo sự kiện theo thời gian thực.
POST
/
api
/
v1
/
webhooks
Create Webhook
curl --request POST \
--url https://api.agentwallex.com/api/v1/webhooks \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"url": "https://your-app.com/webhooks/agentwallex",
"events": [
"payment.completed",
"payment.failed",
"policy.violated"
],
"secret": "whsec_your_signing_secret"
}
'import requests
url = "https://api.agentwallex.com/api/v1/webhooks"
payload = {
"url": "https://your-app.com/webhooks/agentwallex",
"events": ["payment.completed", "payment.failed", "policy.violated"],
"secret": "whsec_your_signing_secret"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: 'https://your-app.com/webhooks/agentwallex',
events: ['payment.completed', 'payment.failed', 'policy.violated'],
secret: 'whsec_your_signing_secret'
})
};
fetch('https://api.agentwallex.com/api/v1/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.agentwallex.com/api/v1/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' => 'https://your-app.com/webhooks/agentwallex',
'events' => [
'payment.completed',
'payment.failed',
'policy.violated'
],
'secret' => 'whsec_your_signing_secret'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-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.agentwallex.com/api/v1/webhooks"
payload := strings.NewReader("{\n \"url\": \"https://your-app.com/webhooks/agentwallex\",\n \"events\": [\n \"payment.completed\",\n \"payment.failed\",\n \"policy.violated\"\n ],\n \"secret\": \"whsec_your_signing_secret\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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.agentwallex.com/api/v1/webhooks")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://your-app.com/webhooks/agentwallex\",\n \"events\": [\n \"payment.completed\",\n \"payment.failed\",\n \"policy.violated\"\n ],\n \"secret\": \"whsec_your_signing_secret\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.agentwallex.com/api/v1/webhooks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"https://your-app.com/webhooks/agentwallex\",\n \"events\": [\n \"payment.completed\",\n \"payment.failed\",\n \"policy.violated\"\n ],\n \"secret\": \"whsec_your_signing_secret\"\n}"
response = http.request(request)
puts response.read_body{
"id": "whk_abc123",
"url": "https://your-app.com/webhooks/agentwallex",
"events": [
"payment.completed",
"payment.failed",
"policy.violated"
],
"status": "active",
"created_at": "2025-06-01T10:00:00Z"
}{
"code": "invalid_request",
"type": "invalid_request_error",
"message": "The request body is missing required fields."
}{
"code": "authentication_failed",
"type": "authentication_error",
"message": "The provided API key is invalid or expired."
}{
"code": "insufficient_permissions",
"type": "authorization_error",
"message": "You do not have permission to perform this action."
}{
"code": "rate_limit_exceeded",
"type": "rate_limit_error",
"message": "Too many requests. Please retry after a short delay."
}{
"code": "server_error",
"type": "internal_error",
"message": "An unexpected error occurred. Please try again later."
}Đăng ký endpoint Webhook mới để nhận thông báo sự kiện theo thời gian thực qua HTTP POST.
Nội dung yêu cầu
string
bắt buộc
URL HTTPS sẽ nhận các sự kiện Webhook.
string
bắt buộc
Khóa ký để xác minh payload Webhook. Phải bắt đầu bằng
whsec_.Ví dụ
curl -X POST https://api.agentwallex.com/api/v1/webhooks \
-H "X-API-Key: awx_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"url": "https://your-app.com/webhooks/agentwallex",
"events": ["payment.completed", "payment.failed", "policy.violated"],
"secret": "whsec_your_signing_secret"
}'
Response
{
"id": "whk_abc123",
"url": "https://your-app.com/webhooks/agentwallex",
"events": ["payment.completed", "payment.failed", "policy.violated"],
"status": "active",
"created_at": "2025-06-01T10:00:00Z"
}
Ủy quyền
ApiKeyAuthBearerAuth
API key authentication. Keys are prefixed with awx_.
Nội dung
application/json
Phản hồi
Webhook created successfully.
A registered webhook endpoint for receiving real-time event notifications.
⌘I