How to use macros in JSON Client importer

Macro is a pattern that specifies how a certain input should be mapped to a replacement output. In the JSON Client importer, you can use macros to interpolate date-time strings.

For example, you don’t have to manually specify yesterday's date-time value in the URL query string. You can instead type {{yesterday}}, and the importer will automatically interpolate it with yesterday’s date-time value.

Macro's syntax:

{{macro}}

Supported date macros

The default date format is YYYY-MM-DD that corresponds to the ISO 8601 date standard.

  • today
  • yesterday
  • thisweekstart
    • this can be replaced with last or next
    • week can be replaced with month or quarter or year
    • start can be replaced with end
  • weekago
    • week can be replaced with month or quarter or year
  • 2weeksago
    • 2 can be replaced with any numeral
    • weeks can be replaced with months or quarters or years

Date macros usage examples

Parameter + macro Output
start_date: {{today}}
start_date: 2020-12-24
updated_at: {{thisweekstart}} updated_at: 2020-12-21
to: {{3monthsago}} to: 2020-09-24

Supported date-time macros

The default date and time format is YYYY-MM-DD[T]hh:mm:ss[Z] that corresponds to the ISO 8601 date and time standard.

  • now
  • thishourstart
    • thiscan be replaced with last or next
    • start can be replaced with end
  • hourago
  • 2hoursago
    • 2 can be replaced with any numeral

Date-time macros usage examples

Parameter + macro Output
created_at: {{lasthourstart}} created_at: 2020-12-24T14:00:00Z
updated_since: {{5hoursago}} updated_since: 2020-12-24T07:00:00Z

Check out this JSON Client macros generator to optimize your flow.

Custom format

You can format each macro as needed using the following syntax:

{{macro.format(output-format)}}

  • macro - specify the macro you need
  • output-format - specify the format you want the macro to output

Macros custom format example

Parameter + macro Output
start_date: {{today.format(DDDD)}} start_date: Thursday
created_at: {{5hoursago.format(hh:mm)}} created_at: 08:23

Where I can use macros


You can use date and date-time macros in JSON URL, URL query string and Body fields of the JSON Client importer. The most frequent cases, however, include the field " URL query string" for GET requests, for example:

and the field “ Request body" for POST requests. For example, here is how you can post a message to Slack:

And here is the output:

Book a free onboarding call! 
For any questions, feel free to email our team at  contact@coupler.io