Response Templates
Response Templates are a reusable library of pre-configured API response patterns. Instead of manually creating responses for common scenarios, you can apply templates and customize as needed.
What is a Response Template?
A response template is a pre-built response configuration that includes:
- HTTP status code
- Response headers
- Body structure (JSON, XML, HTML, or text)
- Dynamic variables and placeholders
- Optional response delay
Templates save time and enforce consistency across simulations.
Template Library
Access the template library from any simulation:
- Open a route
- Click Add Response
- Select Choose from Template Library
- Browse or search templates
- Select and apply
The template is inserted into your route with all configuration pre-filled.
Template Categories
Templates are organized by type and use case:
Success Responses
- 200 OK - Standard success with data
- 201 Created - Resource creation with location header
- 204 No Content - Success with no body
- 206 Partial Content - Paginated responses
Client Error Responses
- 400 Bad Request - Validation errors
- 401 Unauthorized - Missing or invalid authentication
- 403 Forbidden - Insufficient permissions
- 404 Not Found - Resource does not exist
- 409 Conflict - Resource state conflict
- 422 Unprocessable Entity - Semantic validation errors
Server Error Responses
- 500 Internal Server Error - Generic server failure
- 502 Bad Gateway - Upstream dependency failure
- 503 Service Unavailable - Temporary outage
- 504 Gateway Timeout - Upstream timeout
Edge Cases
- Rate limit exceeded - 429 with Retry-After header
- Maintenance mode - 503 with custom message
- Deprecated endpoint - 410 Gone
- Redirect - 301/302 with Location header
Creating Custom Templates
Build your own templates for repeated use.
From an Existing Response
- Configure a response in any route
- Click the Template menu
- Select Save as Template
- Fill in template details:
- Name - Short descriptive name
- Category - Choose or create a category
- Description - When to use this template
- Tags - Searchable keywords
- Click Save
The template is added to your library and available across all simulations.
From Scratch
- Navigate to Templates in the sidebar
- Click New Template
- Configure status, headers, body, and delay
- Save with name and category
Dynamic Data with Faker.js
Templates support Faker.js for generating realistic dynamic data.
Faker Variables
Use Faker.js expressions in template bodies and headers:
{
"id": "{{faker.datatype.uuid}}",
"name": "{{faker.name.fullName}}",
"email": "{{faker.internet.email}}",
"company": "{{faker.company.name}}",
"address": {
"street": "{{faker.address.streetAddress}}",
"city": "{{faker.address.city}}",
"state": "{{faker.address.state}}",
"zip": "{{faker.address.zipCode}}"
},
"phone": "{{faker.phone.number}}",
"createdAt": "{{faker.date.recent}}",
"avatar": "{{faker.image.avatar}}"
}
Every request generates new random values following realistic patterns.
Common Faker Methods
| Category | Method | Example Output |
|---|---|---|
| Names | faker.name.fullName | "Jane Smith" |
faker.name.firstName | "Michael" | |
faker.name.lastName | "Johnson" | |
| Internet | faker.internet.email | "alice@example.com" |
faker.internet.url | "https://example.com" | |
faker.internet.avatar | URL to random avatar | |
| Addresses | faker.address.city | "San Francisco" |
faker.address.country | "United States" | |
faker.address.zipCode | "94105" | |
| Dates | faker.date.recent | ISO 8601 recent date |
faker.date.past | Date in the past | |
faker.date.future | Date in the future | |
| Commerce | faker.commerce.productName | "Ergonomic Chair" |
faker.commerce.price | "49.99" | |
faker.commerce.department | "Electronics" | |
| Company | faker.company.name | "Acme Corp" |
faker.company.catchPhrase | "Innovative Solutions" | |
| Numbers | faker.datatype.number | Random integer |
faker.datatype.uuid | UUID v4 | |
faker.datatype.boolean | true or false |
See Faker.js documentation for the complete API.
Template Variables
Combine Faker.js with SureStage template variables:
{
"requestId": "{{$randomUUID}}",
"userId": "{{request.path.id}}",
"name": "{{faker.name.fullName}}",
"timestamp": "{{$isoTimestamp}}",
"page": "{{request.query.page}}"
}
Variables are resolved when the response is sent.
Applying Templates
To a New Response
- Add a response to a route
- Click Choose Template
- Select a template from the library
- The response is populated with template content
- Customize as needed and save
To an Existing Response
- Open a response for editing
- Click Replace with Template
- Select a template
- Confirm replacement (existing content is overwritten)
Bulk Apply
Apply a template to multiple routes at once:
- Select multiple routes (checkbox selection)
- Click Bulk Actions > Apply Template
- Choose a template and target response (e.g., 404 error)
- All selected routes receive the template
Sharing Templates
Workspace Templates
Templates are automatically shared within your workspace. Any team member can use templates you create.
Organization Templates
Publish templates to the organization library:
- Open a template
- Click Publish to Organization
- Add documentation and usage notes
- Confirm
The template appears in the organization-wide library for all workspaces.
Template Management
Access template management at /templates:
Organizing Templates
- Search - Find templates by name or description
- Filter by category - View templates by type
- Sort - By name, usage count, or date created
- Tag-based filtering - Find templates by tags
Editing Templates
- Click a template to open it
- Modify configuration
- Save changes
All simulations using this template are unaffected. Templates are copied into routes, not referenced.
Versioning
Templates are not versioned. If you need version control, use Blueprints instead.
Deleting Templates
Delete unused templates from your library. This does not affect routes already using the template.
Best Practices
Name clearly - Use descriptive names like "User Not Found (404)" not "Error 1".
Document usage - Add notes explaining when to use each template and any customization needed.
Use categories - Organize templates by type (success, error, edge case) for easy discovery.
Leverage Faker.js - Generate realistic data instead of static placeholders like "test@example.com".
Share common patterns - Publish frequently-used templates to the organization library.
Keep it simple - Templates should be general-purpose starting points, not overly specific.
Next Steps
- Routes & Responses - Learn about response configuration
- StageAssist - Use AI to generate templates
- Blueprints - Create full simulation templates