How to use macros in Coupler.io importers?

In any text field of Coupler.io importer, you can use macros to interpolate date-time strings. Macro is a pattern that specifies how a certain input should be mapped to a replacement output.

For example, you don’t have to manually specify yesterday's date-time value in Quickbooks report parameters or JSON URL query. 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
  • tomorrow
  • 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
  • 2weeksfromnow
    • 2 can be replaced with any numeral
    • weeks can be replaced with days or 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
to: {{1yearfromnow}} to: 2024-07-04

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
  • 1hourfromnow
    • 1 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
created_at: {{3hoursfromnow}} created_at: 2020-12-24T18:00:00Z

Check out this Coupler.io 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
created_at: {{55hoursfromnow.format(YYYY-MM-DD)}} created_at: 2023-07-06

Where I can use macros

You can use date and date-time macros in:

  • JSON / CSV URL, URL query string and Body fields of the JSON or CSV Client importer.
  • Quickbooks "Where" field
    • Note: QB requires using of macro values in single quotes, i.e. '{{today}}'. Check more here.
  • Quickbooks reports the "Query parameters" field
  • Xero "Where" field
    • Note: special formatting to be used with Xero Importer: check the details here.
  • Xero reports "Report Period" field
  • BigQuery "SQL query" field
  • JIRA "JQL" field
  • Slack "Search query" field
  • Shopify "Created after date", "Created before date", "Changed after date", "Changed before date" fields
  • Facebook Ads "From", "To" fields
  • WooCommerce "After date", "Before date" fields
  • SalesForce "Changed after date", "Changed before date" fields
  • Mailchimp "Created after date", "Created before date", "Sent since date", "Sent before date" fields
  • Hubspot  "Created after date", "Created before date", "Updated after date", "Updated before date" fields
    • Note: only date macros are available for Hubspot date fields. Date and time macros ( {{hourago}} etc) are unavailible.

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:

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.