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 withlast
ornext
week
can be replaced withmonth
orquarter
oryear
start
can be replaced withend
weekago
week
can be replaced withmonth
orquarter
oryear
2weeksago
2
can be replaced with any numeralweeks
can be replaced withmonths
orquarters
oryears
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
this
can be replaced withlast
ornext
start
can be replaced withend
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 needoutput-format
- specify the format you want themacro
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