Skip to content

Request Transformation

A Jinja2 template that defines the body of the outgoing HTTP request — letting you reshape data before it reaches the destination and control exactly what is sent.

The template applies to the outgoing request body only — it has no effect on the response. If the field is blank, the original incoming payload is forwarded as-is.

WARNING

When the request transformation field is blank, the complete original request body is forwarded to the external API. This may include sensitive user data or internal fields. Set a request transformation to control exactly what is sent.

Use request transformation for POST, PUT, and PATCH requests where you need to control the request body structure. GET requests have no body, so this field has no effect on GET connectors.

Variables

TIP

For the full list of variables, filters, and functions available in templates, see Template Variables.

Two variables are specific to payload templates:

  • body_text — the incoming request body decoded as a UTF-8 string. Use this for JSON payloads.
  • body_raw — the request body as raw bytes. Use only when you need exact binary encoding. Avoid rendering it directly in a Jinja2 template — the output is not valid JSON.

Both are available for POST, PUT, and PATCH requests. For GET requests (or any request with no body), both are None. If you render a None variable in a template, it produces the literal string None, not an empty string — so always guard with a default filter (e.g., {{ body_text | default('') }}) when the variable may be absent.

get_secret() is not available here

Unlike headers and query parameters, payload templates do not have access to get_secret(). Secrets are intentionally excluded from payload templates. Use headers or query parameters if you need to include a secret value. See Secrets for details.

Examples

jinja2
{
  "tenant_id": "{{ tenant_id }}",
  "user_email": "{{ user.email }}",
  "original_payload": "{{ body_text }}"
}
jinja2
{
  "tenant_id": "{{ tenant_id }}",
  "order_id": "{{ (body_text | from_json).order.id }}",
  "order_total": {{ (body_text | from_json).order.total }}
}

TIP

Numeric fields like order_total above are not wrapped in quotes so they render as JSON numbers, not strings. If the downstream API expects a number type, omitting the quotes ensures the value is sent correctly.

Do not output from_json directly

Never use {{ body_text | from_json }} as the entire payload template — it produces HTML-escaped Python notation, not valid JSON. Leave the template blank to forward the body as-is, or use {% set %} to extract specific fields. See Template Variables — Behavioral notes for details.

Next Steps

Gainsight CC Developer Portal