Example 5793

API Mock

Mock API response payloads for testing.

# Mock API definition
{
endpoint: "/api/v1/users"
method: "GET"
status: 200
# JSON response body
response: """
[
{
"id": 1,
"name": "Fern Witting",
"email": "Kamryn_Kris-Gutkowski@gmail.com",
"role": "admin"
},
{
"id": 2,
"name": "Candace Paucek",
"email": "Krystal_Gutmann-Frami@yahoo.com",
"role": "user"
}
]
"""

# Response headers
headers: {
Content-Type: "application/json"
X-Total-Count: "2"
X-Request-Id: "2a70b747-f2fd-4a11-ba05-ab59f35e2098"
}
delay_ms: 458 # simulated latency
}

See also