Skip to main content

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:

  1. Open a route
  2. Click Add Response
  3. Select Choose from Template Library
  4. Browse or search templates
  5. 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

  1. Configure a response in any route
  2. Click the Template menu
  3. Select Save as Template
  4. Fill in template details:
    • Name - Short descriptive name
    • Category - Choose or create a category
    • Description - When to use this template
    • Tags - Searchable keywords
  5. Click Save

The template is added to your library and available across all simulations.

From Scratch

  1. Navigate to Templates in the sidebar
  2. Click New Template
  3. Configure status, headers, body, and delay
  4. 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

CategoryMethodExample Output
Namesfaker.name.fullName"Jane Smith"
faker.name.firstName"Michael"
faker.name.lastName"Johnson"
Internetfaker.internet.email"alice@example.com"
faker.internet.url"https://example.com"
faker.internet.avatarURL to random avatar
Addressesfaker.address.city"San Francisco"
faker.address.country"United States"
faker.address.zipCode"94105"
Datesfaker.date.recentISO 8601 recent date
faker.date.pastDate in the past
faker.date.futureDate in the future
Commercefaker.commerce.productName"Ergonomic Chair"
faker.commerce.price"49.99"
faker.commerce.department"Electronics"
Companyfaker.company.name"Acme Corp"
faker.company.catchPhrase"Innovative Solutions"
Numbersfaker.datatype.numberRandom integer
faker.datatype.uuidUUID v4
faker.datatype.booleantrue 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

  1. Add a response to a route
  2. Click Choose Template
  3. Select a template from the library
  4. The response is populated with template content
  5. Customize as needed and save

To an Existing Response

  1. Open a response for editing
  2. Click Replace with Template
  3. Select a template
  4. Confirm replacement (existing content is overwritten)

Bulk Apply

Apply a template to multiple routes at once:

  1. Select multiple routes (checkbox selection)
  2. Click Bulk Actions > Apply Template
  3. Choose a template and target response (e.g., 404 error)
  4. 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:

  1. Open a template
  2. Click Publish to Organization
  3. Add documentation and usage notes
  4. 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

  1. Click a template to open it
  2. Modify configuration
  3. 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