Use Macros in API Calls
When setting up an API source or destination, macros can be used to customize the data requested in the API call. Macros can also be used to incorporate data returned from one API into the request sent to another API when chaining API calls. The following subsections describe how to use macros in each of these applications, as well as how to use lookup values as macros in API calls.
1. Customize an API Call with Macros
After completing the initial steps of setting up the API source or destination, any number of macros can be incorporated into the API call in the configuration step, .
For information about the initial steps of setting up an API source or destination, see How to Add a Data Source. Connector-specific instructions are also located on the Connectors page.
Click to expand the URL Macros panel and access associated controls.
In the Set API URL field, type a left curly bracket,
{
, at the position where the macro should be added to access a dropdown menu containing all available macros that can be applied.To add a macro listed in the dropdown menu to the Set API URL field, click on the macro in the list, and it will be added at the current position.
Optional: To specify the date-time format to which Nexla should convert date-time macro values, select the desired format from the Date Format for Date/Time Macro pulldown menu.
Optional: To specify the date or time unit that Nexla should use to perform mathematical operations on date-time macro values, select the desired unit from the Time Unit for Operations pulldown menu.
2. Macros in Chained API Calls
When chaining API calls in Nexla, call responses can be used in subsequent API calls in the chain by adding the responses as macros in the Set API URL field.
After setting up the preceding API call, click at the bottom of the screen to configure the next API call.
In the Set API URL field in the newly added step, type a left curly bracket,
{
, at the position where the response macro should be added. Responses from previous API calls will now appear in the dropdown menu of available macros.To add a response macro listed in the dropdown menu to the Set API URL field, click on the macro in the list, and it will be added at the current position.
3. Lookup Values as Macros in API Calls
Column values in any Nexla static or dynamic data lookup accessible to the user can also be added as macros in API calls.
For information about creating and using data lookups in Nexla, see the Help Center articles Create a Static Lookup, Create a Dynamic Lookup, and Transforming with Data Lookups.
In the URL Macros panel, select the lookup containing the value(s) to be used in the API call from the Add Lookups to Supported Macros pulldown menu.
When a lookup is selected from this menu, it will be listed in the Add Lookups to Supported Macros field.
To remove a lookup from the Add Lookups to Supported Macros list, also removing its column values from the available macros dropdown menu, click on the lookup in the list.
Once the lookup is selected, type a left curly bracket,
{
, at the position where the lookup column value macro should be added. All key columns in the selected lookup will now be displayed in the dropdown menu of available macros.To add a lookup column value macro listed in the dropdown menu to the Set API URL field, click on the macro in the list, and it will be added at the current position.