EMTITHAL uses JWT Bearer tokens. All protected endpoints require an Authorization: Bearer <token> header.
Create a new account with an email and password. A verification email is sent automatically.
POST https://api.emtithal.aisc.sa/api/v1/auth/register
Content-Type: application/json
{
"email": "engineer@example.sa",
"password": "YourSecurePassword!"
}
After registering, an OTP is emailed. Submit it to activate your account:
POST https://api.emtithal.aisc.sa/api/v1/auth/verify-email
Content-Type: application/json
{
"email": "engineer@example.sa",
"otp": "123456"
}
Exchange credentials for a short-lived access token and a longer-lived refresh token:
POST https://api.emtithal.aisc.sa/api/v1/auth/login
Content-Type: application/json
{
"email": "engineer@example.sa",
"password": "YourSecurePassword!"
}
// Response:
{
"access_token": "eyJhbGci...",
"refresh_token": "eyJhbGci...",
"token_type": "bearer",
"expires_in": 900
}
Add the Authorization header to every protected request:
GET https://api.emtithal.aisc.sa/api/v1/auth/me
Authorization: Bearer eyJhbGci...
Accept-Language: ar
Access tokens expire in 15 minutes. Use the refresh token to get a new pair without re-logging in:
POST https://api.emtithal.aisc.sa/api/v1/auth/refresh
Content-Type: application/json
{
"refresh_token": "eyJhbGci..."
}
Invalidate all tokens for the current session:
POST https://api.emtithal.aisc.sa/api/v1/auth/logout
Authorization: Bearer eyJhbGci...
Auth errors return bilingual JSON envelopes. Common codes:
| Code | HTTP | Meaning (EN) | Meaning (AR) |
|---|---|---|---|
AUTH.INVALID_CREDENTIALS | 401 | Email or password is incorrect | البريد الإلكتروني أو كلمة المرور غير صحيحة |
AUTH.EMAIL_NOT_VERIFIED | 403 | Email address must be verified before logging in | يجب التحقق من البريد الإلكتروني قبل تسجيل الدخول |
AUTH.INVALID_TOKEN | 401 | Access token is invalid or expired | رمز الوصول غير صالح أو منتهي الصلاحية |
AUTH.SESSION_EXPIRED | 401 | Your session has expired. Please log in again | انتهت جلستك. يرجى تسجيل الدخول من جديد |
AUTH.MISSING_TOKEN | 401 | Authorization header with Bearer token is required | يجب إرسال رمز Bearer في ترويسة التفويض |
AUTH.EMAIL_ALREADY_REGISTERED | 409 | An account with this email already exists | يوجد حساب مسجل بهذا البريد الإلكتروني |
Send Accept-Language: ar or Accept-Language: en on any request. All error responses carry both languages in the bilingual envelope; this header controls which language is primary.