Developers
App sign-in
The company apps (driver, carrier and shipper) sign a person in with their email and password on one device, and receive a short-lived access token and a longer-lived refresh token. These routes are for those apps. A company key, described in the Company keys guide, is a different thing: it belongs to a system, not to a person on a device.
Before signing in
GET /app/config needs no sign-in. Send the optional values app, platform and version (for example 1.4.2) as query values and read sign_in_open (false while sign-in is closed), maintenance (on, and a message in each language), minimum_version, update_required (true when your version is below the minimum, null when you did not send one) and flags. The answer is the same for everyone who sends the same three values, and you may keep it for one minute.
curl "https://tawasulone.com/api/v1/app/config?app=driver&platform=android&version=1.4.2"
Signing in
POST /app/sessions with the person's email and password, the app (driver, carrier or shipper), a device_id (8 to 64 characters: letters, digits and . _ - , the same for as long as the app stays installed), the platform (android or ios) and, if you wish, device_name, app_version and device_token, the trusted-device token if you hold one: when it is accepted no second step is needed and the answer carries a new device_token that replaces the earlier one, and when it is not, the second step is asked as usual. One device has one open session: signing in again on the same device ends the earlier session, and the person is told each time they sign in.
curl -X POST -H "Content-Type: application/json" -d '{"email": "<EMAIL>", "password": "<PASSWORD>", "app": "driver", "device_id": "<A_STABLE_DEVICE_ID>", "platform": "android"}' "https://tawasulone.com/api/v1/app/sessions"
On success the answer is 201 with token_type (Bearer), access_token and access_expires_at, refresh_token and refresh_expires_at, the session (uuid, app and ends_at, the moment the session ends whatever you do) and the user (uuid, name and locale). Which people may use which app depends on their role; a person who may not use the app gets the same refusal as a wrong password.
{
"success": true,
"data": {
"token_type": "Bearer",
"access_token": "<ACCESS_TOKEN>",
"access_expires_at": "2026-06-01T07:55:00Z",
"refresh_token": "<REFRESH_TOKEN>",
"refresh_expires_at": "2026-07-01T07:40:00Z",
"session": { "uuid": "<SESSION_UUID>", "app": "driver", "ends_at": "2026-09-01T07:40:00Z" },
"user": { "uuid": "<USER_UUID>", "name": "<NAME>", "locale": "ar" }
}
}
When a second step is needed
If the account needs a second factor, the answer is 202 with second_factor: a challenge_id, the methods that can answer it (app, email or phone) and expires_at. For email or phone, POST /app/sessions/second-factor/send with the challenge_id and the method first; the answer is 202 with sent true. Then POST /app/sessions/second-factor/verify with the challenge_id, the method and the code: success is the 201 answer above, and a wrong code is 422 with code in error.details. The verify call also accepts the method recovery_code with one of the account's recovery codes. With the verify call you may send trust_device true to ask to trust this device: when the platform offers that to the account, the 201 answer carries a device_token; it is never offered after a recovery code. A challenge serves one sign-in and expires; sign in again when it does.
{
"success": true,
"data": {
"second_factor": {
"challenge_id": "<CHALLENGE_ID>",
"methods": ["email", "phone"],
"expires_at": "2026-06-01T07:50:00Z"
}
}
}
Using and renewing the session
Send the access token with every call in this header:
Authorization: Bearer <ACCESS_TOKEN>
The access token lasts a short time (access_expires_at). Renew with POST /app/sessions/refresh and the refresh_token: the answer has the shape of a sign-in, with a new access token and a new refresh token. A refresh token works once, so keep the new one and drop the previous one. If one that was already used is sent again, the session ends and the person must sign in again; so they must when the refresh token expires, when the session reaches its ends_at, or when the person may no longer use the app.
curl -X POST -H "Content-Type: application/json" -d '{"refresh_token": "<REFRESH_TOKEN>"}' "https://tawasulone.com/api/v1/app/sessions/refresh"
Reading and ending the session
GET /app/session with the access token returns this session's uuid, app, device_name, platform, app_version, opened_at and ends_at, the person's own company (company: its uuid and name in their language, null when they have none) and abilities, the scopes this token holds, which are the ones that decide every 403. DELETE /app/session ends it at once and answers 204.
When it fails
A wrong email or password, an unknown, used or expired refresh token, and a person who may not use the app all answer 401 with WWW-Authenticate: Bearer, and never say which part was wrong. Too many attempts answer 429 with Retry-After, the seconds to wait. While sign-in is closed the answer is 503 with Retry-After. A device_id that is not valid is 422 with device_id in error.details. Handle every other code as the Errors guide describes.
Keep both tokens, and the device_token if you have one, in the device's secure storage, never in a log, a URL or a screenshot, and send them only over HTTPS.