Skip to main content
A hosted session is a signed, expiring link to a page hosted by Shortext, where your user completes a step you cannot do in your own product: logging in to Meta to connect a WhatsApp Business number, or entering and checking mailbox settings. When they are done, they come back to your app and you receive the result. Typical case: you build a product on Shortext, and each of your clients connects their own WhatsApp number to the agent you set up for them.

Flow

1

Create the session (your server)

POST /hosted-sessions with a purpose. The response holds the url of the page.
2

Send your user to the page

Redirect them, or open the URL in a new window. Do not embed it in an iframe: the Meta login refuses it.
3

Your user completes the page

On https://shortext.ny-corp.io/connect/{token}, they log in to Meta or fill in their mailbox settings.
4

Back to your app

Shortext sends them to your return_url with ?session_id={id}&status={status}.
5

Get the result (your server)

Receive the hosted_session.completed or hosted_session.failed webhook, or call GET /hosted-sessions/{id}. Do not trust the status of the return URL alone: anyone can type it.

Purposes

GET /hosted-sessions/purposes lists them.

Create a session

Requires the Manage integrations permission.
string
required
whatsapp or mail.
object
Options of the purpose, for example { "agent_id": "AGI-XXXXX" }. The agent must belong to your company.
string
Your page the user comes back to. HTTPS only.
string
The language of the page, for example fr or en.
integer
default:"60"
Lifetime of the link in minutes, from 5 to 1,440 (24 hours).
Response
The url contains a secret and is only returned at creation. Never log it, never share it with anyone but the user it is for.

Statuses

A session serves one outcome: once it is completed, failed, cancelled or expired, its link stops working. Create a new session to try again.

Result

For both purposes, result lists the connected channels, in the same format as GET /channels:
Keep the channel id: it is the channel_id you send messages from. A channel.connected webhook is also sent for each new channel.

Other endpoints

See the guide Connect a client’s WhatsApp.