Skip to main content
When you configure an API Target, the gateway acts as a proxy between your API consumers and your backend server. By default, requests are forwarded as-is to your target server. However, you often need to modify requests before they reach your backend or transform responses before they’re returned to consumers. Target Transformations allow you to:
  • Rewrite paths - Map consumer-facing URLs to your internal API structure
  • Inject headers - Add authentication tokens, API keys, or tracking headers
  • Modify query parameters - Add, remove, or transform URL parameters
  • Transform request bodies - Restructure payloads, add metadata, or wrap content
  • Transform responses - Filter fields, restructure data, or normalize formats
  • Calculate dynamic credits - Charge based on actual usage from response data
All transformations use an Expression Language that lets you access request data, user context, and response data dynamically.

Expression Syntax

Expressions are enclosed in double curly braces:
Everything outside {{ }} is treated as static text. You can mix static content with multiple expressions:

Where Expressions Can Be Used

Expressions are supported in the following Target configuration fields:

Context Variables

Different variables are available depending on where the expression is used.

Request Variables

Available in: Path, Headers, Query, Request Body

Context Variables

Available in: All expressions

Response Variables

Available in: Response Body, Response Headers, Dynamic Credits

Rendered Request Variables

Available in: Response Body, Response Headers, Dynamic Credits The renderedRequest object contains the transformed request that was actually sent to the target server.

Accessing Properties

Use dot notation for object properties:
Use bracket notation for dynamic keys or special characters:

Functions

String Functions

Array Functions

Encoding Functions

Type Functions

Utility Functions

Hash & Random Functions

Supported hash algorithms: md5, sha1, sha256, sha512

Date Functions

URL Functions

Component values: 1=scheme, 2=host, 3=port, 5=path, 6=query, 7=fragment

Operators

Comparison

Logical

Ternary

String Concatenation

Arithmetic

Usage Examples

Path Transformation

Prefix all requests with a version:
Dynamic path based on request:

Custom Headers

Add authentication header:
Forward user context:

Query Parameters

Default pagination:

Request Body Transformation

Wrap original body:

Response Body Transformation

Extract specific fields:

Dynamic Credits

Use credits from response header:
Calculate credits based on response:
Fixed credits on success, zero on error:

Limits

  • Maximum template size: 200,000 characters
  • Maximum expressions per template: 100

Notes

  • Expressions that fail to evaluate will throw an error and the request will return a gateway error
  • JSON objects and arrays in expression results are automatically serialized
  • The request.json and response.json variables are null if the body is not valid JSON
  • Header names are case-insensitive and normalized to lowercase