列出账户 webhooks
GET /api/webhooks
GET https://api.avista.global/api/webhooks需要在 Authorization 头中提供 Bearer token。请参阅 生成令牌 获取。
返回已认证账户配置的所有 webhooks。
认证
需要在 Authorization 头中提供 Bearer 令牌。
代码示例
curl -X GET "https://api.avista.global/api/webhooks" \
-H "Authorization: Bearer $AVISTA_TOKEN"const axios = require('axios');
const response = await axios.get('https://api.avista.global/api/webhooks', {
headers: { 'Authorization': `Bearer ${process.env.AVISTA_TOKEN}` },
});
console.log(response.data);import os, requests
response = requests.get(
'https://api.avista.global/api/webhooks',
headers={'Authorization': f'Bearer {os.environ["AVISTA_TOKEN"]}'},
)
print(response.json())$ch = curl_init('https://api.avista.global/api/webhooks');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('AVISTA_TOKEN'),
],
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.avista.global/api/webhooks"))
.header("Authorization", "Bearer " + System.getenv("AVISTA_TOKEN"))
.GET()
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());响应 (200)
| 字段 | 类型 | 描述 |
|---|---|---|
accountId | number | 账户 ID |
webhooks | array | 已配置的 webhooks 列表 |
webhooks[].id | number | Webhook 唯一标识符 |
webhooks[].type | string | 事件类型:cash_in、cash_out、refund_in、refund_out、med_created、med_accepted、med_rejected |
webhooks[].url | string | 已配置的端点 URL |
webhooks[].headers | object | 自定义请求头(键值对) |
webhooks[].isActive | boolean | 表示 webhook 是否处于活动状态 |
webhooks[].createdAt | string | 创建日期(ISO 8601) |
total | number | 已配置的 webhooks 总数 |
{
"accountId": 93,
"webhooks": [
{
"id": 1,
"type": "cash_in",
"url": "https://api.example.com/webhooks/pix",
"headers": {
"Authorization": "Bearer token123"
},
"isActive": true,
"createdAt": "2025-01-09T12:00:00.000Z"
}
],
"total": 4
}错误
| 状态码 | 描述 |
|---|---|
| 401 | 令牌缺失或无效 |
| 404 | 账户未找到 |