Webhooks
创建 Webhook
注册回调 URL,以接收订单、资金活动、全球支付、稳定币支付或加密货币提现的实时事件通知。
POST
/
v2
/
webhook
创建 Webhook
curl --request POST \
--url https://api-test.velafi.com/v2/webhook \
--header 'Content-Type: application/json' \
--header 'X-BH-TOKEN: <api-key>' \
--data '
{
"eventType": "<string>",
"url": "<string>"
}
'import requests
url = "https://api-test.velafi.com/v2/webhook"
payload = {
"eventType": "<string>",
"url": "<string>"
}
headers = {
"X-BH-TOKEN": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-BH-TOKEN': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({eventType: '<string>', url: '<string>'})
};
fetch('https://api-test.velafi.com/v2/webhook', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.post("https://api-test.velafi.com/v2/webhook")
.header("X-BH-TOKEN", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"eventType\": \"<string>\",\n \"url\": \"<string>\"\n}")
.asString();{
"code": 123,
"msg": "<string>",
"data": {
"webhookId": "<string>",
"eventType": "<string>",
"url": "<string>",
"status": 123,
"publicKey": "<string>"
}
}使用此端点注册一个 Webhook URL,当特定事件类型发生时,VelaFi 将调用该 URL。每次注册仅对应一种事件类型,因此请为每个需要接收的事件分别创建 Webhook。如果该事件类型已存在一个活跃的 Webhook,请求将被拒绝。Webhook 归属于您的账户,因此一个 Webhook 会接收账户下所有商户的对应事件。响应中包含一个您必须保存的
publicKey——它用于验证此端点后续所有 Webhook 推送上的 RSA-SHA256 签名。
所有请求都必须包含
X-BH-TOKEN 请求头和 Content-Type: application/json。请安全保存响应中的 publicKey。它也会由列出 Webhook 返回。端点
POST https://api.velafi.com/v2/webhook
请求参数
string
必填
此 Webhook 应接收的事件类型。可接受的值:
ORDER_WEBHOOK— 法币/加密货币订单状态变更GLOBAL_PAYMENT_WEBHOOK— 法币/法币全球支付状态变更FUNDING_WEBHOOK— 待处理资金(Pending Fund)账户活动ON_RAMP_WITHDRAW_WEBHOOK— 已完成的 API 入金订单向目标钱包的加密货币提现成功STABLE_COIN_PAYMENT_WEBHOOK— 稳定币支付订单已确认CRYPTO_WITHDRAW_WEBHOOK— 商户钱包的加密货币提现成功、失败或被取消
string
必填
VelaFi 将向其 POST 事件通知的可公开访问的 URL。必须以
http 开头。请使用 https:// URL。响应字段
number
HTTP 风格的响应码。
200 表示成功。string
人类可读的状态消息,例如
SUCCESS。object
示例
cURL
curl -X POST https://api.velafi.com/v2/webhook \
-H "X-BH-TOKEN: YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"eventType": "ORDER_WEBHOOK",
"url": "https://your-app.com/webhooks/velafi"
}'
Response
{
"code": 200,
"msg": "SUCCESS",
"data": {
"webhookId": "ebab8a9663704e7cbbebe672c7c67912",
"eventType": "ORDER_WEBHOOK",
"url": "https://your-app.com/webhooks/velafi",
"status": 10,
"publicKey": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp/6GRTIrl+kQb9u27cGz..."
}
}
如果您丢失了
publicKey,可以通过列出 Webhook 重新获取。有关如何使用公钥验证传入请求,请参阅 Webhook 设置。⌘I
创建 Webhook
curl --request POST \
--url https://api-test.velafi.com/v2/webhook \
--header 'Content-Type: application/json' \
--header 'X-BH-TOKEN: <api-key>' \
--data '
{
"eventType": "<string>",
"url": "<string>"
}
'import requests
url = "https://api-test.velafi.com/v2/webhook"
payload = {
"eventType": "<string>",
"url": "<string>"
}
headers = {
"X-BH-TOKEN": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-BH-TOKEN': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({eventType: '<string>', url: '<string>'})
};
fetch('https://api-test.velafi.com/v2/webhook', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.post("https://api-test.velafi.com/v2/webhook")
.header("X-BH-TOKEN", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"eventType\": \"<string>\",\n \"url\": \"<string>\"\n}")
.asString();{
"code": 123,
"msg": "<string>",
"data": {
"webhookId": "<string>",
"eventType": "<string>",
"url": "<string>",
"status": 123,
"publicKey": "<string>"
}
}
