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
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:Runs API
runs.list()
List runs with optional filters:
runs.retrieve()
Fetch a single run by its ID:
payload and output:
runs.cancel()
Cancel a run that is queued or executing:
- 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:
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: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: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.