API7 Docs
TransformationBody Transformer

Body Transformer Configuration

Parameters

See plugin common configurations for configuration options available to all plugins.

  • requestobject · optional

    Request body transformation configuration.

    • input_formatstring · optional

      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.

    • templatestring · required

      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_base64boolean · optional

      Set to true if the template is base64 encoded.

  • responseobject · optional

    Response body transformation configuration.

    • input_formatstring · optional

      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.

    • templatestring · required

      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_base64boolean · optional

      Set to true if the template is base64 encoded.

  • max_req_body_sizeinteger · optional · default: 67108864

    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_sizeinteger · optional · default: 67108864

    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.