Home
/
API Response Examples
/
Login
Login API response JSON example
Last updated 2026-05-20
When to use this
Use this for a /auth/login response: the authenticated user payload plus a short-lived access token and a long-lived refresh token. Drop it into a login-form unit test or a session-bootstrap mock.
Example JSON
Successful POST /auth/login response.
{
"id": 1,
"username": "emilys",
"email": "emily.johnson@x.example",
"firstName": "Emily",
"lastName": "Johnson",
"image": "https://jsonexamples.com/image/200?text=User+1",
"accessToken": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNzAwMDAwMDAwfQ.signature",
"refreshToken": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxfQ.refreshSig"
}
Request examples
fetch()
Axios
cURL
Copy
const res = await fetch('https://jsonexamples.com/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username: 'emilys', password: 'emilyspass' })
});
const session = await res.json();
Copy
const { data: session } = await axios.post('https://jsonexamples.com/auth/login', {
username: 'emilys',
password: 'emilyspass'
});
Copy
curl -X POST https://jsonexamples.com/auth/login \
-H 'Content-Type: application/json' \
-d '{"username":"emilys","password":"emilyspass"}'
Common variations
Failed login (compare to 401 Unauthorized)
{
"message": "Invalid credentials",
"code": "auth/invalid_credentials"
}
Refresh-token response
{
"accessToken": "eyJ.new.access",
"refreshToken": "eyJ.new.refresh"
}
Convert this JSON
Generated starting points for TypeScript, JSON Schema, and Zod. Refine before shipping to production.
TypeScript
JSON Schema
Zod
Copy
export interface Login {
"id": number;
"username": string;
"email": string;
"firstName": string;
"lastName": string;
"image": string;
"accessToken": string;
"refreshToken": string;
}
Copy
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Login",
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"username": {
"type": "string"
},
"email": {
"type": "string"
},
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"image": {
"type": "string"
},
"accessToken": {
"type": "string"
},
"refreshToken": {
"type": "string"
}
},
"required": [
"id",
"username",
"email",
"firstName",
"lastName",
"image",
"accessToken",
"refreshToken"
],
"additionalProperties": false
}
Copy
import { z } from 'zod';
export const LoginSchema = z.object({
id: z.number(),
username: z.string(),
email: z.string(),
firstName: z.string(),
lastName: z.string(),
image: z.string(),
accessToken: z.string(),
refreshToken: z.string()
});
export type Login = z.infer<typeof LoginSchema>;
Copy link to this example
https://jsonexamples.com/api-response-examples/login