Setup
POST
/tw-v2/xchat/setupDescription
Initialize X Chat (encrypted DMs) for your account. This is a required first step before sending encrypted messages.
Note: You must have X Chat already set up in the official X app before using this endpoint.
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
| authToken | string | required | Twitter authentication token (auth_token cookie value) |
| userId | string | required | Your Twitter/X user ID (numeric string) |
| pin | string | required | Your X Chat PIN (4-6 digits) set up in the X app |
| proxy | string | optional | Proxy in format 'hostname:port@username:password' |
Code Examples
const body = {
authToken: 'YOUR_AUTH_TOKEN',
userId: '1234567890123456789',
pin: '123456'
};
const response = await fetch('https://api.tweetapi.com/tw-v2/xchat/setup', {
method: 'POST',
headers: {
'X-API-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify(body)
});
const data = await response.json();
console.log(data);
Response
Success Response (200 OK)
200
{
"status": "ready",
"userId": "1234567890123456789",
"publicKeyVersion": "1763729043842",
"message": "XChat keys recovered successfully. You can now send encrypted messages."
}Error Responses
400s Errors
401
UNAUTHORIZED404
NOT_FOUND400
BAD_REQUEST429
TOO_MANY_REQUESTS500s Errors
500
INTERNAL_SERVER_ERRORAPI Playground
POST
/tw-v2/xchat/setupSensitive Credentials Required
Requires your Twitter authToken. Use a test account.
Press ⌘ + Enter to execute
curl -X POST "https://api.tweetapi.com/tw-v2/xchat/setup" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"Response
Click "Try It!" to see the response