curl --request POST \
--url https://your-instance.example.com/api/auth/login \
--header 'Content-Type: application/json' \
--data '
{
"email": "ops@acme.example",
"password": "CorrectHorseBatteryStaple!"
}
'import requests
url = "https://your-instance.example.com/api/auth/login"
payload = {
"email": "ops@acme.example",
"password": "CorrectHorseBatteryStaple!"
}
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: 'ops@acme.example', password: 'CorrectHorseBatteryStaple!'})
};
fetch('https://your-instance.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://your-instance.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' => 'ops@acme.example',
'password' => 'CorrectHorseBatteryStaple!'
]),
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://your-instance.example.com/api/auth/login"
payload := strings.NewReader("{\n \"email\": \"ops@acme.example\",\n \"password\": \"CorrectHorseBatteryStaple!\"\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://your-instance.example.com/api/auth/login")
.header("Content-Type", "application/json")
.body("{\n \"email\": \"ops@acme.example\",\n \"password\": \"CorrectHorseBatteryStaple!\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://your-instance.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\": \"ops@acme.example\",\n \"password\": \"CorrectHorseBatteryStaple!\"\n}"
response = http.request(request)
puts response.read_body{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI1Zjdi...",
"refreshToken": "rt_64d2f9c5e8a1d4e001a0b1c2e6f7a8b9",
"sessionConfig": {
"enabled": true,
"idleTimeoutMinutes": 30,
"tokenExpiryHours": 8,
"warningTimeMinutes": 2
},
"user": {
"id": "5f7b1c2e8a1d4e0012c3b4a5",
"email": "admin@acme.example",
"fullName": "Acme Admin",
"organizationId": "64a1b2c3d4e5f60012345678",
"accessRole": "ADMIN"
}
}{
"error": "Invalid or expired token",
"code": "TOKEN_EXPIRED"
}{
"error": "Invalid or expired token",
"code": "TOKEN_EXPIRED"
}{
"error": "Invalid or expired token",
"code": "TOKEN_EXPIRED"
}Login with password or impersonation token
Authenticate a user with email + password or with an impersonation token issued by /api/auth/impersonate/. On success returns an access token, a refresh token, the user payload, and the resolved session config.
curl --request POST \
--url https://your-instance.example.com/api/auth/login \
--header 'Content-Type: application/json' \
--data '
{
"email": "ops@acme.example",
"password": "CorrectHorseBatteryStaple!"
}
'import requests
url = "https://your-instance.example.com/api/auth/login"
payload = {
"email": "ops@acme.example",
"password": "CorrectHorseBatteryStaple!"
}
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: 'ops@acme.example', password: 'CorrectHorseBatteryStaple!'})
};
fetch('https://your-instance.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://your-instance.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' => 'ops@acme.example',
'password' => 'CorrectHorseBatteryStaple!'
]),
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://your-instance.example.com/api/auth/login"
payload := strings.NewReader("{\n \"email\": \"ops@acme.example\",\n \"password\": \"CorrectHorseBatteryStaple!\"\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://your-instance.example.com/api/auth/login")
.header("Content-Type", "application/json")
.body("{\n \"email\": \"ops@acme.example\",\n \"password\": \"CorrectHorseBatteryStaple!\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://your-instance.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\": \"ops@acme.example\",\n \"password\": \"CorrectHorseBatteryStaple!\"\n}"
response = http.request(request)
puts response.read_body{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI1Zjdi...",
"refreshToken": "rt_64d2f9c5e8a1d4e001a0b1c2e6f7a8b9",
"sessionConfig": {
"enabled": true,
"idleTimeoutMinutes": 30,
"tokenExpiryHours": 8,
"warningTimeMinutes": 2
},
"user": {
"id": "5f7b1c2e8a1d4e0012c3b4a5",
"email": "admin@acme.example",
"fullName": "Acme Admin",
"organizationId": "64a1b2c3d4e5f60012345678",
"accessRole": "ADMIN"
}
}{
"error": "Invalid or expired token",
"code": "TOKEN_EXPIRED"
}{
"error": "Invalid or expired token",
"code": "TOKEN_EXPIRED"
}{
"error": "Invalid or expired token",
"code": "TOKEN_EXPIRED"
}Body
Provide either password or impersonationToken with email.
Login email; used to look up the user before credential check.
Plain-text password; verified via WorkOS when the user is migrated, otherwise via the local bcrypt hash. Mutually exclusive with impersonationToken.
Single-use JWT issued by /api/auth/impersonate/{userId}; must carry the isImpersonation flag and match email. Mutually exclusive with password.
Response
Login successful
Returned by /api/auth/login and POST /api/auth/workos/callback on success. Contains access + refresh tokens, session config, and the resolved user.
JWT access token.
Resolved session configuration returned alongside tokens. Mirrors the org-level idle-timeout / SSO renewal policy so the client can enforce it.
Show child attributes
Show child attributes
{
"enabled": true,
"idleTimeoutMinutes": 30,
"tokenExpiryHours": 8,
"warningTimeMinutes": 2,
"idleTrackingEnabled": true,
"ssoSilentRenewalEnabled": true,
"ssoFallbackBehavior": "redirect",
"passwordSilentRenewalEnabled": false,
"passwordFallbackBehavior": "logout"
}
Compact User payload returned with auth tokens.
Show child attributes
Show child attributes
{
"id": "5f7b1c2e8a1d4e0012c3b4a5",
"email": "admin@acme.example",
"fullName": "Acme Admin",
"organizationId": "64a1b2c3d4e5f60012345678",
"accessRole": "ADMIN",
"conversationOpenPreference": "split"
}