Middleman templates transform the JSON body of an incoming proxy request before it's forwarded to your target.
They run only when both:
Content-Type: application/json, andIf either is missing, the original body is forwarded unchanged.
Invalid templates are rejected at save time. A runtime failure (e.g. drilling into a field that isn't an object) falls back to forwarding the original body — the failure is recorded on the matching row in the dashboard's History tab.
An identifier (a bareword like email) looks up the field with that name in the incoming body.
{
"email": "ada@example.com",
"amount": 9900
}
{
"to": email,
"cents": amount
}
{
"to": "ada@example.com",
"cents": 9900
}
Identifiers also work as field names — the key itself comes from the incoming body:
{
event_type: payload
}
Dot notation drills into nested objects:
{
"name": user.profile.display_name,
"country": user.address.country
}
Ternary form — if (cond) X : Y:
{
"tier": if (is_premium) "paid" : "free"
}
Without an else branch, the field is omitted entirely when the condition is false:
{
"discount_code": if (has_discount) discount_code
}
Use cond ? { ... } to merge a block of fields only when a condition holds — handy for grouping several related fields under one gate:
{
"id": user_id,
is_premium ? {
"plan": plan_name,
"renews_at": renewal_date
}
}
Prefix any condition with ! to invert it:
{
"anonymous": if (!is_logged_in) true : false
}
← Docs