Ymtaz Logo

Login

POSThttps://api.ymtaz.sa/api/v1/auth/login

Authenticates a user and returns a JWT token for subsequent API requests.

Request Body

emailstringRequired

The user's email address.

passwordstringRequired

The user's password.

Response

statusboolean

Indicates if the request was successful.

codenumber

HTTP status code.

data.account.tokenstring

JWT token for authentication.

curl https://api.ymtaz.sa/api/v1/auth/login \
-H "Content-Type: application/json" \
-X POST \
-d '{
  "email": "user@example.com",
  "password": "your_password"
}'

Response

{
"status": true,
"code": 200,
"message": "Login successful",
"data": {
  "account": {
    "email": "user@example.com",
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
  }
}
}

Try it out

Token Validation

GEThttps://api.ymtaz.sa/api/v1/auth/check

Validates if the provided authentication token is valid and returns the associated account information.

Request Headers

AuthorizationstringRequired

Bearer token for authentication (e.g., "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...").

Response

statusboolean

Indicates if the request was successful.

codenumber

HTTP status code.

data.accountobject

Account information if the token is valid.

curl https://api.ymtaz.sa/api/v1/auth/check \
-H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."

Response

{
  "status": true,
  "code": 200,
  "message": "Token is valid",
  "data": {
    "account": {
      "id": 123,
      "email": "user@example.com",
      "account_type": "client"
    }
  }
}

Try it out

Admin Check

GEThttps://api.ymtaz.sa/api/v1/admin/check

Checks if the authenticated user has admin privileges.

Request Headers

AuthorizationstringRequired

Bearer token for authentication (e.g., "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...").

Response

statusboolean

Indicates if the request was successful.

codenumber

HTTP status code.

data.is_adminboolean

Indicates if the user has admin privileges.

curl https://api.ymtaz.sa/api/v1/admin/check \
-H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."

Response

{
  "status": true,
  "code": 200,
  "message": "User is an admin",
  "data": {
    "is_admin": true
  }
}

Try it out