Skip to content

X Chat Setup

POST/tw-v2/xchat/setup

1 API unit per call · How billing works

Description

Initialize X Chat (encrypted DMs) for your account. This is a required first step before sending encrypted messages. Call it again when the API asks you to, for example after an X Chat PIN change.

Note: You must have X Chat already set up in the official app before using this endpoint.

Request Body

ParameterDescription
authTokenstringrequiredAccount authentication token (auth_token cookie value)
userIdstringrequiredYour Twitter user ID (numeric string)
pinstringrequiredYour X Chat PIN (4-6 digits) set up in the official app
proxystringoptionalProxy in format 'hostname:port@username:password'

Code Examples

const body = {
  authToken: 'YOUR_AUTH_TOKEN',
  userId: '1001937475184068444',
  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": "1001937475184068444",
  "publicKeyVersion": "1767225600000",
  "message": "Sample post text 61903 for documentation."
}

Error Responses

400s Errors

400Wrong X Chat PIN, or X Chat isn't set up for this account. An invalid PIN response says how many attempts remain. Check your PIN in the official app.
404X Chat not found for this user. Set up X Chat in the official app first.
400Session error. Try refreshing your authenticated session.
429Rate limit exceeded, including too many PIN attempts. Wait before retrying.

500s Errors

500Setup failed. Contact support if the issue persists.
503X Chat setup is temporarily unavailable. Try again later.