User Login V2 (Recovery)
Recover a Twitter/X account with a dead token and changed password via the mailbox. Returns fresh tokens + a new password. $0.005 per call.
/twitter/user_login_v2This endpoint costs $0.005 per API call.
Recovers an account when the normal User Login can't authenticate — i.e. the auth_token is dead and the password was changed after the account was captured (common with resold accounts). It regains access by resetting the password through the account's mailbox and returns fresh tokens plus a new password.
Save the returned new_password. This flow sets a new password on the account — the old password no longer works.
This is the one-call version: we drive X's current reset flow and read the emailed code ourselves over Microsoft OAuth IMAP. If you don't have mailbox access, use the two-step Reset Password flow instead.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
username | string | Yes | Twitter username (without @) |
email | string | Yes | The email address on the account |
ms_refresh_token | string | Yes* | Microsoft OAuth refresh token for the mailbox (starts with M.C…). Preferred way to give us mailbox access. |
ms_client_id | string | Yes* | OAuth client id (GUID) paired with ms_refresh_token. |
mail_pw | string | No | Mailbox password. Legacy alternative; the OAuth pair above is preferred. |
totp_secret | string | Conditional | Base32 TOTP secret, required if the account has authenticator-app 2FA |
proxy | string | No | Proxy URL. Recommended so the recovery IP matches the IP used for later writes. |
* Supply either ms_refresh_token + ms_client_id, or mail_pw.
Email Provider Support
The automatic mailbox read supports Hotmail / Outlook / Live via Microsoft OAuth. Gmail and Yahoo are not supported — use the two-step Reset Password flow for those (the account owner reads the code).
Notes
- Try
/user_loginfirst (fast, no password change). If it fails with dead-token / wrong-password errors, fall back to/user_login_v2. - 2FA: authenticator-app (TOTP) is handled via
totp_secret. If X asks for a passkey after the reset, the password is still set but no tokens are returned — finish with/user_loginusingnew_password. - X limits reset attempts per account; repeated calls can return
RECOVERY_RATE_LIMITED(429) for 30-60 minutes.
Response (200)
Same shape as /user_login, plus new_password:
{
"username": "myaccount",
"new_password": "Gx7c266vra3z",
"auth_token": "a3b02c3782dc4f...",
"ct0": "e63a5e4d0a...",
"twid": "u=143711528",
"profile": { "...": "..." }
}If auth_token is null, the password was reset (new_password is returned) but X required a 2FA method we can't satisfy (passkey). Call /user_login with the new password to finish.
Error Responses
Errors include a code field identifying the reason:
| HTTP | code | Meaning |
|---|---|---|
| 400 | n/a | Missing username / email, or neither ms_refresh_token+ms_client_id nor mail_pw |
| 404 | ACCOUNT_NOT_FOUND | Account not found (suspended, deleted, or renamed) |
| 422 | VERIFY_REQUIRED | X serves an identity check instead of the reset methods |
| 429 | RECOVERY_RATE_LIMITED | X's per-account reset limit — retry later (30-60 min) |
| 502 | MODERN_RECOVERY_FAILED | Reset could not be completed (mailbox read failed, code timed out, or an unexpected step) |
| 503 | MODERN_RECOVERY_UNAVAILABLE | Recovery worker busy/unreachable — retry shortly |
Example
curl -X POST "https://api.getxapi.com/twitter/user_login_v2" \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-d '{
"username": "myaccount",
"email": "myaccount@hotmail.com",
"ms_refresh_token": "M.C512_BAY.0.U.-Ct…",
"ms_client_id": "9e5f94bc-e8a4-4e73-b8be-63364c29d753",
"totp_secret": "SXGS5MN2IHUMV34H",
"proxy": "http://user:pass@host:port"
}'User LoginUpdated
Get fresh auth tokens for a Twitter account via API. Required for write endpoints like tweeting and DMs. GetXAPI login endpoint docs.
Reset Password (two-step)New
Two-step Twitter/X account recovery — you trigger the reset, the owner supplies the emailed code, you get fresh tokens. Works for any mailbox. $0.005 per step.