Bỏ qua tới nội dung

Chiến dịch

· 15 endpoint

Chiến dịch của tài khoản

GET/api/v1/accounts/{accountId}/campaignsScope: crm:read

Tham số

accountId
path · bắt buộc
string
max 200
ID tài khoản (accounts.zalo_id). Facebook dùng Facebook ID, Telegram dùng ID tài khoản Telegram.

Lệnh mẫu

bash
curl "http://127.0.0.1:9900/api/v1/accounts/{accountId}/campaigns" \
  -H "Authorization: Bearer dpk_xxx"

Tạo chiến dịch (trạng thái draft)

POST/api/v1/accounts/{accountId}/campaignsScope: crm:write

Tham số

accountId
path · bắt buộc
string
max 200
ID tài khoản (accounts.zalo_id). Facebook dùng Facebook ID, Telegram dùng ID tài khoản Telegram.

Body (JSON)

name
bắt buộc
string
max 200
campaign_type
tuỳ chọn
"message" | "friend_request" | "mixed"
default "message"
template_message
tuỳ chọn
string | object
default ""
Nội dung gửi; hỗ trợ biến như UI ({name}...) hoặc JSON blocks của trình soạn
friend_request_message
tuỳ chọn
string
max 500 · default ""
mixed_config
tuỳ chọn
string | object
delay_seconds
tuỳ chọn
integer
≥ 5 · ≤ 86400 · default 60
Giãn cách giữa 2 liên hệ (giây); hàng đợi luôn chờ tối thiểu 30 giây

Lệnh mẫu

bash
curl -X POST "http://127.0.0.1:9900/api/v1/accounts/{accountId}/campaigns" \
  -H "Authorization: Bearer dpk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"name":"string","campaign_type":"message","template_message":""}'

Một chiến dịch

GET/api/v1/accounts/{accountId}/campaigns/{campaignId}Scope: crm:read

Tham số

accountId
path · bắt buộc
string
max 200
campaignId
path · bắt buộc
integer
≥ 1

Lệnh mẫu

bash
curl "http://127.0.0.1:9900/api/v1/accounts/{accountId}/campaigns/{campaignId}" \
  -H "Authorization: Bearer dpk_xxx"

Sửa chiến dịch

PATCH/api/v1/accounts/{accountId}/campaigns/{campaignId}Scope: crm:write

Tham số

accountId
path · bắt buộc
string
max 200
campaignId
path · bắt buộc
integer
≥ 1

Body (JSON)

name
tuỳ chọn
string
max 200
campaign_type
tuỳ chọn
"message" | "friend_request" | "mixed"
default "message"
template_message
tuỳ chọn
string | object
default ""
Nội dung gửi; hỗ trợ biến như UI ({name}...) hoặc JSON blocks của trình soạn
friend_request_message
tuỳ chọn
string
max 500 · default ""
mixed_config
tuỳ chọn
string | object
delay_seconds
tuỳ chọn
integer
≥ 5 · ≤ 86400 · default 60
Giãn cách giữa 2 liên hệ (giây); hàng đợi luôn chờ tối thiểu 30 giây

Lệnh mẫu

bash
curl -X PATCH "http://127.0.0.1:9900/api/v1/accounts/{accountId}/campaigns/{campaignId}" \
  -H "Authorization: Bearer dpk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"name":"string","campaign_type":"message","template_message":""}'

Xoá chiến dịch

DELETE/api/v1/accounts/{accountId}/campaigns/{campaignId}Scope: crm:write

Tham số

accountId
path · bắt buộc
string
max 200
campaignId
path · bắt buộc
integer
≥ 1

Lệnh mẫu

bash
curl -X DELETE "http://127.0.0.1:9900/api/v1/accounts/{accountId}/campaigns/{campaignId}" \
  -H "Authorization: Bearer dpk_xxx"

Nhân bản chiến dịch

POST/api/v1/accounts/{accountId}/campaigns/{campaignId}/cloneScope: crm:write

Tham số

accountId
path · bắt buộc
string
max 200
campaignId
path · bắt buộc
integer
≥ 1

Body (JSON)

name
tuỳ chọn
string
max 200
include_contacts
tuỳ chọn
boolean
default false

Lệnh mẫu

bash
curl -X POST "http://127.0.0.1:9900/api/v1/accounts/{accountId}/campaigns/{campaignId}/clone" \
  -H "Authorization: Bearer dpk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"name":"string","include_contacts":false}'

Chạy / tạm dừng / kết thúc chiến dịch

POST/api/v1/accounts/{accountId}/campaigns/{campaignId}/statusScope: campaigns:run

active bắt đầu hàng đợi gửi theo tài khoản (giãn cách như cấu hình), paused tạm dừng, done kết thúc.

Tham số

accountId
path · bắt buộc
string
max 200
campaignId
path · bắt buộc
integer
≥ 1

Body (JSON)

status
bắt buộc
"draft" | "active" | "paused" | "done"

Lệnh mẫu

bash
curl -X POST "http://127.0.0.1:9900/api/v1/accounts/{accountId}/campaigns/{campaignId}/status" \
  -H "Authorization: Bearer dpk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"status":"draft"}'

Người nhận của chiến dịch và trạng thái gửi

GET/api/v1/accounts/{accountId}/campaigns/{campaignId}/contactsScope: crm:read

Tham số

accountId
path · bắt buộc
string
max 200
campaignId
path · bắt buộc
integer
≥ 1

Lệnh mẫu

bash
curl "http://127.0.0.1:9900/api/v1/accounts/{accountId}/campaigns/{campaignId}/contacts" \
  -H "Authorization: Bearer dpk_xxx"

Thêm người nhận vào chiến dịch

POST/api/v1/accounts/{accountId}/campaigns/{campaignId}/contactsScope: crm:write

Tham số

accountId
path · bắt buộc
string
max 200
campaignId
path · bắt buộc
integer
≥ 1

Body (JSON)

contacts
bắt buộc
object[]
max 5000 items
└contact_id
bắt buộc
string
max 200
└display_name
tuỳ chọn
string
max 200
└phone
tuỳ chọn
string
max 30
└avatar
tuỳ chọn
string
max 1000

Lệnh mẫu

bash
curl -X POST "http://127.0.0.1:9900/api/v1/accounts/{accountId}/campaigns/{campaignId}/contacts" \
  -H "Authorization: Bearer dpk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"contacts":[]}'

Xoá người nhận (theo danh sách hoặc tất cả)

DELETE/api/v1/accounts/{accountId}/campaigns/{campaignId}/contactsScope: crm:write

Tham số

accountId
path · bắt buộc
string
max 200
campaignId
path · bắt buộc
integer
≥ 1

Body (JSON)

contact_ids
tuỳ chọn
string[]
max 5000 items
all
tuỳ chọn
boolean
default false

Lệnh mẫu

bash
curl -X DELETE "http://127.0.0.1:9900/api/v1/accounts/{accountId}/campaigns/{campaignId}/contacts" \
  -H "Authorization: Bearer dpk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"contact_ids":[],"all":false}'

Thêm mọi hội thoại đang gắn một nhãn vào chiến dịch

POST/api/v1/accounts/{accountId}/campaigns/{campaignId}/contacts/from-labelScope: crm:write

Tham số

accountId
path · bắt buộc
string
max 200
campaignId
path · bắt buộc
integer
≥ 1

Body (JSON)

label_id
bắt buộc
integer
≥ 1
only_users
tuỳ chọn
boolean
default true
Bỏ qua nhóm chat

Lệnh mẫu

bash
curl -X POST "http://127.0.0.1:9900/api/v1/accounts/{accountId}/campaigns/{campaignId}/contacts/from-label" \
  -H "Authorization: Bearer dpk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"label_id":1,"only_users":true}'

Thêm thành viên một nhóm (đã quét/lưu) vào chiến dịch

POST/api/v1/accounts/{accountId}/campaigns/{campaignId}/contacts/from-groupScope: crm:write

Như "Thêm vào chiến dịch" ở tab Thành viên nhóm. Thành viên lấy từ danh sách đã lưu (quét nhóm trong app trước nếu trống).

Tham số

accountId
path · bắt buộc
string
max 200
campaignId
path · bắt buộc
integer
≥ 1

Body (JSON)

group_id
bắt buộc
string
max 200
exclude_ids
tuỳ chọn
string[]
max 5000 items · default []

Lệnh mẫu

bash
curl -X POST "http://127.0.0.1:9900/api/v1/accounts/{accountId}/campaigns/{campaignId}/contacts/from-group" \
  -H "Authorization: Bearer dpk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"group_id":"string","exclude_ids":[]}'

Nhật ký gửi của chiến dịch

GET/api/v1/accounts/{accountId}/campaigns/{campaignId}/send-logScope: crm:read

Tham số

accountId
path · bắt buộc
string
max 200
campaignId
path · bắt buộc
integer
≥ 1
limit
query · tuỳ chọn
integer
≥ 1 · ≤ 1000 · default 200

Lệnh mẫu

bash
curl "http://127.0.0.1:9900/api/v1/accounts/{accountId}/campaigns/{campaignId}/send-log" \
  -H "Authorization: Bearer dpk_xxx"

Thống kê chiến dịch nổi bật

GET/api/v1/accounts/{accountId}/campaigns-statsScope: crm:read

Tham số

accountId
path · bắt buộc
string
max 200
ID tài khoản (accounts.zalo_id). Facebook dùng Facebook ID, Telegram dùng ID tài khoản Telegram.
limit
query · tuỳ chọn
integer
≥ 1 · ≤ 100 · default 10

Lệnh mẫu

bash
curl "http://127.0.0.1:9900/api/v1/accounts/{accountId}/campaigns-stats" \
  -H "Authorization: Bearer dpk_xxx"

Trạng thái hàng đợi gửi chiến dịch

GET/api/v1/accounts/{accountId}/campaigns-queueScope: crm:read

Tham số

accountId
path · bắt buộc
string
max 200
ID tài khoản (accounts.zalo_id). Facebook dùng Facebook ID, Telegram dùng ID tài khoản Telegram.

Lệnh mẫu

bash
curl "http://127.0.0.1:9900/api/v1/accounts/{accountId}/campaigns-queue" \
  -H "Authorization: Bearer dpk_xxx"