Skip to content

Set password ​

Xash app

Sets the account password using the 5-digit code sent by SMS, and signs you in. It is used in two situations:

POST /api/v1/auth/set-password

No token is needed.

Body ​

FieldTypeRequiredDescription
user_numberstringYesThe user number from the SMS.
otpstringYesThe 5-digit code from the SMS.
passwordstringYesThe new password. At least 8 characters.
password_confirmationstringYesThe password again.
pinstringNoA 5-digit PIN to set at the same time.
pin_confirmationstringWith pinThe PIN again.

Example ​

bash
curl -X POST https://app.xash.co.zw/api/v1/auth/set-password \
  -H "Content-Type: application/json" \
  -d '{
    "user_number": "1234567890",
    "otp": "00000",
    "password": "YOUR_PASSWORD",
    "password_confirmation": "YOUR_PASSWORD"
  }'

Response 200 ​

json
{
  "success": true,
  "token": "41|EXAMPLEsessionTOKENdoNOTuse000000000000000000",
  "tokenType": "Bearer",
  "has_address": false,
  "has_business": false,
  "message": "Password set successfully."
}

This is the same body as Sign in: token is a session token you can use straight away, for example to create a server token.

When this call resets a password (the account already had a password or a PIN), all existing session tokens are deleted. Server tokens keep working.

Errors ​

These two failures use the key code, not error_code.

StatuscodeMeaning
422otp_invalidThe code is wrong, expired or already used.
422otp_requiredNo otp was sent. message explains what to do.
422noneA field is invalid or the user number does not exist. Validation error
429noneMore than 5 attempts in a minute from this IP, or 10 in an hour, for this account.
json
{
  "success": false,
  "code": "otp_invalid",
  "message": "Invalid or expired verification code."
}

After 5 wrong codes the code is cancelled. Request a new one.

Why otp can be absent

Old versions of the Xash app did not send otp. Xash can allow them to finish a registration that has only just started without it. That allowance is off by default and never applies to an account that already has a password. A new integration must always send otp.