Login
curl --request POST \
--url https://api.example.com/api/auth/login \
--header 'Content-Type: application/json' \
--data '
{
"email": "<string>",
"password": "<string>"
}
'import requests
url = "https://api.example.com/api/auth/login"
payload = {
"email": "<string>",
"password": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({email: '<string>', password: '<string>'})
};
fetch('https://api.example.com/api/auth/login', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/auth/login",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'email' => '<string>',
'password' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/auth/login"
payload := strings.NewReader("{\n \"email\": \"<string>\",\n \"password\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/auth/login")
.header("Content-Type", "application/json")
.body("{\n \"email\": \"<string>\",\n \"password\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/auth/login")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"email\": \"<string>\",\n \"password\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"accessToken": "<string>",
"refreshToken": "<string>",
"expiresIn": 123,
"requiresPasswordChange": true,
"session": "<string>",
"username": "<string>"
}Authentication
Login
Authenticates a user with email and password
POST
/
api
/
auth
/
login
Login
curl --request POST \
--url https://api.example.com/api/auth/login \
--header 'Content-Type: application/json' \
--data '
{
"email": "<string>",
"password": "<string>"
}
'import requests
url = "https://api.example.com/api/auth/login"
payload = {
"email": "<string>",
"password": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({email: '<string>', password: '<string>'})
};
fetch('https://api.example.com/api/auth/login', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/auth/login",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'email' => '<string>',
'password' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/auth/login"
payload := strings.NewReader("{\n \"email\": \"<string>\",\n \"password\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/auth/login")
.header("Content-Type", "application/json")
.body("{\n \"email\": \"<string>\",\n \"password\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/auth/login")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"email\": \"<string>\",\n \"password\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"accessToken": "<string>",
"refreshToken": "<string>",
"expiresIn": 123,
"requiresPasswordChange": true,
"session": "<string>",
"username": "<string>"
}Authenticates a user with email and password. Returns Cognito access/id/refresh tokens on success, or a
NEW_PASSWORD_REQUIRED challenge on first login when an admin has created the account with a temporary password.
Authentication
This is a public endpoint that does not require authentication.Rate Limiting
This endpoint is rate-limited to 5 requests per minute per IP address.Request Body
string
required
User email address (case-insensitive, will be lowercased automatically)Must be a valid email format.Example:
user@example.comstring
required
User passwordMust be at least 8 characters long.Example:
MyP@ssw0rd!Request Example
curl -X POST https://api.example.com/api/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "MyP@ssw0rd!"
}'
Response
Success Response (200 OK)
The response varies depending on whether this is a first-time login:Standard Login Success
string
Cognito JWT access token used for API authenticationPass this token in the
Authorization: Bearer <token> header for authenticated requests.string
Cognito refresh token used to obtain new access tokensUse this with the
/api/auth/refresh-token endpoint when the access token expires.number
Token expiration time in secondsTypically 3600 (1 hour).
boolean
Indicates whether a password change is requiredWill be
false for standard login success.{
"accessToken": "eyJraWQiOiJxYz...",
"refreshToken": "eyJjdHkiOiJKV1QiLCJlbmMiOiJBMjU2R0NNIiwiYWxnIjoiUlNBLU9BRVAifQ...",
"expiresIn": 3600,
"requiresPasswordChange": false
}
First-Time Login (Password Change Required)
When an admin creates a user account with a temporary password, the first login returns a challenge:boolean
Set to
true to indicate password change is requiredstring
Session token for completing the password change challengeMust be provided to the
/api/auth/complete-password-change endpoint.string
Username (email) of the account
{
"requiresPasswordChange": true,
"session": "AYABeD...",
"username": "user@example.com"
}
Error Responses
Validation error — Invalid email format or password too short
{
"statusCode": 400,
"message": ["email must be an email", "password must be longer than or equal to 8 characters"],
"error": "Bad Request"
}
Invalid credentials — Email or password is incorrectThe response is intentionally generic to prevent user enumeration attacks.
{
"statusCode": 401,
"message": "Invalid credentials",
"error": "Unauthorized"
}
Rate limit exceeded — More than 5 requests in 1 minute
{
"statusCode": 429,
"message": "Too many requests",
"error": "Too Many Requests"
}
Notes
- Email addresses are automatically lowercased and trimmed for consistency
- The endpoint returns generic error messages on authentication failure to prevent user enumeration
- Access tokens are JWTs that expire after 1 hour (3600 seconds)
- Refresh tokens are long-lived and can be used to obtain new access tokens without re-entering credentials
- On first login with a temporary password, you must complete the password change flow using
/api/auth/complete-password-change
⌘I