Example 7186

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": "Natasha Block",
"email": "Gerda_Kilback@gmail.com",
"role": "admin"
},
{
"id": 2,
"name": "Winifred Thompson",
"email": "Clara_Grant29@gmail.com",
"role": "user"
}
]
"""

# Response headers
headers: {
Content-Type: "application/json"
X-Total-Count: "2"
X-Request-Id: "137a5af3-30dc-4dab-a959-561ab84b40a1"
}
delay_ms: 236 # simulated latency
}

See also