Skip to main content

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, Configure.png.

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.

  1. Click URL_Macros.png to expand the URL Macros panel and access associated controls.

      URL_Macros2.png

  2. 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.

      Macros_Menu.png

  3. 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.

      Macro_Added3.png

  4. 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.

      DateTime.png

  5. 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.

      Time_Unit.png

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.

  1. After setting up the preceding API call, click Add_Another_Step.png at the bottom of the screen to configure the next API call.

  2. 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.

      Response_Macros.png

  3. 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.

      Macro_Added3_b.png

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.

  1. 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.

      Lookup_Macros9.png

    • When a lookup is selected from this menu, it will be listed in the Add Lookups to Supported Macros field.

        Lookup_Macros6.png

    • To remove a lookup from the Add Lookups to Supported Macros list, also removing its column values from the available macros dropdown menu, click Delete_Lookup.png on the lookup in the list.

        Delete_Lookup2.png

  2. 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.

      Lookup_Macros7.png

  3. 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.

      Lookup_Macro_Added3.png