API công khai dùng xác thực OAuth2 client_credentials — gọi POST https://api.phanmempanda.com/v1/auth/token với client_id/client_secret lấy được từ trang Tích hợp → API keys sau khi đăng nhập vào ứng dụng, đổi lấy access token dùng cho các request tiếp theo (header Authorization: Bearer <token>).
Ví dụ đủ 2 bước: lấy access token, rồi gửi 1 tin nhắn. Thay client_id/client_secret bằng giá trị thật lấy ở trang Tích hợp → API keys, và oa_code/template_id theo OA và mẫu tin của bạn.
# 1. Lấy access token (hết hạn sau 3600 giây, nhớ xin lại khi hết hạn)
curl -s -X POST https://api.phanmempanda.com/v1/auth/token \
-H "Content-Type: application/json" \
-d '{
"grant_type": "client_credentials",
"client_id": "ac_xxxxxxxxxxxx",
"client_secret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}'
# → {"accessToken":"...","tokenType":"Bearer","expiresIn":3600}
# 2. Gửi 1 tin nhắn (Idempotency-Key BẮT BUỘC — gọi lại đúng key trong 24h
# trả về nguyên response cũ, không gửi trùng tin)
curl -s -X POST https://api.phanmempanda.com/v1/messages/send \
-H "Authorization: Bearer <accessToken>" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-2026-09-07-000123" \
-d '{
"oa_code": "oa-xxxxxxx",
"template_id": "123456",
"phone": "0901234567",
"params": { "customer_name": "Nguyễn Văn A", "order_code": "DH00123" }
}'