Quikpair WhatsApp API:如何使用測試金鑰發送首則 WhatsApp 範本訊息
Send your first WhatsApp template message with a test key
Quikpair 的 WhatsApp API 測試金鑰可在連接 WhatsApp 號碼前測試範本訊息發送及 webhook。測試請求會返回 202,觸發標記為 "test": true 的狀態 webhook,但訊息不會送達 WhatsApp,亦不會收費。測試模式會略過部分正式發送檢查,因此測試成功不代表正式發送一定成功。
Disclosure: I publish this from the Quikpair account. Quikpair makes the WhatsApp API described here, so I have a stake in the topic. This post was AI-generated and checked against Quikpair's public developer docs and Meta's public pricing page.
Quikpair's WhatsApp API docs describe a test key: you can build and test message sends before your WhatsApp number is connected. This post covers what a test key does and what it does not do, using the public docs.
What you need
- A Quikpair account with the WhatsApp section (WhatsApp, then API & Webhooks).
- An HTTPS endpoint if you want to see webhooks.
- Nothing else for the test step. The docs say you can build and test with a test key before your number is connected.
Step 1: create a test key
In the app, open WhatsApp, then API & Webhooks, create a key and choose type Test. Test keys start with qp_wa_test_. Store the key like any secret and keep it out of browser or mobile code. In the examples below I use an obviously fake placeholder.
Step 2: send a test message
The body of POST /messages follows Meta's Cloud API message object. Set type, then an object with the same name. Add an Idempotency-Key header so a retry never sends twice.
curl -X POST https://backend.quikpair.com/api/v1/whatsapp/messages \
-H "Authorization: Bearer qp_wa_test_PLACEHOLDER_NOT_A_REAL_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-1042-ready" \
-d '{"to":"YOUR_TEST_RECIPIENT","type":"template",
"template":{"name":"order_shipped","language":{"code":"en"},
"components":[{"type":"body","parameters":[
{"type":"text","text":"Rahul"},{"type":"text","text":"#1042"}]}]}}'
Phone numbers are international digits without the plus sign. Per the docs, a test send returns 202, checks the request body the way a live send does, and fires message.status webhooks (sent, delivered, read) marked "test": true. Nothing reaches WhatsApp and nothing is charged. Send to a number ending in 0000 to get a failed status and test your error handling.
What a test key cannot do
Test keys can call POST /messages, GET /account, GET /templates (once a number is connected) and the webhook routes. Other calls, such as template changes, media upload and reading messages, return 403 test_key_not_allowed. Test sends also skip the live-only checks: the 24-hour window, opt-outs, paid-message settings and your monthly quota. So passing in test mode does not prove a live send will pass those checks.
Step 3: handle the webhook
Register an HTTPS endpoint under API & Webhooks, or with POST /webhook-endpoints. Events include message.received and message.status. The signing secret is shown once, so save it when you create the endpoint and verify each request with it.
Going live
The docs list the remaining steps: connect your own WhatsApp Business number (the API never uses a shared number), create templates that Meta reviews, add a payment method in Meta if you will send paid messages and turn on Allow paid messages, then create a Live key and swap it in.
About cost
Quikpair's docs say Meta bills paid messages to your own WhatsApp Business account and that Quikpair does not charge per message. Meta's own pricing page says that since July 1, 2025 it charges per delivered template message, with rates that depend on the template category and the recipient's country calling code, and that non-template messages sent inside an open customer service window are free. Check Meta's current rate card for your country before you plan volume, and check your Quikpair plan for any monthly API message limit.
Docs: https://www.quikpair.com/developers/whatsapp/
Meta pricing: https://developers.facebook.com/docs/whatsapp/pricing/
來源:DEV Community · dev.to