Example 4396

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": "Enrique Padberg",
"email": "Essie.Bednar@gmail.com",
"role": "admin"
},
{
"id": 2,
"name": "Kasey Spencer",
"email": "Jasmine_Orn@hotmail.com",
"role": "user"
}
]
"""

# Response headers
headers: {
Content-Type: "application/json"
X-Total-Count: "2"
X-Request-Id: "91d584f5-6f5d-446d-aa74-e3ec3bfd495c"
}
delay_ms: 473 # simulated latency
}

See also