Skip to main content
POST
/
api
/
login
Login
curl --request POST \
  --url https://api.example.com/api/login \
  --header 'Content-Type: application/json' \
  --data '
{
  "username": "<string>",
  "password": "<string>"
}
'
{
  "access_token": "<string>",
  "token_type": "<string>"
}
Authenticates a user with their email and password, returning a JWT access token that can be used for subsequent authenticated requests.

Request

This endpoint uses OAuth2 password flow with form data.
username
string
required
The user’s email address (note: the field is named “username” per OAuth2 spec, but should contain the email)
password
string
required
The user’s password

Response

access_token
string
The JWT access token to use for authenticated requests
token_type
string
The token type, always “bearer”

Example Request

curl -X POST http://localhost:8000/api/login \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "[email protected]&password=securepassword123"

Example Response

{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "token_type": "bearer"
}

Error Responses

Usage

After receiving the access token, include it in the Authorization header for authenticated requests:
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

Build docs developers (and LLMs) love