Chuyển đến nội dung chính

Documentation Index

Fetch the complete documentation index at: https://docs.sellfern.com/llms.txt

Use this file to discover all available pages before exploring further.

API Webhooks cho phép bạn theo chương trình đăng ký và quản lý các điểm cuối HTTPS mà Sellfern gửi thông báo sự kiện đến. Tất cả các thao tác yêu cầu một token với phạm vi webhooks:manage.
Để có cái nhìn tổng quan về khái niệm webhook, các loại sự kiện, cấu trúc payload và xác minh chữ ký, xem Hướng dẫn tích hợp Webhook.

POST /api/v2/webhooks

Tạo một điểm cuối webhook mới cho tổ chức của bạn. Phạm vi yêu cầu: webhooks:manage
url
string
bắt buộc
URL HTTPS mà Sellfern sẽ POST các payload sự kiện tới. Phải có thể tiếp cận công khai.
events
array
bắt buộc
Mảng các tên sự kiện để đăng ký. Đăng ký một hoặc nhiều từ: order.created, order.updated, order.status_changed, order.fulfillment.shipped, order.fulfillment.delivered, expense.created, ticket.created, ticket.updated.
curl -X POST "https://api.sellfern.com/api/v2/webhooks" \
  -H "Authorization: Bearer sk_live_YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/webhooks/sellfern",
    "events": ["order.created", "order.status_changed"]
  }'
Phản hồi (201 Created)
{
  "success": true,
  "data": {
    "id": "wh_abc123",
    "url": "https://example.com/webhooks/sellfern",
    "events": ["order.created", "order.status_changed"],
    "secret": "whsec_...",
    "enabled": true,
    "created_at": "2026-05-22T10:00:00Z"
  }
}
Trường secret chỉ được trả về một lần khi tạo. Lưu trữ an toàn — bạn sẽ cần nó để xác minh chữ ký webhook đến.

GET /api/v2/webhooks

Liệt kê tất cả các điểm cuối webhook đã đăng ký cho tổ chức của bạn. Phạm vi yêu cầu: webhooks:manage
curl -X GET "https://api.sellfern.com/api/v2/webhooks" \
  -H "Authorization: Bearer sk_live_YOUR_TOKEN"
Phản hồi (200 OK)
{
  "success": true,
  "data": [
    {
      "id": "wh_abc123",
      "url": "https://example.com/webhooks/sellfern",
      "events": ["order.created", "order.status_changed"],
      "enabled": true,
      "created_at": "2026-05-22T10:00:00Z"
    }
  ]
}

PATCH /api/v2/webhooks/:id

Cập nhật URL, sự kiện hoặc trạng thái bật của một điểm cuối webhook hiện có. Phạm vi yêu cầu: webhooks:manage
id
string
bắt buộc
ID điểm cuối webhook được trả về khi bạn tạo điểm cuối.
url
string
URL đích mới.
events
array
Mảng sự kiện thay thế. Cái này thay thế toàn bộ danh sách sự kiện đã đăng ký.
enabled
boolean
Đặt thành false để tạm dừng việc giao mà không xóa điểm cuối.
curl -X PATCH "https://api.sellfern.com/api/v2/webhooks/wh_abc123" \
  -H "Authorization: Bearer sk_live_YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"events": ["order.status_changed", "order.fulfillment.shipped"]}'

DELETE /api/v2/webhooks/:id

Xóa một điểm cuối webhook. Việc giao đến điểm cuối này sẽ dừng ngay lập tức. Phạm vi yêu cầu: webhooks:manage
id
string
bắt buộc
ID điểm cuối webhook để xóa.
curl -X DELETE "https://api.sellfern.com/api/v2/webhooks/wh_abc123?confirm=wh_abc123" \
  -H "Authorization: Bearer sk_live_YOUR_TOKEN"

POST /api/v2/webhooks/:id/test

Gửi một sự kiện thử nghiệm tới điểm cuối để xác minh rằng nó có thể tiếp cận và handler của bạn đang hoạt động đúng. Phạm vi yêu cầu: webhooks:manage
curl -X POST "https://api.sellfern.com/api/v2/webhooks/wh_abc123/test" \
  -H "Authorization: Bearer sk_live_YOUR_TOKEN"

GET /api/v2/webhooks/:id/deliveries

Lấy các lần giao gần đây cho một điểm cuối webhook, bao gồm mã phản hồi HTTP và bất kỳ chi tiết lỗi nào. Phạm vi yêu cầu: webhooks:manage
curl -X GET "https://api.sellfern.com/api/v2/webhooks/wh_abc123/deliveries" \
  -H "Authorization: Bearer sk_live_YOUR_TOKEN"

Phản hồi lỗi

Trạng tháiCodeMô tả
401Token không hợp lệ hoặc đã thu hồi
403missing_scopeToken không có phạm vi webhooks:manage
404Không tìm thấy ID điểm cuối webhook
400Lỗi xác thực (URL không hợp lệ, tên sự kiện không xác định)