Skip to main content
A run is created each time you trigger a task. It represents a single execution instance and tracks the task’s payload, status, output, and metadata throughout its lifetime.

What is a run?

A run contains:
  • A unique run ID
  • The current status
  • The payload (input data)
  • The output (result data, once complete)
  • Metadata, tags, and other contextual information

The run lifecycle

A run moves through several states during execution. The following sections describe all possible states.

Initial states

Execution states

Final states

Attempts

An attempt is a single execution of a task within a run. A run can have multiple attempts if it fails and retries. Each attempt has:
  • A unique attempt ID
  • A status
  • An output or error
When a task fails, it is retried according to its retry settings, creating new attempts until it succeeds or exhausts the retry limit.

Boolean helpers

Run objects returned from the SDK include boolean helpers to check state without comparing status strings:
Boolean helpers are also available when subscribing to real-time run updates:

Runs API

runs.list()

List runs with optional filters:

runs.retrieve()

Fetch a single run by its ID:
Provide the task type to get typed payload and output:
Pass the trigger response directly to skip repeating the run ID:

runs.cancel()

Cancel a run that is queued or executing:
When a run is canceled:
  • Execution is stopped
  • The run is marked as canceled
  • No further retries occur
  • Any in-progress child runs are also canceled

runs.replay()

Create a new run with the same payload as a previous run:
The new run uses the latest deployed version of the task.

runs.reschedule()

Update the delay on a run that is in the DELAYED state:

Advanced run features

Time-to-live (TTL)

Set a TTL when triggering to automatically expire a run if it has not started within the given time:
Expired runs show as Expired in the dashboard.
Dev runs automatically get a 10-minute TTL. On Trigger.dev Cloud, staging and production runs receive a maximum TTL of 14 days.

Delayed runs

Schedule a run to start after a delay:
Delayed runs show as Delayed in the dashboard. You can reschedule or cancel them using runs.reschedule() and runs.cancel().

Idempotency keys

Prevent duplicate runs by providing an idempotency key:
  • If a run with the same key is in progress, the new trigger is ignored and the existing run’s handle is returned.
  • If the run has already completed, the previous output or error is returned immediately.
See the wait documentation for more information.

Triggering for undeployed tasks

You can trigger a run for a task that has not been deployed yet. The run enters a Pending version state and starts executing once the task is deployed. This is useful in CI/CD pipelines where you want to enqueue work before the deployment completes.

Real-time run updates

Subscribe to a run’s state changes in real time:
For more on real-time updates, see the Realtime documentation.