Check Can DM

POST/tw-v2/xchat/can-dm

Description

Check if users can receive X Chat encrypted DMs. Returns chat permissions including whether they have X Chat enabled and a public key for encryption.

Use this endpoint to verify recipients before attempting to send encrypted messages.

Request Body

ParameterTypeRequiredDescription
authTokenstringrequiredTwitter authentication token (auth_token cookie value)
userIdsstring[]requiredArray of Twitter user IDs to check (1-100 IDs per request)
proxystringoptionalProxy in format 'hostname:port@username:password'

Code Examples

const body = {
  authToken: 'YOUR_AUTH_TOKEN',
  userIds: ['1605533637071769600', '123456789']
};

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

// Check if user can receive X Chat messages
const user = data.users[0];
if (user.chatPermissions?.canDmOnXChat && user.chatPermissions?.hasPublicKey) {
  console.log('User can receive X Chat messages');
} else {
  console.log('User cannot receive X Chat messages');
}

Response

Success Response (200 OK)

200
{
  "users": [
    {
      "id": "1234567890123456789",
      "status": "Found",
      "name": "John Doe",
      "screenName": "johndoe",
      "avatarUrl": "https://pbs.twimg.com/profile_images/default_normal.jpg",
      "chatPermissions": {
        "canDm": true,
        "canDmOnXChat": true,
        "hasPublicKey": true,
        "canBeAddedToGroup": false
      },
      "isProtected": false,
      "isSuspended": false,
      "isBlueVerified": false,
      "isVerified": false
    }
  ]
}

Response Fields

ParameterTypeRequiredDescription
usersarrayrequiredArray of user chat permission results
users[].idstringrequiredTwitter user ID
users[].statusstringrequiredLookup status: 'Found' or 'NotFound'
users[].namestringoptionalUser's display name (only if Found)
users[].screenNamestringoptionalUser's @ handle (only if Found)
users[].avatarUrlstringoptionalURL to user's profile image
users[].chatPermissions.canDmbooleanoptionalWhether you can send regular DMs to this user
users[].chatPermissions.canDmOnXChatbooleanoptionalWhether the user has X Chat enabled
users[].chatPermissions.hasPublicKeybooleanoptionalWhether the user has a public key for encryption
users[].chatPermissions.canBeAddedToGroupbooleanoptionalWhether the user can be added to group chats
users[].isProtectedbooleanoptionalWhether the user's account is protected (private)
users[].isSuspendedbooleanoptionalWhether the user's account is suspended
users[].isBlueVerifiedbooleanoptionalWhether the user has X Premium (blue checkmark)

Understanding Chat Permissions

ScenariocanDmOnXChathasPublicKeyCan Send X Chat?
X Chat enabled & set uptruetrueYes
X Chat enabled, not set uptruefalseNo
X Chat not enabledfalsefalseNo

Tip: Both canDmOnXChat and hasPublicKey must be true to send encrypted X Chat messages to a user.

Error Responses

400s Errors

400BAD_REQUEST
400BAD_REQUEST
400BAD_REQUEST
401UNAUTHORIZED
429TOO_MANY_REQUESTS

API Playground

POST/tw-v2/xchat/can-dm

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

Click "Try It!" to see the response