Conversation History

POST/tw-v2/xchat/history

Description

Get decrypted conversation history for an end-to-end encrypted X Chat conversation. Returns messages in decrypted plaintext with metadata.

Prerequisite: You must call /xchat/setup first before fetching history.

Request Body

ParameterTypeRequiredDescription
authTokenstringrequiredTwitter authentication token (auth_token cookie value)
conversationIdstringrequiredConversation ID in format 'userId1:userId2' (both user IDs separated by colon)
cursorstringoptionalPagination cursor from previous response (nextCursor value)
limitnumberoptionalMaximum number of messages to return (1-200, default: 200)
proxystringoptionalProxy in format 'hostname:port@username:password'

Code Examples

const body = {
  authToken: 'YOUR_AUTH_TOKEN',
  conversationId: '1234567890123456789:9876543210987654321'
};

const response = await fetch('https://api.tweetapi.com/tw-v2/xchat/history', {
  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);

Pagination Example

// Fetch next page using cursor from previous response
const body = {
  authToken: 'YOUR_AUTH_TOKEN',
  conversationId: '1234567890123456789:9876543210987654321',
  cursor: '2011466279383891968' // nextCursor from previous response
};

const response = await fetch('https://api.tweetapi.com/tw-v2/xchat/history', {
  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
{
  "messages": [
    {
      "id": "2011476201525952514",
      "messageId": "72afe3e1-38c7-4b4b-9e45-b55347162a2d",
      "senderId": "1234567890123456789",
      "text": "Hello!",
      "timestamp": 1736847291525,
      "conversationKeyVersion": "1768394917884"
    },
    {
      "id": "2011475490973106178",
      "messageId": "7b9effa8-5f40-45d8-ba5f-c71ca4852a75",
      "senderId": "9876543210987654321",
      "text": "Hi, how are you?",
      "timestamp": 1736847190973,
      "conversationKeyVersion": "1768394917884"
    }
  ],
  "hasMore": true,
  "nextCursor": "2011475490973106178"
}

Response Fields

ParameterTypeRequiredDescription
messagesarrayrequiredArray of decrypted messages
messages[].idstringrequiredMessage sequence ID (used for pagination)
messages[].messageIdstringrequiredUnique message UUID
messages[].senderIdstringrequiredTwitter/X user ID of the message sender
messages[].textstringrequiredDecrypted message text
messages[].timestampnumberrequiredMessage timestamp in milliseconds
hasMorebooleanrequiredWhether more messages are available
nextCursorstring | nullrequiredCursor for fetching the next page (null if no more messages)

Error Responses

400s Errors

400BAD_REQUEST
400BAD_REQUEST
400BAD_REQUEST
404NOT_FOUND
404NOT_FOUND
401UNAUTHORIZED
429TOO_MANY_REQUESTS

API Playground

POST/tw-v2/xchat/history

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/history" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json"
Response

Click "Try It!" to see the response