Auth session JSON example
Last updated 2026-05-20
Example JSON
The response returned by POST /auth/login.
{
"id": 1,
"username": "emilys",
"email": "[email protected]",
"firstName": "Emily",
"lastName": "Johnson",
"gender": "female",
"image": "https://jsonexamples.com/image/200?text=User+1",
"accessToken": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNzAwMDAwMDAwfQ.signature",
"refreshToken": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNzAwMDAwMDAwfQ.refresh"
}Request examples
fetch('https://jsonexamples.com/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username: 'emilys', password: 'emilyspass' })
})
.then(r => r.json())
.then(session => console.log(session.accessToken));Common variations
Refresh-token response
Same shape, returned by POST /auth/refresh.
{
"accessToken": "eyJhbGciOiJIUzI1NiJ9.new.accesstoken",
"refreshToken": "eyJhbGciOiJIUzI1NiJ9.new.refreshtoken"
}Authenticated /auth/me response
Returned when you call /auth/me with the Bearer token attached.
{
"id": 1,
"username": "emilys",
"email": "[email protected]",
"firstName": "Emily",
"lastName": "Johnson"
}Failed login (matches 401 response)
Matching error envelope; see the 401 Unauthorized example for the full shape.
{
"message": "Invalid credentials",
"code": "auth/invalid_credentials"
}Convert this JSON
Generated starting points for TypeScript, JSON Schema, and Zod. Refine before shipping to production.
export interface AuthSession {
"id": number;
"username": string;
"email": string;
"firstName": string;
"lastName": string;
"gender": string;
"image": string;
"accessToken": string;
"refreshToken": string;
}