Zdocs.zca.vnVề ZCA

API Agency

Trang này dành cho Agency: gồm API User (dùng chung) và API Agency (dashboard). Yêu cầu header Authorization: Bearer <token>. Base URL: https://api.zca.vn/api.

Phần 1 — API User (API Key, 1 user = 1 API Key)

User dùng một API Key để gọi mọi endpoint tích hợp (gửi tin, template, access-token, oa-info). Header: Authorization: Bearer <api-key>. Base URL: https://api.zca.vn/api.

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.

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"}}'

Gửi tin ZNS (ZBS) & Zalo / Template

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?.
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. Chỉ cần template_id (query). oa_id tùy chọn — 1 user 1 OA thì không cần.

curl -X GET "https://api.zca.vn/api/zalo/template-detail?template_id=365511" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response: template_name, list_params (biến dùng trong template_data khi gửi tin), price, status.

Ví & Giao dịch

MethodPathMô tả
GET/user/walletSố dư ví: main_balance, credit_balance, total
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, ...)

Phần 2 — API Agency (Dashboard)

Các endpoint riêng cho Agency (role RESELLER hoặc ADMIN): ví, tier, cấu hình thanh toán, sub-users, rút tiền, developer.

Ví & Tier

MethodPathMô tả
GET/dashboard/walletSố dư ví (main_balance, credit_balance, total)
GET/dashboard/tier/statsThống kê Tier: totalVolume, currentTier, nextTier, volumeToNextTier, progressPercent
GET/dashboard/tier/tiersDanh sách Commission Tiers (bảng hạng chiết khấu)

Cấu hình thanh toán

MethodPathMô tả
GET/dashboard/payment-configLấy cấu hình TK nhận tiền (bank, account, transfer_prefix, delegate_payment, ...)
PUT/dashboard/payment-configLưu cấu hình. Body: bank, account, account_name, transfer_prefix?, delegate_payment?, agency_participates_referral?
GET/dashboard/payment-infoThông tin chuyển khoản + QR. Query: amount=xxx
GET/dashboard/auto-withdraw-configLấy cấu hình rút tiền tự động
PUT/dashboard/auto-withdraw-configCập nhật cấu hình rút tự động

Quản lý User con (Sub-users)

MethodPathMô tả
GET/dashboard/sub-usersDanh sách User thuộc Agency (id, email)
GET/dashboard/oa-listDanh sách OA (sub-users + OA + ví). Query: sort=email
POST/dashboard/transfer-creditChuyển Credit sang User. Body: { user_id, amount }
POST/dashboard/adjust-balanceĐiều chỉnh ví User (cộng/trừ Cash hoặc Credit). Body: { user_id, amount, balance_type: "MAIN"|"CREDIT", description? }. Chỉ Agency không ủy thác.

Rút tiền

MethodPathMô tả
POST/dashboard/withdrawTạo yêu cầu rút tiền. Body: { amount, bank_name?, bank_account?, bank_holder? }. Admin duyệt sau.

Developer & Webhook

MethodPathMô tả
GET/dashboard/developer-configLấy cấu hình Developer (webhook_url, API key masked)
PUT/dashboard/developer-configCập nhật webhook_url
POST/dashboard/developer-config/create-api-keyTạo API Key mới (dùng cho webhook nạp tiền Sepay)

Referral & Khác

MethodPathMô tả
GET/dashboard/referralsDanh sách referral. Query: status
GET/dashboard/referral-campaignsDanh sách chiến dịch mời bạn bè (PENDING)
POST/dashboard/referral-campaigns/:id/approveDuyệt ref (thưởng cho referrer + referee)
POST/dashboard/referral-campaigns/:id/rejectTừ chối ref
GET/dashboard/business-infoThông tin kinh doanh đã lưu
PUT/dashboard/business-infoLưu thông tin kinh doanh