Skip to Content
WhatsApp API by Retention Stack

Authentication

Which key to use, and what each request looks like with it.

You have two kinds of key. Pick by how many WhatsApp numbers the code talks to.

Session tokenAccount key
Looks likech_live_...ak_live_...
Works onOne WhatsApp numberEvery number on your account
Use it forSending and receiving on that numberCreating sessions, and services that run several numbers
Session name in requestsNot neededRequired on every session request
Where to get itConsole, shown on each sessionConsole → Account API Keys
If it leaksOne number is exposedEvery number is exposed

Send either key in one of these headers. Both work on every endpoint:

Authorization: Bearer YOUR_KEY
x-api-key: YOUR_KEY

The same request with each key

The only difference is the session name. A session token already knows its session. An account key does not, so you name it.

Send a message

With a session token, leave session out:

curl -X POST https://wp-rapidapi.retentionstack.agency/v1/sendText \
  -H "Authorization: Bearer ch_live_YOUR_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"chatId": "15551234567", "text": "Your order is ready."}'

With an account key, add session:

curl -X POST https://wp-rapidapi.retentionstack.agency/v1/sendText \
  -H "Authorization: Bearer ak_live_YOUR_ACCOUNT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"session": "SESSION_NAME", "chatId": "15551234567", "text": "Your order is ready."}'

Endpoints with the session in the path

With a session token, put me where the session name goes. With an account key, put the name:

# session token
curl https://wp-rapidapi.retentionstack.agency/v1/me/auth/qr \
  -H "Authorization: Bearer ch_live_YOUR_SESSION_TOKEN"

# account key
curl https://wp-rapidapi.retentionstack.agency/v1/SESSION_NAME/auth/qr \
  -H "Authorization: Bearer ak_live_YOUR_ACCOUNT_KEY"

Endpoints with the session in the query

Same rule: leave session out with a session token, add ?session=SESSION_NAME with an account key.

Which key each kind of request accepts

RequestSession tokenAccount key
Messages, contacts, groups, presenceIts own sessionAny of your sessions
QR code, pairing code, passkeyIts own sessionAny of your sessions
GET /v1/sessions (list)Returns only its own sessionReturns all your sessions
POST /v1/sessions (create)Not allowed (403)Yes
Billing, account keys, rotating tokensConsole onlyConsole only

A session token sent with another session's name returns 403. It never acts on a session other than its own.

Running several numbers

Create each session with your account key. The response includes the new session's channel_token. Store one token per number, and send each number's messages with its own token. That way your sending code never needs the account key or a session name. See Create a session from code.

Rotating a session token

Rotate a session token from the console. The old token stops working immediately, so deploy the new one first or expect a short outage.

Errors

HTTPCause
401No key, or the key is unknown or revoked
403The session belongs to someone else, a session token named another session, or a session token tried to create a session

Both use the standard error envelope.

Was this page helpful?

On this page