Bỏ qua tới nội dung

Webhook

Đăng ký webhook outbound có chữ ký HMAC. · 8 endpoint

Webhook của key này

GET/api/v1/webhooksScope: webhooks:manage

Lệ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:manage

Deplao 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)

name
tuỳ chọn
string
max 100 · default ""
url
bắt buộc
string (uri)
max 2000
events
tuỳ chọn
string[]
max 50 items · default ["*"]
account_ids
tuỳ chọn
string[]
max 200 items
secret
tuỳ 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:manage

Tham số

id
path · 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:manage

Tham số

id
path · bắt buộc
string
max 200

Body (JSON)

name
tuỳ chọn
string
max 100
url
tuỳ chọn
string (uri)
max 2000
events
tuỳ chọn
string[]
max 50 items
account_ids
tuỳ chọn
array | null
max 200 items
active
tuỳ 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:manage

Tham số

id
path · 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:manage

Tham số

id
path · 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:manage

Tham số

id
path · bắt buộc
string
max 200
status
query · tuỳ chọn
"pending" | "delivered" | "failed"
limit
query · 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:manage

Tham số

id
path · 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"