# API proxy transformation
PRIVATE RELEASE
This feature is in private release. Private release features are available in production but only to selected customers. Contact your Customer Success Manager to enable this feature.
API proxy transformation allows you to modify API proxy requests and responses as they pass through Workato's API gateway. You can transform inbound request data before forwarding it to the target endpoint or transform target responses before returning them to the client. Transformations streamline API consumption, improve data integrity, and enable you to align different schemas and data formats, providing greater control over your API usage.
API proxy transformation flow
# Key concepts
Review the following key concepts before beginning the transformation process:
Client
The user or application that sends requests to the API proxy endpoint.
Proxy schema
The schema defined within Workato that specifies the structure of requests and responses exchanged between the client and the API proxy. It serves as the client-facing interface for the API.
Target
The backend service that processes API requests forwarded by the API proxy.
Target schema
The schema of the backend service, also referred to as the backend API or external API. This schema defines the structure of the request forwarded to the target and the response returned by the target. Transformations enable compatibility when the proxy schema and target schema differ, aligning inbound request data with the backend service’s requirements and responses with the client’s expectations.
# Supported transformation types
OPTIMIZED SUPPORT
Optimized support is available only for JSON content types. Use Plain text
to manage alternative content formats.
API proxy transformation supports the following modifications to requests and responses:
Schema manipulation
Modify the schema for both proxy or target requests and responses, ensuring proper structure and data flow.
Key-value pair mapping
Create or modify parameters within the request or response, such as masking sensitive data or adding custom headers.
In-line formulas
Use Workato's formula capabilities to manipulate values within the request or response. You can apply static or dynamic values (using datapills) and perform calculations or formatting based on the data.
Conditional response mapping
Apply conditional logic to return different HTTP statuses or responses based on specific conditions.
# Unsupported transformation types
While API proxy transformation offers flexibility in modifying requests and responses, the following transformations are not supported:
Changing HTTP request methods
You cannot modify the HTTP method between the proxy and the target. For example, a
GET
request at the proxy can't be transformed into aPOST
request at the target. You must use the same method across both the proxy and the target endpoints.Dynamic path transformations
You cannot use dynamic transformations with datapills or formulas for the target URL path. Only static text paths are allowed.
Transforming arrays or objects in query parameters
For
GET
andDELETE
requests, you can't transform arrays or objects in query parameters. However, you can still use arrays and objects in the request body.Unsupported content types for request and response bodies
You cannot apply transformations to certain content types in both request and response bodies. These include multipart form data, URL-encoded forms, plain text, or binary data. XML is partially supported, which enables you to construct XML bodies using the
text/plain
content type when transforming request or response bodies.Multiple conditional responses
You cannot map multiple response status codes for a single proxy endpoint to different conditions. Handling multiple status-code mappings using conditional logic is not supported.
# Formula limitations
Workato allows you to use formulas to transform requests and responses, offering flexibility to dynamically transform data. While most documented formulas are supported, certain exceptions apply.
If you encounter limitations or require additional formula support, contact your Customer Success Manager (CSM) for assistance.
# Transform proxy requests
Transforming proxy requests allows you to modify inbound request data before forwarding it to the target endpoint. You can configure the endpoint path, query parameters, headers, or request body based on your requirements. Use transformations when the client schema differs from the target schema to reconcile mismatched data formats or structures.
PREREQUISITES
Before you can apply API proxy transformation, ensure you have the following:
- Configured API proxy endpoint: Verify that your API proxy endpoint is properly set up. For more information, refer to the API proxy endpoint configuration documentation.
- Defined client schema: Configure the request and response format expected by the proxy-facing client. This is typically predefined during the proxy setup.
- Defined target schema: Configure the target request schema and response schema. You can do this by sending a sample request with the guided setup wizard or providing a JSON sample.
Transforming proxy requests involves two key steps:
- Configuring the target endpoint schema: Set up the target endpoint request schema to align with the target API’s data format.
- Applying transformations: Modify the request using transformation options to match the client schema or adapt to specific target API constraints.
# Configure the target endpoint schema
Before applying transformations, you must define the schema for the target endpoint. This step ensures the proxy endpoint aligns with the target API’s data format. You can define the schema using the guided setup or manual configuration for full control over the process.
# Guided setup
The guided setup helps you configure the schema for the target API. This setup automatically generates the request and response schema by sending a sample request to the target API.
WHEN TO USE GUIDED SETUP
The guided setup simplifies schema definition based on real-time responses from the target API. This ensures compatibility and creates a foundation for transformations.
Complete the following steps to use the guided setup:
Go to Platform > API Platform > API collections.
Choose the API proxy collection where the endpoint is located.
Choose the proxy endpoint, then open the Details tab.
Select the endpoint that you plan to modify, then click Edit endpoint.
Click the Forward request to target action in your proxy workflow to open the configuration.
Configure the Forward request to target action
Click Start guided setup to open the schema definition wizard. If you prefer not to send a sample request to the target API, click Skip guided setup to manually define schemas.
Start guided setup
Define the Target endpoint path appended to the target API’s base URL.
Review the Target URL preview to ensure the full target URL is correct.
Specify the Request content type, if applicable. This field is required for methods such as POST, PUT, PATCH, or DELETE, where a payload is sent.
Configure the Request body by either using the JSON template or adding fields manually. This field appears for methods like POST, PUT, or PATCH.
Define Request parameters to send additional data to the target endpoint.
Add any required Request headers to the HTTP request.
Use the Response drop-down menu to define the expected Response content type, such as JSON or XML.
Click Send request.
Review the schema generated from the sample request to ensure it matches the target API’s expected data format. If the request succeeds, Workato displays a 200 - OK
code.
Review HTTP configuration
Click Apply configuration to save the schema. This ensures the proxy endpoint aligns with the target API’s data format and is ready for transformations.
After you’ve configured the target schema, proceed to apply proxy request transformations to modify requests based on your requirements.
# Manual configuration
Manual setup allows you to configure the target endpoint’s schema without sending a sample request to the target API. This approach gives you complete control over request and response definitions, making it ideal for custom configurations or when guided setup is not suitable.
WHEN TO USE MANUAL SETUP
Use manual setup if you prefer to define schema fields without sending a sample request to the target API.
When configuring proxy requests, determine whether transformations are necessary. For pass-through requests, no transformations or request schema configuration are needed. If transformations are required, fields appear dynamically to allow you to define the target schema and configure request transformations.
Complete the following steps to configure the target endpoint's schema manually:
Go to Platform > API Platform > API collections.
Choose the API proxy collection containing the endpoint.
Select the proxy endpoint and open the Details tab.
Choose the endpoint that you plan to configure, then select Edit endpoint.
Click the Forward request to target action in your proxy workflow to open the configuration.
Configure the Forward request to target action
Click the setup manually link to access the schema definition editor.
Select setup manually
Define the target request schema, such as the Request body, Request parameters, and Request headers.
Use the Response schema drop-down menu to define the response expected from the target API. This configuration forms the basis for transforming the response in subsequent steps and includes the Response content type, Response body, and Response headers.
Click Save to finalize the schema.
After you’ve configured the target schema, proceed to apply proxy request transformations to modify requests based on your requirements.
# Apply proxy request transformations
After schema setup, return to the Forward request to target action to configure transformations. Use the What would you like to do? drop-down menu to determine how the proxy handles requests.
Choose what to do with the API proxy request
Based on your specific requirements, choose one of the following options:
QUERY PARAMETER BEHAVIOR
When applying transformations, the proxy forwards only query parameters explicitly configured in the transformation step to the target API. Query parameters not mapped in the transformation step are excluded from the forwarded request. To pass all query parameters from the client request, explicitly map each parameter.
After configuring and saving the request transformations, configure the Return response action to transform the response before returning it to the client, if needed.
# Transform target responses
PREREQUISITES
Before you can apply API proxy transformation, ensure you have the following:
- Configured API proxy endpoint: Verify that your API proxy endpoint is properly set up. For more information, refer to the API proxy endpoint configuration documentation.
- Defined client schema: Configure the request and response format expected by the proxy-facing client. This is typically predefined during the proxy setup.
- Defined target schema: Configure the target request schema and response schema. The response schema is essential for enabling transformations before returning the response to the client. You can do this by sending a sample request with the guided setup wizard or providing a JSON sample.
Target response transformations allow you to modify the data returned by the target before returning it to the client. You can configure headers, modify the body, or apply conditional logic to customize the response.
Complete the following these steps to configure response transformations:
Go to Platform > API Platform > API Collections.
Select the API proxy collection containing the endpoint.
Choose the proxy endpoint, then open the Details tab.
Select the endpoint you plan to modify, then select Edit endpoint.
Click the Return response action in the endpoint configuration to define how to handle the target response before returning it to the client.
Configure the Return response action
# Apply target response transformations
Choose a transformation option that matches your API’s requirements. Each option determines how the response is modified before returning to the client:
# Conditional response mapping
Conditional response mapping allows you to return different responses based on defined conditions. You can configure one conditional response using dynamic values from both the proxy request or the target response. For example, you can evaluate fields such as HTTP status codes and return designated responses depending on whether the condition is met.
Complete the following steps to set up conditional response mapping:
Add a Conditional response step in the transformation editor. This step evaluates the target API’s response based on defined conditions, such as HTTP status codes or other response data.
Add a conditional response step
Choose the Data field from the response that you plan to evaluate, such as a Status code
or any specific response data.
Configure data field
Set the Condition that triggers the outcome. For example, to check for error codes, you can use conditions like Status code equals 400
.
Define the Value for the condition. For example, if you're monitoring for a specific status code, set the value to 400
or another relevant code.
Use the What would you like to do? drop-down menu to select how the response should be handled if the condition is met. You can choose options like Return transformed response to customize the response.
Define response
Use the Response drop-down menu to specify the status code or message, such as 200 - OK
, if Return transformed response is selected. Configure the Response body and Response headers as needed to customize the response. Note that the Response drop-down menu applies only when transforming the response.
Use the What would you like to do? drop-down menu again to select how the response should be handled if the condition is not met. For example, you can choose Return response without transformation or another option.
# Transform data with Workato formulas
Workato formulas allow you to dynamically transform data in API requests and responses. You can use formulas to streamline data formats, perform arithmetic calculations, and manipulate strings. Most documented formulas are supported, with some exceptions. For more information, refer to the Workato formula documentation.
# Example formula transformation
You can use formulas to define default values for request parameters. For example, you can define a request parameter with a formula to set a default value if the input is missing:
Transform request parameter
In this formula, the Search term
parameter uses the formula Search term.presence || 'Featured products'
to check if a search term is provided. If not, the parameter defaults to Featured products
.
FORMULA LIMITATIONS
Formulas are limited to the capabilities supported by Workato’s Formula interpreter. They can compute new values based on available data formats but must adhere to documented formula functions.
# Send test requests
After configuring transformations, send test requests to ensure everything works as expected. When sending test requests, verify the following:
- Request transformations are applied correctly to parameters, headers, and the body.
- Response transformations modify the response body and headers as intended before returning them to the client.
- HTTP status codes are accurate and reflect the intended response behavior.
- Test data reflects real-world scenarios to check for any edge cases.
Testing ensures your API proxy transformations function properly and meet client and target requirements.
Last updated: 12/10/2024, 3:05:53 AM