run

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.

Syntax

{% run "script_handle", param1:value1, param2:value2 %}
  • "script_handle" — the handle (or ID) of the script to run.

  • param1:value1, param2:value2 — named parameters. Each becomes a variable inside the target script.

Parameters

Named parameters let you pass values into the target script. Each key:value pair becomes a variable accessible in the script's scope.

Values can be variables, string literals, or any Liquid expression:

{% assign customer_email = "[email protected]" %}

{% run "send_welcome_email", email:customer_email, template:"onboarding" %}

Inside send_welcome_email, email and template are available as regular variables.

You can pass as many parameters as needed:

{% run "sync_inventory", product_id:product.id, warehouse:"EU", quantity:new_qty %}

No return value

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 valuerun 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.

Last updated