Before You Start
- Confirm the external system is trusted and has a named owner.
- Keep API Integration disabled until scopes, endpoint purpose, webhook receiver URL, and test contact are ready.
- Do not share API keys, WABA ID, Phone Number ID, access tokens, app secrets, webhook tokens, or customer phone numbers in screenshots.
Introduction
API Integration allows trusted external systems such as a CRM, website, billing tool, booking tool, or operations platform to interact with supported WAPI messaging and contact workflows.
The updated screen is divided into API status, scoped API keys, endpoint documentation cards, a template endpoint generator, incoming CRM webhook forwarding, and recent activity. Treat this tab as an admin-only integration control center.
API keys provide persistent access. Create them only for trusted systems and revoke keys that are no longer needed.
Main Areas
| Area | Purpose |
|---|---|
| Enable/Disable API Integration | Turns external API access on or off globally. |
| API Keys | Creates credentials for external systems and limits access with scopes. |
| Scopes | Controls whether a key can send session messages, send templates, send media, upsert contacts, or use other supported endpoints. |
| Account API IP Policy | Applies Security > IP Manager API allow/block rules before an API key is accepted. Any IP allowlist saved on the API key must also allow the request. |
| API Docs / Endpoint cards | Shows base URL, examples, and copy buttons for supported API calls. |
| Generate Template End-point | Lets an admin select a synced approved template, fill sample variable values, and copy the generated endpoint/request example for a CRM. |
| Trigger URLs | Creates secure copy-ready GET/POST URLs for systems such as WooCommerce, Shopify Flow, WHMCS hooks, no-code tools, billing systems, and custom apps. |
| Developer Test Console | Lets a developer paste an API key temporarily, run live API tests, copy response JSON, and capture message_id values for status checks. |
| Developer support endpoints | Auth Check, Approved Templates List, and Message Status help external apps test setup, map templates, and refresh delivery status. |
| Incoming CRM webhook | Forwards inbound WhatsApp/customer events to an external receiver. |
| HMAC signature header | Lets the receiving CRM verify that a webhook payload came from WAPI and was not changed in transit. |
| Recent Activity | Shows recent API requests, webhook deliveries, failures, and retry context. |
Trigger URLs
Trigger URLs are portable event links that external systems can call when something happens outside WAPI, such as an order paid event, invoice paid event, booking confirmation, or delivery update.
Each trigger has its own generated token. The token is separate from normal API keys, is shown only once when created or regenerated, and can be passed as a query/body token for simple apps or as a Bearer token for POST JSON callers.
- Open Settings > API Integration.
- Open Trigger URLs from the left menu.
- Click Create New Trigger URL beside the Ready status.
- Choose the trigger type and platform mapper.
- Select an approved template for outside-24-hour notifications, or enter text/media settings for service-window triggers.
- Add mapping JSON only when the external app sends a full payload and WAPI needs to extract fields from it.
- Save the trigger and copy the full token from the popup before closing it. The editor closes after the page reloads and the new row appears in Existing Trigger URLs.
- Copy the generated example for the target system: GET URL, POST JSON, Shopify Flow body, WooCommerce delivery URL, WHMCS hook code, cURL, or PHP.
- Run a test with one phone number and review Trigger Logs before using it in production workflows.
Expected Result
- The external system can trigger the allowed WAPI message without needing a full custom module.
- WAPI still sends through the existing approved template, Inbox, WhatsApp, media policy, and message logging pipeline.
| Control | How to use it |
|---|---|
| Create New Trigger URL | Opens the Trigger URL editor above the table. Save creates the trigger and returns the full token once; Cancel closes the editor without saving. |
| Edit settings | Loads the selected trigger into the same editor above the table. Update Trigger URL saves changes; Cancel closes the editor without changing the row. |
| Trigger Type | Choose Template for outside-24-hour notifications, Text for active service-window replies, Media/Document for service-window files, or Platform Webhook Mapping for WooCommerce/Shopify/WHMCS payloads. |
| Platform Mapper | Use Generic JSON/URL for simple parameters, WooCommerce for order payloads, Shopify for order payloads, or WHMCS for hook payloads. |
| Variable Map JSON | Maps external payload fields to WAPI fields such as to, v1, v2, v3, customer_name, and external_reference. Leave blank when using v1/v2/v3 URL parameters or built-in platform defaults. |
| Allowed Method | Use GET or POST for broad compatibility, POST only for cleaner integrations, or GET only when a third-party system can only open a URL. |
| Rate Limit | Limits how many times the trigger may run per minute. Use lower limits for simple public URL integrations. |
| Idempotency Window | Prevents duplicate sends when the same external_reference is received again inside the configured time window. |
| Generated examples | Copy GET URL, cURL, PHP, Shopify Flow JSON body, WHMCS InvoicePaid hook, or WHMCS AcceptOrder hook examples from the trigger row. |
| Existing Trigger URLs and Recent Trigger Logs | Use the horizontal table scroll on smaller screens to review URLs, generated examples, actions, statuses, references, and errors without compressed columns. |
| Test Trigger | Runs the trigger from WAPI Settings with sample variables and the entered test phone number. |
| Regenerate Token | Creates a new full token and immediately invalidates the old token. Update the external app after regeneration. |
External App Setup Examples
| System | Recommended setup |
|---|---|
| WooCommerce | Create a WAPI Platform Webhook Mapping trigger, copy its URL, then create a WooCommerce webhook under WooCommerce > Settings > Advanced > Webhooks. Use Order created, Order updated, or Order paid style events and paste the WAPI URL as the delivery URL. |
| Shopify Flow | Create a WAPI trigger, open Shopify Flow, choose an order event, add Send HTTP request, set method POST, paste the WAPI URL, set Content-Type: application/json, and paste the generated Shopify JSON body. Shopify Flow HTTP request availability depends on the merchant plan. |
| Shopify Webhook | Use a Shopify platform payload trigger when the store can register a webhook URL. WAPI maps order phone, customer name, order number, amount, and status from the payload. |
| WHMCS InvoicePaid | Copy the generated WHMCS InvoicePaid hook code into a PHP file under /includes/hooks/ in WHMCS. Replace the token placeholder with the WAPI trigger token and test one paid invoice. |
| WHMCS AcceptOrder | Copy the generated WHMCS AcceptOrder hook code into /includes/hooks/ when order acceptance should send a WhatsApp message. Service activation hooks can be added later when required. |
| Generic apps | If the app can only open a URL, use the generated GET URL with merge tags for to, v1, v2, and v3. If it supports POST JSON, use the generated JSON/cURL/PHP example. |
Safe Setup Process
- Leave API Integration disabled while planning.
- Decide which external system needs access and which actions it should perform.
- Enable only the required scopes.
- Create the API key, copy it from the persistent popup, then paste it into the external system or a secure credential store before closing the popup.
- Test with one contact and one approved template before larger use.
- Review logs for success/failure.
- Disable or revoke access immediately if the external system is no longer trusted.
Expected Result
- The external system can call only the endpoint actions allowed by its scopes.
- Admins can see recent request status and webhook delivery status inside the same Settings tab.
API Key And Scope Guide
| Control | How to use it |
|---|---|
| Enable/Disable button | Turns the full API surface on or off. Disable it during security review, credential rotation, or when no external system should send requests. |
| Key name | Use a recognizable name such as Production CRM, Booking Portal, or Billing System so admins know which system owns the key. |
| Scopes checkboxes | Grant the smallest set needed. For example, a CRM that only sends approved notifications may need template send access but not contact deletion. |
| Generate API Key | Creates the credential and opens a popup that stays visible until the admin closes it. Use the copy icon in the popup to copy the full key into the external system or secure credential store. |
| Status dropdown | Use active for normal use and revoked when the integration should stop. Revoked keys should fail immediately. |
| Regenerate | Use when a key may be exposed or when rotating credentials. The new full key appears in the same copyable popup; update the external system before closing it because the full key is shown only once. |
Developer Test Console
Use the Developer Test Console when a CRM developer needs real endpoint responses instead of static examples. The console runs requests from the browser against the same public API routes shown in the endpoint cards.
The full API key pasted into the console is not saved by WAPI. It is used only by the current browser request. If the page is refreshed, the developer must paste the key again.
- Open Settings > API Integration.
- Create or copy an active API key with the required scopes.
- Open Developer Test Console.
- Paste the full API key into the console.
- Choose the test type.
- Fill the required fields such as phone number, template, variables, document URL, or message_id.
- Click Run Test or Check Status.
- Copy the Response JSON into the CRM developer mapping screen or documentation.
Expected Result
- The developer can see the exact JSON returned by WAPI for the selected endpoint.
- When a send response includes message_id, the console fills the status message ID field automatically so the developer can immediately test Message Status.
| Test type | What it returns |
|---|---|
| Auth Check | Confirms that API Integration is enabled, the key is valid, and the key has usable scopes. |
| Approved Templates List | Returns live template metadata so a CRM can build template mapping screens, including template format and any required carousel card media inputs. |
| Send Template Message | Sends an approved standard, Flow Launch, or Carousel Template and returns the live send response, including WAPI message_id when the send is accepted. |
| Send Template + PDF/Document Header | Sends an approved media-header template using a reachable temporary HTTPS document/image/video URL. WAPI securely downloads and validates the file, so the external app does not need to perform a browser upload. A successful response includes WAPI message_id; missing or rejected media returns a JSON error. |
| Send Text Message | Sends a text message only inside an active 24-hour WhatsApp service window. |
| Send Document Message | Sends a PDF/document only inside an active 24-hour WhatsApp service window. |
| Message Status | Looks up one previously sent WAPI message by message_id and returns sent, delivered, read, failed, or available timestamp fields. |
| Bulk Message Status | Looks up many previously sent WAPI messages in one read-only request. Use it for CRM Sync Status buttons, selected rows, current-page refresh, or background status jobs. |
| Conversation List | Loads WAPI Inbox conversations so a CRM can build a synced mini inbox with contact, last message, unread count, and status data. |
| Conversation Messages | Loads message history for one conversation and includes signed media download details when a message has media. |
| Conversation Actions | Tests mark-read, close, reopen, and delete actions against one conversation ID using the same public API routes a CRM will call. |
Endpoint Cards
| Endpoint card | When to use it |
|---|---|
| Auth Check | Use after saving WAPI base URL and API key in an external app. It confirms API Integration readiness, API key validity, allowed scopes, and basic connectivity without sending a WhatsApp message. |
| Approved Templates List | Use in external app mapping screens so admins can select approved template names, language, category, format, header type, variable count, and any required carousel card media details without manually typing template names. |
| Campaign Draft / List / Detail | Use POST /api/v1/campaigns with campaigns:write and Idempotency-Key to create a safe draft from an approved template and audience reference. GET list/detail calls use campaigns:read and never return recipient data or mappings. |
| Campaign Preparation And Lifecycle | Use POST /api/v1/campaigns/{id}/prepare, submit-approval, schedule, start, pause, resume, or cancel with campaigns:write and a unique Idempotency-Key. Normal audience, approval, worker, and compliance gates still apply. |
| Campaign Aggregate Report | Use GET /api/v1/campaigns/{id}/report with campaigns:read for complete-data metrics, engagement, timeline, variant, journey, exclusion, and error breakdowns without recipient PII. |
| Send Text Message | Use only inside an active 24-hour WhatsApp customer service window. It is suitable for CRM replies or operational notes after the customer recently messaged. |
| Send Template Message | Use approved WhatsApp templates for CRM-initiated notifications and messages outside the 24-hour window. Fill required variables exactly, and provide one HTTPS media input per required carousel card when the selected template format is Carousel. |
| Send Template Media Header | Use when the approved template has an image, video, or document header. Provide a reachable temporary HTTPS media URL and a filename for documents. WAPI downloads, validates, and prepares this send-time file internally; template review/sample media is not reused for delivery. |
| Send Media Message | Use inside the active service window to send image, video, audio, or document from a reachable HTTPS URL. Localhost/private URLs are blocked. |
| Send Document Message | Shortcut for invoice/PDF style documents, including document URL, filename, and optional caption. |
| Message Status | Use only after a send endpoint has returned a WAPI message_id. First send a text, template, document, or media message, copy message_id from that JSON response, then call /whatsapp/messages/{message_id}/status to refresh sent, delivered, read, or failed status inside the external app. |
| Bulk Message Status | Use POST /whatsapp/messages/status/bulk when the external app needs to refresh many saved WAPI message IDs at once. Send {"message_ids":[5,6,7]} and WAPI returns statuses plus any not_found IDs. Maximum 100 IDs per request. |
| Conversation List | Use GET /whatsapp/conversations for CRM inbox sync. Optional filters include status, search, phone_number, updated_after, page, and per_page. |
| Conversation Messages | Use GET /whatsapp/conversations/{conversation_id}/messages after the CRM has a conversation ID. Optional cursors before_id and after_id let the CRM load older or newer messages. |
| Mark Conversation Read | Use POST /whatsapp/conversations/{conversation_id}/mark-read when a CRM operator opens or marks a conversation as read. This clears WAPI unread counts for inbound messages without making read-only sync endpoints mutate state. |
| Close Conversation | Use POST /whatsapp/conversations/{conversation_id}/close when the CRM operator closes the WAPI chat from the CRM. |
| Reopen Conversation | Use POST /whatsapp/conversations/{conversation_id}/reopen when the CRM operator needs to resume a closed or pending WAPI chat without creating a duplicate thread. |
| Delete Conversation | Use POST /whatsapp/conversations/{conversation_id}/delete only for trusted admin-owned integrations. It permanently removes the conversation and stored media. |
| Get Contact / Contact List | Use for CRM lookup and list sync. Keep pagination limits reasonable. |
| Create Or Update Contact | Use to add or update a contact by phone number before messaging or syncing CRM references. |
| Delete Contact | Use only when the business process requires removing a contact. This should be limited to trusted admin-owned integrations. |
Building A WAPI Client Module
External app developers can build their own WapiClientIntegration module inside a CRM, booking app, billing tool, or operations app. WAPI provides the API endpoints, key management, scopes, examples, and webhook signature behavior; the external app owns its own module code and business workflow.
The client module should stay generic inside the external app. Business workflows such as invoice sending, job-card sending, appointment reminders, ticket updates, or receipts should call the client module instead of scattering raw HTTP calls across controllers.
| Suggested part | Purpose |
|---|---|
| Settings | Stores WAPI base URL, encrypted API key, default language, timeout, retry count, and status polling preference. |
| WapiClient | Central HTTP client that adds Bearer auth, sends JSON, parses responses, normalizes errors, and hides secrets from logs. |
| Connection Test | Calls Auth Check so admins can confirm the external app is connected before enabling business automations. |
| Template Service | Calls Approved Templates List and helps the external app map its events to WAPI template names. |
| Message Service | Wraps sendTemplate, sendDocument, sendMedia, sendText, and contact upsert calls. |
| Status Service | Calls Message Status by saved WAPI message ID when the external app wants local delivered/read/failed status. |
| Inbox Sync Service | Calls Conversation List and Conversation Messages when the external app needs a small WAPI-powered inbox or message timeline. |
| Conversation Action Service | Wraps mark-read, close, reopen, and delete endpoints so CRM buttons do not make raw HTTP calls directly. |
| Webhook Verifier | Verifies X-WAPI-Signature when the external app enables inbound or outgoing WAPI webhooks. |
| Logs | Stores request ID, WAPI message ID, Meta message ID, HTTP status, error code, and response summary for troubleshooting. |
WapiClientIntegration/
Settings/
Services/WapiClient
Services/WapiConnectionTestService
Services/WapiTemplateService
Services/WapiMessageService
Services/WapiStatusService
Services/WapiWebhookVerifier
Logs/request_logs
UI/connection_settings
UI/template_mapping_helper
UI/recent_api_activity Common Client Methods
A CRM-side WAPI client can expose small methods that map directly to WAPI endpoints. The external app developer can rename or reshape these methods to match their framework.
| Method | Endpoint and use |
|---|---|
| checkConnection() | GET /api/v1/auth/check. Test base URL, API key, scopes, and API Integration readiness. |
| listTemplates() | GET /api/v1/templates. Load approved templates for mapping screens. |
| sendTemplate() | POST /api/v1/whatsapp/messages/template. Send invoice, job card, receipt, appointment, or other approved templates. |
| sendDocument() | POST /api/v1/whatsapp/messages/document. Send a PDF/document inside an active 24-hour service window. |
| sendMedia() | POST /api/v1/whatsapp/messages/media. Send image, video, audio, or document inside an active service window. |
| sendText() | POST /api/v1/whatsapp/messages/text. Send quick replies inside an active service window. |
| upsertContact() | POST /api/v1/contacts/upsert. Create or update the WAPI contact before messaging. |
| getMessageStatus() | GET /api/v1/whatsapp/messages/{message_id}/status. Refresh local sent, delivered, read, or failed status by using the WAPI message_id returned from a previous send response. |
| getBulkMessageStatus() | POST /api/v1/whatsapp/messages/status/bulk. Refresh selected/current-page/pending CRM message statuses in one request by sending up to 100 saved WAPI message IDs. |
| listConversations() | GET /api/v1/whatsapp/conversations. Load WAPI Inbox conversations for CRM mini-inbox sync. |
| listConversationMessages() | GET /api/v1/whatsapp/conversations/{conversation_id}/messages. Load the latest, older, or newer messages for one synced conversation. |
| markConversationRead() | POST /api/v1/whatsapp/conversations/{conversation_id}/mark-read. Call when the CRM user opens or reads a conversation so WAPI unread counts also clear. |
| closeConversation() | POST /api/v1/whatsapp/conversations/{conversation_id}/close. Close the WAPI conversation from CRM. |
| reopenConversation() | POST /api/v1/whatsapp/conversations/{conversation_id}/reopen. Reopen the WAPI conversation from CRM. |
| deleteConversation() | POST /api/v1/whatsapp/conversations/{conversation_id}/delete. Permanently remove the WAPI conversation and media. |
| listCampaigns() | GET /api/v1/campaigns with campaigns:read. Load a bounded operations list and canonical counters. |
| getCampaign() | GET /api/v1/campaigns/{campaign_id} with campaigns:read. Load one redacted Campaign status record. |
| createCampaign() | POST /api/v1/campaigns with campaigns:write and Idempotency-Key. Create a draft from an approved template plus all/category/segment/retarget audience reference; optional campaign_type and objective identify journey/experiment behavior and a fatigue-controlled Campaign Family. Raw recipient bulk-send is not exposed. |
| getCampaignReport() | GET /api/v1/campaigns/{campaign_id}/report with campaigns:read. Load complete aggregate reporting without recipient PII. |
| campaignAction() | POST /api/v1/campaigns/{campaign_id}/{prepare|submit-approval|schedule|start|pause|resume|cancel} with campaigns:write and Idempotency-Key. |
| listStorefrontOrders() | GET /api/v1/storefront/orders with storefront.orders:read. List or open canonical Storefront orders; write scope controls status and fulfilment actions. |
| manageStorefrontReturns() | GET /api/v1/storefront/returns or POST the supported order/request actions with storefront.orders:read/write. Return state remains owned by Storefront. |
| listFormsAndSubmissions() | GET /api/v1/forms or /api/v1/form-submissions with forms:read. POST a submission only through forms:write and Idempotency-Key. |
| manageAppointments() | GET /api/v1/appointments and /availability with appointments:read. Booking, reschedule, cancel, and status actions require appointments:write plus Idempotency-Key. |
| managePipelineCards() | GET /api/v1/pipeline/stages or /cards with pipeline:read. Create, update, assign, and move supported cards with pipeline:write plus Idempotency-Key. |
| verifyWebhookSignature() | Verify X-WAPI-Signature with the saved webhook secret before trusting inbound webhook payloads. |
Client Flow Example
The external app should test the connection first, load approved templates for mapping, send a template with variables and optional header/card media, then store WAPI identifiers for later troubleshooting or status refresh.
client = new WapiClient(baseUrl, apiKey)
check = client.checkConnection()
if check.success is false:
show connection error
stop setup
templates = client.listTemplates(language = 'en')
response = client.sendTemplate({
phone_number: customer.phone,
customer_name: customer.name,
template_name: 'invoice_ready_pdf',
language: 'en',
variables: {
'1': customer.name,
'2': invoice.number,
'3': workOrder.number,
'4': invoice.total
},
header: {
type: 'document',
url: invoice.temporaryPdfUrl,
filename: invoice.number + '.pdf'
},
external_reference: 'invoice:' + invoice.id
})
save response.request_id, response.message_id, response.meta_message_id
status = client.getMessageStatus(response.message_id)
update local row with status.status, status.delivered_at, status.read_at, status.error_message Incoming CRM Webhook
- Open API Integration and go to Incoming Message Webhook.
- Enter a clear webhook name and the external CRM HTTPS receiver URL.
- Enable the webhook only when the receiving system is ready.
- Save the webhook settings.
- In the CRM, verify the HMAC SHA-256 signature header before trusting the payload.
- Send or receive one test WhatsApp message and review Recent Activity for delivery status.
Expected Result
- Inbound messages and media events can be forwarded to the CRM in near real time.
- The CRM can reject payloads with invalid signatures.
- Admins can retry failed deliveries from Recent Activity where the app exposes retry action.
24-Hour And Template Rules
- Session text/media sends are intended for active customer service windows.
- Approved templates are used for starting or continuing conversations outside the window.
- Template media-header sends require the selected WhatsApp template to already contain a media header in Meta.
- Carousel template sends require one HTTPS media input per required card in the same order shown by the template metadata.
- Media URLs should be HTTPS and accessible to the server.
- Private network URLs, localhost URLs, oversized files, and blocked MIME types should be expected to fail.
- External systems should not send customer data that the business is not authorized to process.
Examples
Template notification from a CRM
A service CRM can call Send Template Message when a work order is created. The CRM provides the customer phone number, approved template name, language, variables such as order ID, and an external reference for tracking.
For a new recipient, WAPI can create a contact without assigning a category. An existing contact on the sending account keeps its category. Check the message status separately to confirm delivery.
Invoice PDF from a billing system
A billing system can call Send Document Message inside an active service window by sending a temporary HTTPS PDF URL, filename such as invoice-1001.pdf, and an optional caption.
Troubleshooting Decision Tree
- Do all API calls fail?
Yes: Check the global Enable/Disable state, API key status, Authorization Bearer header, and whether the key was revoked or regenerated.
No: Review the failing endpoint card and continue with endpoint-specific checks.
- Does only one endpoint fail?
Yes: Check the key scopes, request method, required JSON fields, 24-hour window rule, template approval, media URL, and file type/size.
No: Check Settings credentials, WhatsApp API status, and Recent Activity for shared errors.
- Does webhook delivery fail?
Yes: Verify the receiver URL is HTTPS, reachable, accepts the payload, and validates the HMAC signature header correctly.
No: Use a single test contact and compare WAPI Recent Activity with the external system log.
FAQs & Troubleshooting
Should I give one API key to all external tools?
No. Create separate keys per external system so each key can be scoped and revoked independently.
Why does an API text send fail outside the service window?
Use an approved template endpoint when the customer service window is closed.
Can a CRM send media using a URL?
Yes, if the endpoint supports media by URL and the URL is HTTPS, public to the server, within size limits, and uses an allowed file type.
Why should the CRM verify HMAC?
HMAC verification helps the CRM confirm the webhook payload came from WAPI and was not changed in transit.
Troubleshooting Checklist
- If all API calls fail, check whether API Integration is enabled and the key is active.
- If only one endpoint fails, check the key scopes and request payload.
- If webhook delivery fails, review the receiver URL, signature expectations, and logs.
- If media by URL fails, verify HTTPS, file type, size, and that the URL is publicly reachable by the server.
- If a template media-header send fails, confirm the approved Meta template actually has a media header and the header type matches image, video, or document.