1
Get a user token for your bot
Every endpoint needs a user-context token for the account your agent speaks as; app-only bearer tokens are rejected. With OAuth 2.0 (Authorization Code with PKCE), request
tweet.read, users.read, dm.read and dm.write, which cover every Calls endpoint. See Authentication for the per-endpoint scopes and OAuth 1.0a.2
Create a call
join_url with the people you want in it.conversation_id of your bot’s conversation with them. See Calling people.3
Join the call
Choose the sample rate your agent works at. It applies in both directions.Open the media WebSocket before
expires_at. The media_token works once.4
Connect your agent
Open The session starts with
media_url with the media token. Binary frames carry audio (PCM16 little-endian mono at your sample rate); text frames carry JSON events from X and commands to X.session.created, then session.joined once your agent is in the call. See Media WebSocket for every event and command, and Example agent for a complete program.5
Leave
Send
{"type": "leave"} on the WebSocket, call POST /2/calls/:id/leave, or close the socket. Your WebSocket receives session.ended with the reason.Next steps
Media WebSocket
Session lifecycle, events, commands and turn-taking.
Scheduled calls
Put calls on the calendar and find the ones to join.