Skip to main content

POST /api/auth/login

Authenticate with email and password to receive JWT tokens for API access.

Request Body

email
string
required
User’s email address. Must be a valid email format.
password
string
required
User’s password. Minimum 8 characters.

Response

success
boolean
required
Indicates if the request was successful
data
object
user
object
id
string
User’s unique identifier (UUID)
email
string
User’s email address
name
string
User’s full name
role
string
User’s role: org_admin, branch_manager, cashier, waiter, or kitchen
organizationId
string
Organization ID the user belongs to
branches
array
Array of branch IDs the user has access to
accessToken
string
JWT access token for authenticating API requests
refreshToken
string
JWT refresh token for obtaining new access tokens (valid for 7 days)

Error Responses

401 Unauthorized
Returned when credentials are invalid or user account is inactive.
{
  "success": false,
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Credenciales inválidas"
  }
}

Example Request

curl -X POST https://api.restai.com/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "securepassword123"
  }'

Example Response

{
  "success": true,
  "data": {
    "user": {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "email": "[email protected]",
      "name": "John Doe",
      "role": "org_admin",
      "organizationId": "123e4567-e89b-12d3-a456-426614174001",
      "branches": ["123e4567-e89b-12d3-a456-426614174002"]
    },
    "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
  }
}

Build docs developers (and LLMs) love