Appearance
Sign in
Exchange your user number and password (or PIN) for a session token.
POST /api/v1/auth/login
No Authorization header is needed.
Body
| Field | Type | Required | Description |
|---|---|---|---|
user_number | string | Yes | Your Xash user number. It was sent to you by SMS when you registered. |
password | string | Yes, unless pin is sent | Your account password. |
pin | string | Yes, unless password is sent | Your 5-digit PIN, if you set one in the Xash app. |
Send password or pin. For a server integration use the password.
Example
bash
curl -X POST https://app.xash.co.zw/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"user_number":"1234567890","password":"YOUR_PASSWORD"}'Response 200
json
{
"success": true,
"token": "41|EXAMPLEsessionTOKENdoNOTuse000000000000000000",
"tokenType": "Bearer",
"has_address": false,
"has_business": false,
"message": "Login successful."
}| Field | Description |
|---|---|
token | A session token. Send it as Authorization: Bearer <token>. |
tokenType | Always Bearer. |
has_address, has_business | Whether the account has a home address and business details. The Xash app uses these to ask for them. They do not restrict purchases. |
Each sign-in creates a new session token. Earlier ones keep working.
Next, create a server token and use that from your backend.
Errors
| Status | When | Body |
|---|---|---|
401 | Wrong user number, password or PIN. | {"success": false, "message": "Invalid user number, password or PIN"} |
422 | A field is missing or malformed. | Validation error |
429 | More than 5 attempts in a minute for this account from this IP. | {"message": "Too Many Attempts."} |
Sign out
POST /api/v1/auth/logout
Deletes the token the request was made with. Other tokens are not affected.
json
{
"success": true,
"message": "Logout successful."
}WARNING
If you call this with a server token, that server token is deleted. To retire a server token, prefer revoking it by id.
Forgotten password
A password is reset with a code sent by SMS to the account's phone:
POST /api/v1/auth/request-pin-otpsends the code.POST /api/v1/auth/set-passwordwith that code sets a new password and returns a session token.
Resetting the password deletes all session tokens. Server tokens keep working.