Learning path: Your first WhatsApp Cloud API integrationStep 2 of 7
WhatsApp Cloud API tokens: temporary, system user and business
Use a system user access token for your own production traffic, and a business token per client if you onboard other businesses. The token on the App Dashboard’s API setup panel is a user access token, which Meta says you regenerate “every few hours” (access tokens). Meta’s Get started guide says the temporary token “expires quickly” and tells you to “Create a system user and generate a permanent access token” (accessed 2026-11-02).
Meta now calls the WhatsApp Business Account (WABA) a “Messaging account”, with the same ID as before. Existing tokens keep working through that change (account model evolution, accessed 2026-11-02).
The three token types
Meta’s access tokens page lists three types (accessed 2026-11-02).
| Token | Who uses it | How long it lasts |
|---|---|---|
| System user access token | Direct developers; Solution Partners for credit-line sharing | “long-lived”; never expires or 60 days, chosen at creation |
| Business Integration System User access token (“business token”) | Tech Providers and Solution Partners | Not documented on the pages cited |
| User access token | Whoever copies it from the API setup panel | “expire quickly, so you have to keep generating a new one every few hours” |
System user tokens “can represent automated services within your business”. Business tokens come from the Embedded Signup code exchange and are “scoped to individual onboarded customers”. The Embedded Signup guide shows that exchange. Store one business token per client, keyed by the client’s waba_id.
Why the test token breaks production
The API setup panel under WhatsApp > API setup “always generates a new User access token whenever you visit it.” That makes it convenient for a first curl, as in the test number walkthrough. Copy it into an environment variable and your integration works for a few hours, then every call fails.
The current pages say “expires quickly” without a number. A 2022 post on the Meta Developers blog said “For security reasons, the token expires in less than 24 hours” (Meta Developers blog, 2022-12-05). Either way, a token copied from the panel can’t carry a service that runs overnight.
Create a system user token
The steps run in Business settings of the business portfolio:
- Go to System Users, click +Add, and choose the Admin or Employee role.
- Click Assign assets. Pick your app and give it Manage app. Reload the page to see Full control, which can take a few minutes.
- Assign the WhatsApp account with Partial or Full access. The system user also needs the Messaging account.
- Click Generate token, pick the app, and choose an expiration: “Never expires” or “Valid for 60 days”.
- Select
business_management,whatsapp_business_managementandwhatsapp_business_messaging, then copy the token.
Meta’s page says Admin system users get “full access to all WhatsApp accounts” by default. Employee system users must be granted each account one by one. If an Employee token works on one account and fails on another, check that step 3 was done for the second account.
Treat the token as opaque. Meta says token format can change, so don’t parse it, and store it in a variable-length field instead of a fixed-width column.
Generate one with the API
Meta’s system user page also generates tokens by API (System users: install apps and generate tokens, accessed 2026-11-02). Meta’s example requests Ads permissions. The version below swaps in the WhatsApp scopes from step 5 and renames the placeholders:
curl \
-F "business_app=<APP_ID>" \
-F "scope=business_management,whatsapp_business_management,whatsapp_business_messaging" \
-F "set_token_expires_in_60_days=true" \
-F "appsecret_proof=<APPSECRET_PROOF>" \
-F "access_token=<ACCESS_TOKEN>" \
"https://graph.facebook.com/<API_VERSION>/<SYSTEM_USER_ID>/access_tokens"
Rotate an expiring token
“An expiring system user token is valid for 60 days from generated or refreshed date.” Meta’s instruction: “To create continuity, the developer should refresh the access token within 60 days.” Refresh with a token exchange:
curl --get 'https://graph.facebook.com/<API_VERSION>/oauth/access_token' \
-d 'grant_type=fb_exchange_token' \
-d 'client_id=<APP_ID>' \
-d 'client_secret=<APP_SECRET>' \
-d 'set_token_expires_in_60_days=true' \
-d 'fb_exchange_token=<CURRENT_TOKEN>'
Meta’s sample shows this as a single GET URL; it’s split into -d pairs here. The response is {"access_token":"<NEW_TOKEN>","token_type":"bearer","expires_in":5183944}. The old token keeps working until its own expiry, so you can deploy the new one without a gap. Schedule the refresh well inside the 60 days and alert if it fails.
Revocation takes effect immediately. Use it when a token leaks (Meta’s GET URL, split the same way):
curl --get 'https://graph.facebook.com/<API_VERSION>/oauth/revoke' \
-d 'client_id=<APP_ID>' \
-d 'client_secret=<APP_SECRET>' \
-d 'revoke_token=<TOKEN_TO_REVOKE>' \
-d 'access_token=<YOUR_ACCESS_TOKEN>'
A non-expiring token avoids the refresh job but stays valid until you revoke it. Pick the 60-day option if you’d rather have a stolen token die on its own.
Check a token before you trust it
GET /<API_VERSION>/debug_token?input_token=<TOKEN> returns app_id, expires_at, data_access_expires_at, is_valid, issued_at, scopes and granular_scopes (debug_token reference). Run it at startup and after every refresh. Sending and receiving need whatsapp_business_messaging, so check that it’s in scopes.
Errors 190 and 0
Token failures come back in the Graph error envelope: message, type set to OAuthException, code, error_subcode and fbtrace_id (Graph API error handling). The codes from Meta’s WhatsApp error codes page (accessed 2026-11-02):
| Code | Meta’s text | What to do |
|---|---|---|
| 0 | “We were unable to authenticate the app user.” | Token expired, invalidated, or the user changed a setting. Get a new token. |
| 190 | “Your access token has expired.” | Regenerate the token. |
| 3 | “Capability or permissions issue.” | Check the app’s permissions. |
| 10 | “Permission is either not granted or has been removed.” | Re-grant the permission. |
| 200 | “No access token was provided.” | Send the Authorization header. |
| 200–299 | Permission not granted or removed | Inspect the token with the access token debugger. |
Under code 190, error_subcode narrows the cause. 460 means the password changed, 463 means expired, 467 means an invalid access token, and 458 means the app isn’t installed. A 463 means the token has expired: generate a new one in Business settings and schedule the next refresh earlier. If a client’s business token returns 458, look for a PARTNER_APP_UNINSTALLED webhook on that account and ask the client to connect again.
Don’t retry token errors in a loop. They won’t clear with time, and a queue that retries them fills up while every send fails. Route them to an alert and let the error codes reference sort the rest. For per-client tokens, keep the failure scoped to that client’s queue, as in multi-tenant webhook routing.
Z-API Omni team