Tasks API
Schedules API
Runs API
Retrieve run
Runs API
Retrieve run
Retrieve information about a run, including its status, payload, output, and attempts. If you authenticate with a Public API key, we will omit the payload and output fields for security reasons.
GET
/
api
/
v3
/
runs
/
{runId}
import { runs } from "@trigger.dev/sdk/v3";
const result = await runs.retrieve("run_1234");
// We include boolean helpers to check the status of the run
// (isSuccess, isFailed, isCompleted, etc.)
if (result.isSuccess) {
console.log("Run was successful with output", result.output);
}
// You also have access to the run status that includes more granular information
console.log("Run status:", result.status);
// You can access the payload and output
console.log("Payload:", result.payload);
console.log("Output:", result.output);
// You can also access the attempts, which will give you information about errors (if they exist)
for (const attempt of result.attempts) {
if (attempt.status === "FAILED") {
console.log("Attempt failed with error:", attempt.error);
}
}
{
"id": "run_1234",
"status": "PENDING_VERSION",
"taskIdentifier": "my-task",
"version": 20240523.1,
"idempotencyKey": "idempotency_key_1234",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"isTest": false,
"startedAt": "2023-11-07T05:31:56Z",
"finishedAt": "2023-11-07T05:31:56Z",
"delayedUntil": "2023-11-07T05:31:56Z",
"ttl": "1h42m",
"expiredAt": "2023-11-07T05:31:56Z",
"tags": [
"user_5df987al13",
"org_c6b7dycmxw"
],
"metadata": {
"foo": "bar"
},
"costInCents": 0.00292,
"baseCostInCents": 0.0025,
"durationMs": 491,
"depth": 0,
"batchId": "batch_1234",
"triggerFunction": "trigger",
"payload": {
"foo": "bar"
},
"payloadPresignedUrl": "https://r2.cloudflarestorage.com/packets/yubjwjsfkxnylobaqvqz/dev/run_p4omhh45hgxxnq1re6ovy/payload.json?X-Amz-Expires=300&X-Amz-Date=20240625T154526Z&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=10b064e58a0680db5b5e077be2be3b2a%2F20240625%2Fauto%2Fs3%2Faws4_request&X-Amz-SignedHeaders=host&X-Amz-Signature=88604cb993ffc151b4d73f2439da431d9928488e4b3dcfa4a7c8f1819",
"output": {
"foo": "bar"
},
"outputPresignedUrl": "https://r2.cloudflarestorage.com/packets/yubjwjsfkxnylobaqvqz/dev/run_p4omhh45hgxxnq1re6ovy/payload.json?X-Amz-Expires=300&X-Amz-Date=20240625T154526Z&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=10b064e58a0680db5b5e077be2be3b2a%2F20240625%2Fauto%2Fs3%2Faws4_request&X-Amz-SignedHeaders=host&X-Amz-Signature=88604cb993ffc151b4d73f2439da431d9928488e4b3dcfa4a7c8f1819",
"relatedRuns": {
"root": {
"id": "run_1234",
"status": "PENDING_VERSION",
"taskIdentifier": "my-task",
"version": 20240523.1,
"idempotencyKey": "idempotency_key_1234",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"isTest": false,
"startedAt": "2023-11-07T05:31:56Z",
"finishedAt": "2023-11-07T05:31:56Z",
"delayedUntil": "2023-11-07T05:31:56Z",
"ttl": "1h42m",
"expiredAt": "2023-11-07T05:31:56Z",
"tags": [
"user_5df987al13",
"org_c6b7dycmxw"
],
"metadata": {
"foo": "bar"
},
"costInCents": 0.00292,
"baseCostInCents": 0.0025,
"durationMs": 491,
"depth": 0,
"batchId": "batch_1234",
"triggerFunction": "trigger"
},
"parent": {
"id": "run_1234",
"status": "PENDING_VERSION",
"taskIdentifier": "my-task",
"version": 20240523.1,
"idempotencyKey": "idempotency_key_1234",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"isTest": false,
"startedAt": "2023-11-07T05:31:56Z",
"finishedAt": "2023-11-07T05:31:56Z",
"delayedUntil": "2023-11-07T05:31:56Z",
"ttl": "1h42m",
"expiredAt": "2023-11-07T05:31:56Z",
"tags": [
"user_5df987al13",
"org_c6b7dycmxw"
],
"metadata": {
"foo": "bar"
},
"costInCents": 0.00292,
"baseCostInCents": 0.0025,
"durationMs": 491,
"depth": 0,
"batchId": "batch_1234",
"triggerFunction": "trigger"
},
"children": [
{
"id": "run_1234",
"status": "PENDING_VERSION",
"taskIdentifier": "my-task",
"version": 20240523.1,
"idempotencyKey": "idempotency_key_1234",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"isTest": false,
"startedAt": "2023-11-07T05:31:56Z",
"finishedAt": "2023-11-07T05:31:56Z",
"delayedUntil": "2023-11-07T05:31:56Z",
"ttl": "1h42m",
"expiredAt": "2023-11-07T05:31:56Z",
"tags": [
"user_5df987al13",
"org_c6b7dycmxw"
],
"metadata": {
"foo": "bar"
},
"costInCents": 0.00292,
"baseCostInCents": 0.0025,
"durationMs": 491,
"depth": 0,
"batchId": "batch_1234",
"triggerFunction": "trigger"
}
]
},
"schedule": {
"id": "sched_1234",
"externalId": "user_1234",
"deduplicationKey": "dedup_key_1234",
"generator": {
"type": "CRON",
"expression": "0 0 * * *",
"description": "Every day at midnight"
}
},
"attempts": [
{
"id": "attempt_1234",
"status": "PENDING",
"error": {
"message": "Something went wrong",
"name": "Error",
"stackTrace": "Error: Something went wrong"
},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"startedAt": "2023-11-07T05:31:56Z",
"completedAt": "2023-11-07T05:31:56Z"
}
]
}
Authorizations
Use your project-specific Secret API key. Will start with tr_dev_
, tr_prod
, tr_stg
, etc.
You can find your Secret API key in the API Keys section of your Trigger.dev project dashboard.
Our TypeScript SDK will default to using the value of the TRIGGER_SECRET_KEY
environment variable if it is set. If you are using the SDK in a different environment, you can set the key using the configure
function.
import { configure } from "@trigger.dev/sdk/v3";
configure({ accessToken: "tr_dev_1234" });
Path Parameters
The ID of an run, starts with run_
. The run ID will be returned when you trigger a run on a task.
Response
200
application/json
Successful request
The response is of type object
.
import { runs } from "@trigger.dev/sdk/v3";
const result = await runs.retrieve("run_1234");
// We include boolean helpers to check the status of the run
// (isSuccess, isFailed, isCompleted, etc.)
if (result.isSuccess) {
console.log("Run was successful with output", result.output);
}
// You also have access to the run status that includes more granular information
console.log("Run status:", result.status);
// You can access the payload and output
console.log("Payload:", result.payload);
console.log("Output:", result.output);
// You can also access the attempts, which will give you information about errors (if they exist)
for (const attempt of result.attempts) {
if (attempt.status === "FAILED") {
console.log("Attempt failed with error:", attempt.error);
}
}
{
"id": "run_1234",
"status": "PENDING_VERSION",
"taskIdentifier": "my-task",
"version": 20240523.1,
"idempotencyKey": "idempotency_key_1234",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"isTest": false,
"startedAt": "2023-11-07T05:31:56Z",
"finishedAt": "2023-11-07T05:31:56Z",
"delayedUntil": "2023-11-07T05:31:56Z",
"ttl": "1h42m",
"expiredAt": "2023-11-07T05:31:56Z",
"tags": [
"user_5df987al13",
"org_c6b7dycmxw"
],
"metadata": {
"foo": "bar"
},
"costInCents": 0.00292,
"baseCostInCents": 0.0025,
"durationMs": 491,
"depth": 0,
"batchId": "batch_1234",
"triggerFunction": "trigger",
"payload": {
"foo": "bar"
},
"payloadPresignedUrl": "https://r2.cloudflarestorage.com/packets/yubjwjsfkxnylobaqvqz/dev/run_p4omhh45hgxxnq1re6ovy/payload.json?X-Amz-Expires=300&X-Amz-Date=20240625T154526Z&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=10b064e58a0680db5b5e077be2be3b2a%2F20240625%2Fauto%2Fs3%2Faws4_request&X-Amz-SignedHeaders=host&X-Amz-Signature=88604cb993ffc151b4d73f2439da431d9928488e4b3dcfa4a7c8f1819",
"output": {
"foo": "bar"
},
"outputPresignedUrl": "https://r2.cloudflarestorage.com/packets/yubjwjsfkxnylobaqvqz/dev/run_p4omhh45hgxxnq1re6ovy/payload.json?X-Amz-Expires=300&X-Amz-Date=20240625T154526Z&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=10b064e58a0680db5b5e077be2be3b2a%2F20240625%2Fauto%2Fs3%2Faws4_request&X-Amz-SignedHeaders=host&X-Amz-Signature=88604cb993ffc151b4d73f2439da431d9928488e4b3dcfa4a7c8f1819",
"relatedRuns": {
"root": {
"id": "run_1234",
"status": "PENDING_VERSION",
"taskIdentifier": "my-task",
"version": 20240523.1,
"idempotencyKey": "idempotency_key_1234",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"isTest": false,
"startedAt": "2023-11-07T05:31:56Z",
"finishedAt": "2023-11-07T05:31:56Z",
"delayedUntil": "2023-11-07T05:31:56Z",
"ttl": "1h42m",
"expiredAt": "2023-11-07T05:31:56Z",
"tags": [
"user_5df987al13",
"org_c6b7dycmxw"
],
"metadata": {
"foo": "bar"
},
"costInCents": 0.00292,
"baseCostInCents": 0.0025,
"durationMs": 491,
"depth": 0,
"batchId": "batch_1234",
"triggerFunction": "trigger"
},
"parent": {
"id": "run_1234",
"status": "PENDING_VERSION",
"taskIdentifier": "my-task",
"version": 20240523.1,
"idempotencyKey": "idempotency_key_1234",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"isTest": false,
"startedAt": "2023-11-07T05:31:56Z",
"finishedAt": "2023-11-07T05:31:56Z",
"delayedUntil": "2023-11-07T05:31:56Z",
"ttl": "1h42m",
"expiredAt": "2023-11-07T05:31:56Z",
"tags": [
"user_5df987al13",
"org_c6b7dycmxw"
],
"metadata": {
"foo": "bar"
},
"costInCents": 0.00292,
"baseCostInCents": 0.0025,
"durationMs": 491,
"depth": 0,
"batchId": "batch_1234",
"triggerFunction": "trigger"
},
"children": [
{
"id": "run_1234",
"status": "PENDING_VERSION",
"taskIdentifier": "my-task",
"version": 20240523.1,
"idempotencyKey": "idempotency_key_1234",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"isTest": false,
"startedAt": "2023-11-07T05:31:56Z",
"finishedAt": "2023-11-07T05:31:56Z",
"delayedUntil": "2023-11-07T05:31:56Z",
"ttl": "1h42m",
"expiredAt": "2023-11-07T05:31:56Z",
"tags": [
"user_5df987al13",
"org_c6b7dycmxw"
],
"metadata": {
"foo": "bar"
},
"costInCents": 0.00292,
"baseCostInCents": 0.0025,
"durationMs": 491,
"depth": 0,
"batchId": "batch_1234",
"triggerFunction": "trigger"
}
]
},
"schedule": {
"id": "sched_1234",
"externalId": "user_1234",
"deduplicationKey": "dedup_key_1234",
"generator": {
"type": "CRON",
"expression": "0 0 * * *",
"description": "Every day at midnight"
}
},
"attempts": [
{
"id": "attempt_1234",
"status": "PENDING",
"error": {
"message": "Something went wrong",
"name": "Error",
"stackTrace": "Error: Something went wrong"
},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"startedAt": "2023-11-07T05:31:56Z",
"completedAt": "2023-11-07T05:31:56Z"
}
]
}