Setup

POST/tw-v2/xchat/setup

Description

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

ParameterTypeRequiredDescription
authTokenstringrequiredTwitter authentication token (auth_token cookie value)
userIdstringrequiredYour Twitter/X user ID (numeric string)
pinstringrequiredYour X Chat PIN (4-6 digits) set up in the X app
proxystringoptionalProxy 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

401UNAUTHORIZED
404NOT_FOUND
400BAD_REQUEST
429TOO_MANY_REQUESTS

500s Errors

500INTERNAL_SERVER_ERROR

API Playground

POST/tw-v2/xchat/setup

Sensitive 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