Appearance
Set password
Xash appSets the account password using the 5-digit code sent by SMS, and signs you in. It is used in two situations:
- finishing a registration, with the code from Registration;
- resetting a forgotten password, with a code from
POST /api/v1/auth/request-pin-otp.
POST /api/v1/auth/set-password
No token is needed.
Body
| Field | Type | Required | Description |
|---|---|---|---|
user_number | string | Yes | The user number from the SMS. |
otp | string | Yes | The 5-digit code from the SMS. |
password | string | Yes | The new password. At least 8 characters. |
password_confirmation | string | Yes | The password again. |
pin | string | No | A 5-digit PIN to set at the same time. |
pin_confirmation | string | With pin | The 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.
| Status | code | Meaning |
|---|---|---|
422 | otp_invalid | The code is wrong, expired or already used. |
422 | otp_required | No otp was sent. message explains what to do. |
422 | none | A field is invalid or the user number does not exist. Validation error |
429 | none | More 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.