Mock Endpoints
Mock Endpoints
Section titled “Mock Endpoints”Mock endpoints return predefined responses when called. Use them to simulate APIs during development.
Creating a Mock Endpoint
Section titled “Creating a Mock Endpoint”- Click New Endpoint and select Mock
- Configure the endpoint:
- Name: A descriptive label (e.g., “Get User by ID”)
- Path: The URL path (e.g.,
/api/users/{id}) - Method: GET, POST, PUT, DELETE, etc.
Path Parameters
Section titled “Path Parameters”Use curly braces for dynamic path segments:
/api/users/{id}- matches/api/users/123/api/projects/{projectId}/tasks/{taskId}- multiple parameters
Access path parameters in your response with {{params.id}}.
Response Configuration
Section titled “Response Configuration”Status Code
Section titled “Status Code”Set any HTTP status code (200, 201, 404, 500, etc.).
Headers
Section titled “Headers”Add custom response headers:
Content-Type: application/jsonX-Custom-Header: valueEnter your response body. For JSON responses, you can use template variables for dynamic data:
{ "id": "{{params.id}}", "name": "{{name}}", "email": "{{email}}", "createdAt": "{{timestamp}}"}Response Variations
Section titled “Response Variations”Create multiple response variations for the same endpoint:
- Static: Always returns the same response (default)
- Sequential: Cycles through variations in order
- Random: Randomly selects a variation
- Conditional: Returns different responses based on request data
Conditional Example
Section titled “Conditional Example”Match requests based on query parameters, headers, or body:
Condition: query.status equals "active"Response: { "users": [...active users...] }
Condition: query.status equals "inactive"Response: { "users": [...inactive users...] }Response Delay
Section titled “Response Delay”Add artificial latency to simulate real network conditions. Set delay in milliseconds (e.g., 500ms).
Enable/Disable
Section titled “Enable/Disable”Toggle endpoints on/off without deleting them. Disabled endpoints return 404.