GetXAPI
Users

Reset Password (two-step)

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.

POST/twitter/reset-password/send-code

A two-step recovery flow for when you don't have (or can't read) the mailbox: you trigger the reset, the account owner reads the emailed code from their own inbox and hands it back, and we complete the reset and return fresh tokens. Because the owner reads the code, this works for any email provider, including Hotmail/Outlook, Gmail and Yahoo.

It sets a new password we control and returns fresh auth_token / ct0 / twid. Each step costs $0.005 per call.

This drives X's current password-reset flow (the old account/* form flow has been retired by X). Step 1 also returns the masked recovery email X shows (e.g. ja***@***.com), so you can confirm the code went to the right inbox.

Step 1 — Send the code

POST/twitter/reset-password/send-code

Triggers X's reset email for the account and returns a session_id.

Request Body

FieldTypeRequiredDescription
usernamestringYesTwitter username or email on the account
proxystringNoProxy URL for the reset trigger

Response (200)

{
  "status": "success",
  "session_id": "5760cef9872e200dd0ebe3d3",
  "expires_in": 600,
  "method": "email",
  "masked_email": "Email ja****************@*******.com"
}

The reset session is held server-side for ~10 minutes.

X limits reset attempts per account. A few send-code calls in a short window return RECOVERY_RATE_LIMITED (429), and repeated attempts extend the cooldown — which can run 30-60 minutes. Retry later rather than immediately.

Step 2 — Confirm with the code

POST/twitter/reset-password/confirm

Completes the reset with the code the owner received, and returns fresh tokens plus the new password.

Save the returned new_password. It's the account's password now.

Request Body

FieldTypeRequiredDescription
session_idstringYesFrom step 1
codestringYesThe code the owner read from their email (6 digits)
totp_secretstringConditionalBase32 TOTP secret, required if the account has authenticator-app 2FA

Response (200)

{
  "username": "myaccount",
  "new_password": "Gx7hcuyxk5xr",
  "auth_token": "59bace0de501...",
  "ct0": "9959...",
  "twid": "u=155977652",
  "profile": { "...": "..." }
}

A 422 with new_password means the reset succeeded. X asked for a 2FA method we can't satisfy (a passkey), so no session tokens were issued — but the password was changed. Finish by calling User Login with new_password.

Error Responses

Errors include a code field:

HTTPcodeMeaning
404ACCOUNT_NOT_FOUNDAccount not found (suspended, deleted, or renamed)
410SESSION_EXPIREDUnknown/expired session_id (or the parked browser session timed out) — start again at step 1
409SESSION_BUSYA confirm is already in progress for this session — retry shortly
400CODE_REJECTEDWrong code; the session stays valid — retry with the correct code
400NO_CODEMissing code
422VERIFY_REQUIREDX serves an "Confirm your account" identity check instead of the method list
422(no code) — response carries new_passwordReset succeeded, but X required a passkey we can't satisfy, so no tokens. Use new_password with User Login.
429RECOVERY_RATE_LIMITEDX's per-account reset limit — wait (can be 30-60 min)
503MODERN_RECOVERY_UNAVAILABLEThe reset worker is busy/unreachable — retry shortly

When to use which

  • User Login V2 — one call, when you have the mailbox OAuth credentials and it's a supported provider (Hotmail/Outlook).
  • This two-step flow — when you don't have mailbox access, the provider isn't auto-readable (Gmail/Yahoo), or the account owner is in the loop to read the code.

Example

# 1) send the code
curl -X POST "https://api.getxapi.com/twitter/reset-password/send-code" \
  -H "Authorization: Bearer API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "username": "myaccount" }'

# 2) confirm with the code the owner received
curl -X POST "https://api.getxapi.com/twitter/reset-password/confirm" \
  -H "Authorization: Bearer API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "session_id": "<from step 1>", "code": "276019", "totp_secret": "SXGS5MN2IHUMV34H" }'

On this page