Skip to main content

Overview

Returns full information about a run, including its status, payload, output, metadata, and all attempt history. If authenticated with a Public API key, payload and output are omitted for security.

Endpoint

GET https://api.trigger.dev/api/v3/runs/{runId}

Path parameters

runId
string
required
The unique run ID, prefixed with run_.

Response

id
string
Unique run ID, prefixed with run_.
status
string
Current status. One of: PENDING_VERSION, DELAYED, QUEUED, EXECUTING, REATTEMPTING, FROZEN, COMPLETED, CANCELED, FAILED, CRASHED, INTERRUPTED, SYSTEM_FAILURE.
taskIdentifier
string
The task that was run.
version
string
Worker version that executed the run.
idempotencyKey
string
Idempotency key used when triggering, if provided.
isTest
boolean
Whether this is a test run.
payload
object
The payload passed to the task (omitted for Public API keys).
output
object
The output returned by the task (omitted for Public API keys).
metadata
object
Key-value metadata attached to the run.
tags
string[]
Tags attached to the run.
createdAt
string
ISO 8601 creation timestamp.
updatedAt
string
ISO 8601 last-updated timestamp.
startedAt
string
When execution started.
finishedAt
string
When the run finished.
delayedUntil
string
If delayed, when the run will be enqueued.
ttl
string
Time-to-live set on the run, if any.
expiredAt
string
If the TTL elapsed before execution, when the run expired.
costInCents
number
Compute cost in cents (excludes DEV).
baseCostInCents
number
Invocation cost in cents (excludes DEV).
durationMs
number
Total compute time in ms (excludes waits).
depth
integer
Depth in the task hierarchy. Root runs have depth 0.
batchId
string
Batch ID if this run was created as part of a batch.
triggerFunction
string
One of trigger, triggerAndWait, batchTrigger, batchTriggerAndWait.
Runs related to this one in the task hierarchy.
schedule
object
Schedule that triggered the run, if applicable.
attempts
object[]
History of all execution attempts.

Examples

import { runs } from "@trigger.dev/sdk";

const run = await runs.retrieve("run_p4omhh45hgxxnq1re6ovy");

// Convenience boolean helpers
if (run.isSuccess) {
  console.log("Output:", run.output);
} else if (run.isFailed) {
  console.log("Failed. Last attempt error:", run.attempts.at(-1)?.error);
}

console.log("Status:", run.status);
console.log("Payload:", run.payload);

for (const attempt of run.attempts) {
  if (attempt.status === "FAILED") {
    console.log("Attempt failed:", attempt.error);
  }
}

Response example

{
  "id": "run_p4omhh45hgxxnq1re6ovy",
  "status": "COMPLETED",
  "taskIdentifier": "my-task",
  "version": "20240523.1",
  "isTest": false,
  "payload": { "message": "Hello, world!" },
  "output": { "result": "done" },
  "tags": ["user_5df987al13"],
  "createdAt": "2024-04-01T12:00:00Z",
  "updatedAt": "2024-04-01T12:00:05Z",
  "startedAt": "2024-04-01T12:00:01Z",
  "finishedAt": "2024-04-01T12:00:05Z",
  "durationMs": 4200,
  "costInCents": 0.00292,
  "baseCostInCents": 0.0025,
  "depth": 0,
  "attempts": [
    {
      "id": "attempt_1234",
      "status": "COMPLETED",
      "createdAt": "2024-04-01T12:00:01Z",
      "startedAt": "2024-04-01T12:00:01Z",
      "completedAt": "2024-04-01T12:00:05Z"
    }
  ]
}

Build docs developers (and LLMs) love