Unetus Docs
  • Documentation
  • Download
    • Introduction
    • Install
    • Send Your First Request
    • Import and Export Data
    • Environment Variables
    • Workspaces
    • Requests
    • Responses
    • Request Collections
    • Request Timeouts
    • Chaining Requests
    • Post CSV Data
    • SOAP Requests
    • gRPC
    • WebSocket Support
    • Get Started with Documents
    • Design Documents
    • Linting
    • GraphQL for OpenAPI
    • Unit Testing
    • Stress Testing
    • Authentication
    • Client Certificates
    • Generate Code Snippet
    • Cookie Management
    • Encoding
    • GraphQL Queries
    • Key Maps
    • Proxy
    • Insomnia Configuration File
    • Introduction to Plugins
    • Context Object Reference
    • Template Tags
    • Hooks and Actions
    • Custom Themes
    • FAQ
    • Application Data
    • SSL Validation

Template Tags

Template tags are closely related to Environment Variables. The main difference between Template Tags and Environment Variables is that Template Tags act more like operations, and not variables.

Tags can do things like transform strings, generate random numbers, handle UUIDs, and create timestamps.

Use Template Tags

To insert a template tag, press CTRL+Space wherever Environment Variables can be used. Template tags will appear below Environment Variables in the autocomplete list, and are marked with an ƒ symbol.

Custom Template Tags

You may want to extend Unetus functionality with custom behaviors, and can do so by creating your custom template tag as an Unetus plugin. Once you’ve added your custom plugin to your Unetus application, the template tag will show up exactly as if it were a native Unetus tag.

Response and Request Tags

Response and request tags enable you to reference values between and from responses and requests.

The Response Tag

Use a response tag to reference values from other responses, or Request Chaining.

This can be useful when including the ID of a created resource in a GET request right after creating it with a POST request. It’s also useful when referencing a reusable login token from a response in an environment variable.

The Request Tag

The request tag is useful for referencing values from the current request.

For example, use a request tag to extract a CSRF token from a cookie so you can use that value as a form value or header.

Template Tag Schema

This example shows the usage of TemplateTag to render custom values.

interface RenderContext {
  // API not finalized yet
};

interface TemplateTag {
  name: string,
  displayName: DisplayName,
  disablePreview?: () => boolean,
  description?: string,
  deprecated?: boolean,
  liveDisplayName?: (args) => ?string,
  validate?: (value: any) => ?string,
  priority?: number,
  args: Array<{
    displayName: string,
    description?: string,
    defaultValue: string | number | boolean,
    type: 'string' | 'number' | 'enum' | 'model' | 'boolean',
    
    // Only type === 'string'
    placeholder?: string,

    // Only type === 'model'
    modelType: string,

    // Only type === 'enum'
    options: Array<{
      displayName: string,
      value: string,
      description?: string,
      placeholder?: string,
    }>,
  }>,
  actions: Array<{
    name: string,
    icon?: string,
    run?: (context) => Promise<void>,
  }>,
};

Example: Template tag to generate random integer

This example template tag generates a random integer between 0 and 100.

/**
 * Example template tag that generates a random number 
 * between a user-provided MIN and MAX
 */
module.exports.templateTags = [{
    name: 'randomInteger',
    displayName: 'Random Integer',
    description: 'Generate a random integer.',
    args: [
        {
            displayName: 'Minimum',
            description: 'Minimum potential value',
            type: 'number',
            defaultValue: 0
        }, 
        {
            displayName: 'Maximum',
            description: 'Maximum potential value',
            type: 'number',
            defaultValue: 100
        }
    ],
    async run (context, min, max) {
        return Math.round(min + Math.random() * (max - min));
    }
}];
Edit this page
Report an issue
© 2021-2023 Kong Inc.
© 2023 Unetus Project