Zdocs.zca.vnVề ZCA

API User

Các endpoint tích hợp dành cho User. 1 user = 1 API Key — dùng API Key cho mọi endpoint (không dùng JWT). Header: Authorization: Bearer <your-api-key>. Base URL: https://api.zca.vn/api.

Lấy API Key tại Portal → User → Developers (API Key). Client secret chỉ hiển thị một lần khi tạo, vui lòng lưu lại.

Lưu ý: Trang này chỉ dành cho User. Nếu bạn là Agency, xem tài liệu đầy đủ tại API Agency.

Hướng dẫn gửi tin ZBS (ZNS) qua API Key

Gửi một tin ZBS (ZNS) từ n8n, script hoặc app: dùng API Key trong header, gọi POST /api/zns/send.

  1. Lấy API Key — Portal → User → Developers → tạo/lấy API Key (client_secret).
  2. Gửi 1 tin ZNSPOST /api/zns/send, header Authorization: Bearer <api-key>, body: template_id, phone, template_data. oa_id tùy chọn.
  3. Ví dụ (curl) — Xem bên dưới.
curl -X POST "https://api.zca.vn/api/zns/send" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"template_id":"365511","phone":"84912345678","template_data":{"ten_khach_hang":"Nguyễn A","ma_du_an":"INV-001"}}'

template_data có thể là object hoặc mảng [{ "name": "ten_bien", "value": "..." }].

Gửi tin ZNS (ZBS)

MethodPathMô tả
POST/api/zns/sendGửi 1 tin ZNS. Body: template_id, phone, template_data, oa_id? (tùy chọn).
POST/api/zns/bulk-sendGửi nhiều tin ZNS. Body: template_id, campaign_data: [{ phone, template_data }], oa_id?, campaign_name?.

Zalo OA & Template

MethodPathMô tả
GET/api/zalo/access-tokenLấy access_token Zalo OA. Query: oa_id? (optional).
GET/api/zalo/templatesDanh sách templates ZNS. Query: oa_id, offset, limit, status.
GET/api/zalo/template-detailChi tiết 1 template ZBS. Query: template_id (bắt buộc), oa_id? (tùy chọn — 1 user 1 OA thì không cần).
GET/api/zalo/oa-infoThông tin OA (verified, package, expiry). Query: oa_id?.

Lấy chi tiết 1 template ZBS (ZNS)

Dùng GET /api/zalo/template-detail để lấy thông tin một template: tên, danh sách biến (list_params), giá tin, trạng thái. Chỉ cần truyền template_id (query). oa_id tùy chọn — 1 user 1 OA thì không cần.

  1. Lấy API Key tại Portal → User → Developers.
  2. Gọi GET .../zalo/template-detail?template_id=TEMPLATE_ID với header Authorization: Bearer <api-key>.
curl -X GET "https://api.zca.vn/api/zalo/template-detail?template_id=365511" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response thường chứa template_name, list_params (mảng biến dùng trong template_data khi gửi tin), price, status, v.v.

Ví dụ body gửi tin: { "template_id": "365511", "phone": "84912345678", "template_data": { "ten_khach_hang": "Nguyễn A", "ma_du_an": "INV-001" } }

Các endpoint dưới đây dùng khi đăng nhập Portal (JWT), không gọi bằng API Key.

Ví & Giao dịch (Portal)

MethodPathMô tả
GET/user/walletSố dư ví (dùng JWT trên Portal)
POST/user/wallet/topupNạp tiền (Main). Body: { amount, description? }. Có thể kích hoạt thưởng Referral 5M+5M nếu đủ điều kiện.
GET/user/ledgerLịch sử giao dịch. Query: limit=50, offset=0

Zalo OA

MethodPathMô tả
GET/user/zalo/tokenToken Zalo OA đã lưu (connected, oa_id, expires_at). Dùng để gọi Zalo API gửi tin.

Giới thiệu (Referrals)

MethodPathMô tả
GET/user/referralsDanh sách người được giới thiệu. Query: status=PENDING|COMPLETED

Phân tích & Báo cáo

MethodPathMô tả
GET/user/analyticsPhân tích User. Query: from, to (ISO date). Mặc định tháng hiện tại.
GET/user/analytics/by-dayThống kê theo ngày. Query: from, to
GET/user/analytics/campaignsBáo cáo theo chiến dịch. Query: from, to

Thanh toán & Hóa đơn

MethodPathMô tả
GET/user/payment-infoThông tin chuyển khoản + QR. Query: oa_id, amount, request_invoice=1
GET/user/invoice-infoLấy thông tin hóa đơn đã lưu
PUT/user/invoice-infoLưu thông tin hóa đơn (company name, tax code, address, ...)