The run tag executes another script asynchronously. Unlike function, run does not wait for the target script to finish and does not return a result. The calling script continues immediately after triggering the run.
This is useful for offloading work that doesn't need to happen inline — sending notifications, syncing data, processing queues, and other background tasks.
Since run executes asynchronously, there is no as result clause. The calling script does not wait for the target script to finish and cannot access its result.
The log line executes immediately — it does not wait for process_order to complete.
If you need the result of another script, use function instead:
Delayed execution
Use the delay parameter to schedule a script to run after a specified number of seconds:
This triggers send_followup_email after 1 hour (3600 seconds).
The delay value can also be a variable:
Dynamic handle
The script handle can be a variable instead of a string literal. This lets you decide which script to run at runtime:
Example: Trigger background sync for each order item
Each run call is dispatched asynchronously. The loop completes immediately without waiting for any of the sync scripts to finish.
Example: Send notification with delay
Legacy format: JSON payload
The old format using a single JSON payload variable is still supported. All keys from the payload object are spread into the target script's scope.
Note: Named parameters and the JSON payload format cannot be mixed in a single call. Use one or the other.
Limitations
No return value — run is fire-and-forget. Use function if you need a result.
No recursive runs — a script cannot run itself, directly or through a chain of other scripts.
Task variables are not available inside the target script. Pass any values you need as parameters.
Global variables are accessible inside the target script.
{% for item in order.line_items %}
{% run "sync_item_inventory", variant_id:item.variant_id, quantity:item.quantity %}
{% endfor %}
{% log "Inventory sync triggered for all items" %}
{% run "send_reminder", email:customer.email, order_name:order.name, delay:86400 %}
{% log "Reminder scheduled for 24h from now" %}