Transformations
Transformations allow you to remove, remap, or add headers or parameters in API requests and API responses
Transformations allow you to remove, remap, or add headers or parameters in API requests and API responses transparently to the developer using the API. Currently, we support single object transformations and we will be launching more complex transformations in the future.
Transformation actions
Function | Description | Use case |
---|---|---|
ADD | Add a header or parameter to an API request or response. | Add a secret authentication parameter per plan in the case where each plan uses a different base URL (learn more about multi-base URLs here). |
REMAP | Remap a header or parameter in an API request or response. | Remap request authentication from query to header to provide a better developer experience, without modifying the original API. |
REMOVE | Remove a header or parameter in an API request or response. | Remove a parameter in the original API response so that it isn't displayed to the API consumer. |
How to get started with transformations
To start, navigation to the Provider Dashboard and select the Definition page for the API you want to edit. Next, select the Transformations tab on the top navigation bar.
![transformations1.png 1916](https://files.readme.io/c92b5f9-transformations1.png)
This screen allows you to remove, remap, or add headers or parameters in API requests and API responses.
How to define a transformation
Step 1: Select either Request Transformation or Response Transformation
![transformations 1.png 2374](https://files.readme.io/3e79a10-transformations_1.png)
Step 2: Select an action
You can set the action to Remove, Remap, or Add.
![Screen Shot 2020-07-14 at 4.44.38 PM.png 2380](https://files.readme.io/0a7a757-Screen_Shot_2020-07-14_at_4.44.38_PM.png)
[IMPORTANT]
The Method and Base URL Transformations can only be done from the Edit Endpoint tab.
Step 3: Define the target Key
You can select from the available options, and add more detail using dot notation.
![Screen Shot 2020-07-14 at 4.44.56 PM.png 2378](https://files.readme.io/e51b253-Screen_Shot_2020-07-14_at_4.44.56_PM.png)
Step 4: Select a variable type
You can select from Static, Variable, or Template.
- Select type Static for if you want to send plain text/json or any fixed data
- Select type Variable if you want to map the value from other parameters. Example request.header.xxxx
- Select type Template if you want to read values from other variables and add more content and manipulate data. You can use the powerful mustache syntax to achieve complex mappings.
Example {{request.query.value}},{{request.body.item}} I am using transformation {{request.body.item2}}
![Screen Shot 2020-07-14 at 4.45.22 PM.png 2374](https://files.readme.io/beaf86e-Screen_Shot_2020-07-14_at_4.45.22_PM.png)
Step 5: Set the variable value
![Screen Shot 2020-07-14 at 4.45.42 PM.png 2380](https://files.readme.io/f990e79-Screen_Shot_2020-07-14_at_4.45.42_PM.png)
Step 6: Set the scope of the transformation
Set the scope to include the full API or select specific endpoints.
![Screen Shot 2020-07-14 at 4.46.05 PM.png 2376](https://files.readme.io/2f4fa81-Screen_Shot_2020-07-14_at_4.46.05_PM.png)
Step 7: Select which subscription plans are impacted
You can choose to apply the transformation to all of the plans or select which specific plans it applies to.
![Screen Shot 2020-07-14 at 4.46.16 PM.png 2380](https://files.readme.io/033b19b-Screen_Shot_2020-07-14_at_4.46.16_PM.png)
How to add header "content-type" [Required if transforming methods]
While transforming methods, you must add the header "content-type" explicitly. To do this, you must leave the Transformations tab and navigate to the Endpoints tab. Click "Edit" on the desired endpoint.
![Screen Shot 2020-07-21 at 2.47.59 PM.png 1911](https://files.readme.io/7f974e9-Screen_Shot_2020-07-21_at_2.47.59_PM.png)
From the Edit Endpoint page, select the Header tab. Add one of the following content-type headers to the Example Value field:
application/json
multipart/form-data
application/x-www-form-urlencoded
![Screen Shot 2020-07-21 at 3.06.12 PM.png 1640](https://files.readme.io/500db23-Screen_Shot_2020-07-21_at_3.06.12_PM.png)
Save the changes once you are finished
Updated over 3 years ago