Webhook
Đăng ký webhook outbound có chữ ký HMAC. · 8 endpoint
- GET/webhooks
- POST/webhooks
- GET/webhooks/{id}
- PATCH/webhooks/{id}
- DELETE/webhooks/{id}
- POST/webhooks/{id}/test
- GET/webhooks/{id}/deliveries
- POST/webhook-deliveries/{id}/retry
Webhook của key này
GET
/api/v1/webhooksScope: webhooks:manageLệnh mẫu
bash
curl "http://127.0.0.1:9900/api/v1/webhooks" \
-H "Authorization: Bearer dpk_xxx"Đăng ký webhook (trả secret một lần)
POST
/api/v1/webhooksScope: webhooks:manageDeplao POST sự kiện tới url kèm chữ ký X-Deplao-Signature: v1=<HMAC-SHA256(secret, timestamp + "." + body)>. Xem hướng dẫn "Webhook".
URL trong mạng nội bộ (localhost, 192.168.x, 10.x) chỉ được phép khi gọi từ chính máy chạy Deplao (không qua tunnel), hoặc khi bật cài đặt api_allow_private_urls.
Body (JSON)
nametuỳ chọn | string max 100 · default "" | |
urlbắt buộc | string (uri) max 2000 | |
eventstuỳ chọn | string[] max 50 items · default ["*"] | |
account_idstuỳ chọn | string[] max 200 items | |
secrettuỳ chọn | string max 200 | Bỏ trống = Deplao tự sinh |
Lệnh mẫu
bash
curl -X POST "http://127.0.0.1:9900/api/v1/webhooks" \
-H "Authorization: Bearer dpk_xxx" \
-H "Content-Type: application/json" \
-d '{"name":"CRM sync","url":"https://crm.example.com/deplao","events":["message.received","friend.request.received"]}'Một webhook
GET
/api/v1/webhooks/{id}Scope: webhooks:manageTham số
idpath · bắt buộc | string max 200 |
Lệnh mẫu
bash
curl "http://127.0.0.1:9900/api/v1/webhooks/{id}" \
-H "Authorization: Bearer dpk_xxx"Sửa webhook / bật lại sau khi tự tắt
PATCH
/api/v1/webhooks/{id}Scope: webhooks:manageTham số
idpath · bắt buộc | string max 200 |
Body (JSON)
nametuỳ chọn | string max 100 | |
urltuỳ chọn | string (uri) max 2000 | |
eventstuỳ chọn | string[] max 50 items | |
account_idstuỳ chọn | array | null max 200 items | |
activetuỳ chọn | boolean |
Lệnh mẫu
bash
curl -X PATCH "http://127.0.0.1:9900/api/v1/webhooks/{id}" \
-H "Authorization: Bearer dpk_xxx" \
-H "Content-Type: application/json" \
-d '{"name":"string","url":"https://example.com/file.jpg","events":[]}'Xoá webhook
DELETE
/api/v1/webhooks/{id}Scope: webhooks:manageTham số
idpath · bắt buộc | string max 200 |
Lệnh mẫu
bash
curl -X DELETE "http://127.0.0.1:9900/api/v1/webhooks/{id}" \
-H "Authorization: Bearer dpk_xxx"Gửi thử sự kiện "ping" ngay
POST
/api/v1/webhooks/{id}/testScope: webhooks:manageTham số
idpath · bắt buộc | string max 200 |
Lệnh mẫu
bash
curl -X POST "http://127.0.0.1:9900/api/v1/webhooks/{id}/test" \
-H "Authorization: Bearer dpk_xxx"Lịch sử gửi gần nhất (mặc định 100, tối đa 500)
GET
/api/v1/webhooks/{id}/deliveriesScope: webhooks:manageTham số
idpath · bắt buộc | string max 200 | |
statusquery · tuỳ chọn | "pending" | "delivered" | "failed" | |
limitquery · tuỳ chọn | integer ≥ 1 · ≤ 500 · default 100 |
Lệnh mẫu
bash
curl "http://127.0.0.1:9900/api/v1/webhooks/{id}/deliveries" \
-H "Authorization: Bearer dpk_xxx"Gửi lại một lần gửi lỗi
POST
/api/v1/webhook-deliveries/{id}/retryScope: webhooks:manageTham số
idpath · bắt buộc | string max 200 |
Lệnh mẫu
bash
curl -X POST "http://127.0.0.1:9900/api/v1/webhook-deliveries/{id}/retry" \
-H "Authorization: Bearer dpk_xxx"