Check Can DM
POST
/tw-v2/xchat/can-dmDescription
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
| Parameter | Type | Required | Description |
|---|---|---|---|
| authToken | string | required | Twitter authentication token (auth_token cookie value) |
| userIds | string[] | required | Array of Twitter user IDs to check (1-100 IDs per request) |
| proxy | string | optional | Proxy 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
| Parameter | Type | Required | Description |
|---|---|---|---|
| users | array | required | Array of user chat permission results |
| users[].id | string | required | Twitter user ID |
| users[].status | string | required | Lookup status: 'Found' or 'NotFound' |
| users[].name | string | optional | User's display name (only if Found) |
| users[].screenName | string | optional | User's @ handle (only if Found) |
| users[].avatarUrl | string | optional | URL to user's profile image |
| users[].chatPermissions.canDm | boolean | optional | Whether you can send regular DMs to this user |
| users[].chatPermissions.canDmOnXChat | boolean | optional | Whether the user has X Chat enabled |
| users[].chatPermissions.hasPublicKey | boolean | optional | Whether the user has a public key for encryption |
| users[].chatPermissions.canBeAddedToGroup | boolean | optional | Whether the user can be added to group chats |
| users[].isProtected | boolean | optional | Whether the user's account is protected (private) |
| users[].isSuspended | boolean | optional | Whether the user's account is suspended |
| users[].isBlueVerified | boolean | optional | Whether the user has X Premium (blue checkmark) |
Understanding Chat Permissions
| Scenario | canDmOnXChat | hasPublicKey | Can Send X Chat? |
|---|---|---|---|
| X Chat enabled & set up | true | true | Yes |
| X Chat enabled, not set up | true | false | No |
| X Chat not enabled | false | false | No |
Tip: Both
canDmOnXChatandhasPublicKeymust betrueto send encrypted X Chat messages to a user.
Error Responses
400s Errors
400
BAD_REQUEST400
BAD_REQUEST400
BAD_REQUEST401
UNAUTHORIZED429
TOO_MANY_REQUESTSAPI Playground
POST
/tw-v2/xchat/can-dmSensitive 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