Skip to main content
POST
/
api
/
v1
/
auth
/
login
Login
curl --request POST \
  --url https://api.example.com/api/v1/auth/login \
  --header 'Content-Type: application/json' \
  --data '
{
  "email": "<string>",
  "phone": "<string>",
  "password": "<string>"
}
'
{
  "status": 123,
  "data": {
    "token": "<string>",
    "token_type": "<string>",
    "user": {
      "id": 123,
      "name": "<string>",
      "email": "<string>",
      "roles": [
        {
          "id": 123,
          "name": "<string>"
        }
      ],
      "permissions": [
        {
          "id": 123,
          "name": "<string>"
        }
      ]
    }
  }
}

Authentication

This endpoint does not require authentication.

Request Body

email
string
User’s email address. Required if phone is not provided.Validation: Must be a valid email format.Example: [email protected]
phone
string
User’s phone number. Required if email is not provided.Validation: Maximum 20 characters.Example: +525512345678
password
string
required
User’s password.Validation: Required string.Example: password123
You must provide either email or phone, but not both. The system will authenticate using whichever identifier is provided.

Response

status
integer
HTTP status code (200 for success)
data
object

Success Response Example

{
  "status": 200,
  "data": {
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIxIiwianRpIjoiYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoiLCJpYXQiOjE3MDk4NTYwMDAsIm5iZiI6MTcwOTg1NjAwMCwiZXhwIjoxNzQxMzkyMDAwLCJzdWIiOiIxIiwic2NvcGVzIjpbXX0...",
    "token_type": "Bearer",
    "user": {
      "id": 1,
      "name": "John Doe",
      "email": "[email protected]",
      "roles": [
        {
          "id": 1,
          "name": "admin"
        }
      ],
      "permissions": [
        {
          "id": 5,
          "name": "view-items"
        },
        {
          "id": 12,
          "name": "create-inventory"
        }
      ]
    }
  }
}

Error Responses

Code Examples

curl -X POST https://api.sushigo.local/api/v1/auth/login \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "password123"
  }'

Usage Notes

  • Store the returned token securely (e.g., in localStorage or a secure cookie)
  • Include the token in subsequent API requests using the Authorization: Bearer {token} header
  • The token does not expire automatically but can be revoked via the logout endpoint
  • User roles and permissions are included in the response for client-side authorization checks

Build docs developers (and LLMs) love