GetXAPI
Users

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.

POST/twitter/user_login_v2

This 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

FieldTypeRequiredDescription
usernamestringYesTwitter username (without @)
emailstringYesThe email address on the account
ms_refresh_tokenstringYes*Microsoft OAuth refresh token for the mailbox (starts with M.C…). Preferred way to give us mailbox access.
ms_client_idstringYes*OAuth client id (GUID) paired with ms_refresh_token.
mail_pwstringNoMailbox password. Legacy alternative; the OAuth pair above is preferred.
totp_secretstringConditionalBase32 TOTP secret, required if the account has authenticator-app 2FA
proxystringNoProxy 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_login first (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_login using new_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:

HTTPcodeMeaning
400n/aMissing username / email, or neither ms_refresh_token+ms_client_id nor mail_pw
404ACCOUNT_NOT_FOUNDAccount not found (suspended, deleted, or renamed)
422VERIFY_REQUIREDX serves an identity check instead of the reset methods
429RECOVERY_RATE_LIMITEDX's per-account reset limit — retry later (30-60 min)
502MODERN_RECOVERY_FAILEDReset could not be completed (mailbox read failed, code timed out, or an unexpected step)
503MODERN_RECOVERY_UNAVAILABLERecovery 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"
  }'

On this page