Templates Overview
Create dynamic mock API responses with template variables, faker functions, and control structures
What is a Template?
A template is a JSON (or other format) response that contains special syntax to make it dynamic. Instead of static values, you can use template expressions wrapped in double braces {{ and }}.
Templates are processed when a request is made to your mock API, allowing you to create realistic, context-aware responses.
Basic Syntax
Template Expression Format
All template expressions use double-brace syntax:
{{functionName 'argument'}}- String arguments must be wrapped in single or double quotes:
{{get "id"}} - Number arguments have no quotes:
{{jwt 3600}} - No spaces inside the braces (except for readability)
Valid Example
{
"requestId": {{get 'id'}},
"userName": {{faker 'person.name'}},
"expiresIn": {{jwt 3600}}
}Template Categories
1. Request Variables
Capture data from the incoming HTTP request
{{get 'paramName'}} // Query parameter (?paramName=value)
{{post 'fieldName'}} // POST form field
{{json 'key'}} // JSON body field
{{path $1}} // Path segment by index
{{path.regex $1}} // Regex capture groupExample:
Request: GET /api/user?id=42
Template: {{get "id"}} → Returns: 42
Path Variables:
Use {{path $1}} for static paths or {{path.regex $1}} for regex capture groups.
Example: GET /users/123 → {{path $1}} = "users", {{path $2}} = "123"
2. Faker Functions
Generate realistic fake data automatically
{{faker 'person.name'}} // Random person name (default: en_US)
{{faker 'person.name:ko_KR'}} // Korean name
{{faker 'email'}} // Random email
{{faker 'address.city:en_US'}} // English city
{{faker 'company.name'}} // Random company name20+ Faker functions available
Including: person, address, company, internet, lorem, date, finance, phone, and more. Use function:locale to specify a language (e.g., person.name:ko_KR).
3. Control Structures
Create loops and manage data flow
Repeat Block
{{#repeat 10}}
// This content repeats 10 times
// Use {{@index}} for current iteration
{{/repeat}}Index Variable
{{@index}} // 0, 1, 2, 3...
{{@index 1}} // 1, 2, 3, 4...
{{@index 100}} // 100, 101, 102...
{{@index 0 2}} // 0, 2, 4, 6...
{{@index 1 10}} // 1, 11, 21, 31...4. Special Functions
JWT tokens and other utilities
{{jwt 3600}} // Generate JWT token (expires in 3600 seconds)Important Notes
- Templates are validated in real-time in the editor
- Syntax errors will show inline with line numbers
- Unclosed braces or repeat blocks will cause validation errors
- Use single or double quotes consistently for string arguments
- Faker functions generate different data on each request (not cached)