Skip to content

Syntax and rules

A reference to keep open while writing instructions. It covers the options you can use, when saving is rejected, limits, and advanced examples.

SyntaxDescriptionIf omitted
:saveName to store the response under. Read JSON with {{ name.field }}JSON is stored in connected, and plain text is printed where the instruction is
:methodget or postget
:bodyData to send with POST. Must be used with :method postCalled with no data
:content_typeFormat of the data you send. Use application/json for a JSON bodyForm format (application/x-www-form-urlencoded)
:headersAdditional headers, written as a JSON object. Example: :headers {"X-Store-Id": "123"}
If it isn’t valid JSON, the call isn’t made and is treated as failed. For authentication headers, use a registered credential
Default headers only
:basic_authName of a credential registered as BasicCalled without authentication
:auth_credentialsName of a credential registered as TokenCalled without authentication
:cache_max_ageHow long to reuse the response, in seconds. If the call returns the same value for every recipient, set it longer to reduce callsDefault cache rules (see Set up response reuse)
:no_cacheCalls fresh every time. Use it for values that must always be current, such as stockCache is used
default:Text to show when the value is empty (an existing personalized message filter)Sent blank
{% abort_message %}Doesn’t send to this recipientSent even if blank
Rejected whenHow to fix
Liquid syntax error, unsupported filter or tagCheck that brackets are paired and filter names are correct
Unsupported option or invalid option value:method accepts only get or post
Write :cache_max_age in seconds (for example, 3600)
:retry isn’t supported yet (coming soon)
Too many calls in a messageWrite no more than 3 across all fields, including subject and content.
Instruction inside a for loopCall once outside the loop and loop over the response array (see example 4 below)
Personalization variable in the domain of the request URLYou can’t use personalization variables in the domain of the request URL
Keep the domain fixed and use variables only in the path or query
Saved name used without a fieldInclude the field, as in {{ point.amount }} instead of {{ point }}
Credential issueCheck that the name is registered, that the type (Basic or Token) matches the option (:basic_auth or :auth_credentials), and that the allowed domain exactly matches the request URL
ItemLimit
Calls per message3 across all fields, including subject and content
· Each instruction counts as one. The same URL written again in a different field counts separately
· Instructions inside {% if %} branches all count, whether or not they run
· In journey automation, 3 per message action
Maximum wait per call2 seconds
Response size1MB
Request URL length2048 characters after variables are filled in
Response cache duration· GET: 5 minutes by default
· POST: only when :cache_max_age is set
· :cache_max_age range: 300 seconds (5 minutes) to 14400 seconds (4 hours). Values outside the range are set to the nearest limit
Credentials10 per project

Examples to refer to once you know the basics.


Example 1. Use the same value in the subject and content

Section titled “Example 1. Use the same value in the subject and content”

A name saved with :save can only be used in the field where the instruction is written. To use it in another field, such as the subject and the content, write the instruction in each field. If the URL is the same, the cached response is reused.

Subject

{% connected_content https://api.example.com/products/{{ tags.wishlist_sku }} :save product %}The price of {{ product.name }} on your wishlist just dropped.

Content

{% connected_content https://api.example.com/products/{{ tags.wishlist_sku }} :save product %}Get it now for {{ product.price | number_with_delimiter }}.

Example 2. Use one response in the next call

Section titled “Example 2. Use one response in the next call”

Instructions run from top to bottom, so you can use a value saved earlier in the next request URL. The next call starts only after the previous one finishes, so wait times add up.

{% connected_content https://api.example.com/me?uid={{ userId }} :save me %}
{% connected_content https://api.example.com/orders/{{ me.id }} :save orders %}
{{ me.name }}, you have {{ orders.total }} orders

Example 3. Call a different API depending on a condition

Section titled “Example 3. Call a different API depending on a condition”

You can call inside {% if %}, and you can use the same name on both sides. It holds the response from whichever side actually ran.

{% if tags.vip %}
{% connected_content https://api.example.com/vip-deals :save deals %}
{% else %}
{% connected_content https://api.example.com/normal-deals :save deals %}
{% endif %}
Today's deal: {{ deals.title }}

Example 4. Show a list from the response with a loop

Section titled “Example 4. Show a list from the response with a loop”

Call the instruction once outside the loop, then show the returned list with a loop.

{% connected_content https://api.example.com/reco?uid={{ userId }} :save reco %}
Recommended for you:
{% for item in reco.items %}
- {{ item.title }} {{ item.price | number_with_delimiter }}
{% endfor %}