Body Transformer Configuration
Configuration reference for the Body Transformer plugin (`body-transformer`): the parameters, each attribute with its type, whether it is required, its default and its accepted values.
Parameters
See plugin common configurations (opens in Apache APISIX docs) for configuration options available to all plugins.
request — object · optional · since APISIX 3.2.0 · API7 Gateway 3.2.16.3
Request body transformation configuration.
input_format — string · optional · since APISIX 3.2.0 · API7 Gateway 3.2.16.3
Valid values: xml, json, encoded, args, plain, or multipart
Request body original media type. If unspecified, the value would be determined by the Content-Type header to apply the corresponding decoder.
The xml option corresponds to text/xml media type. The json option corresponds to application/json media type. The encoded option corresponds to application/x-www-form-urlencoded media type. The args option corresponds to GET requests. The plain option corresponds to text/plain media type. The multipart option corresponds to multipart/form-data media type.
If the media type is not one of the supported types, the value would be left unset and the transformation template will be directly applied.
template — string · required · since APISIX 3.2.0 · API7 Gateway 3.2.16.3
Request body transformation template. The template uses lua-resty-template syntax. See the template syntax for more details.
You can also use auxiliary functions _escape_json() and _escape_xml() to escape special characters such as double quotes, _body to access request body, and _ctx to access context variables. See examples to learn more.
The template names _ctx, _body, _escape_json, _escape_xml, and _multipart are reserved; _escape_json() and _escape_xml() are called as functions. Decoded request fields with these names are ignored so that they cannot replace the helpers.
template_is_base64 — boolean · optional · since APISIX 3.8.0 · API7 Gateway 3.2.16.3
Set to true if the template is base64 encoded.
response — object · optional · since APISIX 3.2.0 · API7 Gateway 3.2.16.3
Response body transformation configuration.
input_format — string · optional · since APISIX 3.2.0 · API7 Gateway 3.2.16.3
Valid values: xml, json, encoded, args, plain, or multipart
Response body original media type. If unspecified, the value would be determined by the Content-Type header to apply the corresponding decoder.
The xml option corresponds to text/xml media type. The json option corresponds to application/json media type. The encoded option corresponds to application/x-www-form-urlencoded media type. The args option is primarily used for request query arguments and is typically not applicable to response bodies. The plain option corresponds to text/plain media type. The multipart option corresponds to multipart/form-data media type.
If the media type is none of the supported types, the value would be left unset and the transformation template will be directly applied.
template — string · required · since APISIX 3.2.0 · API7 Gateway 3.2.16.3
Response body transformation template.
The template names _ctx, _body, _escape_json, _escape_xml, and _multipart are reserved; _escape_json() and _escape_xml() are called as functions. Decoded response fields with these names are ignored so that they cannot replace the helpers.
template_is_base64 — boolean · optional · since APISIX 3.8.0 · API7 Gateway 3.2.16.3
Set to true if the template is base64 encoded.
max_req_body_size — integer · optional · default: 67108864 · since APISIX 3.18.0 · API7 Gateway 3.9.17
Valid values: greater than or equal to 1
Maximum request body size in bytes read for transformation. A larger body is rejected with status 413. Introduced in API7 Enterprise 3.9.17 and 3.10.4, and APISIX 3.18.0.
max_resp_body_size — integer · optional · default: 67108864 · since APISIX 3.18.0 · API7 Gateway 3.9.17
Valid values: greater than or equal to 1
Maximum response body size in bytes buffered for transformation. A larger response is truncated to this size before transformation. The chunk that crosses the threshold is buffered before the limit is enforced, so transient memory use can exceed the configured size. Introduced in API7 Enterprise 3.9.17 and 3.10.4, and APISIX 3.18.0.