{ "openapi": "3.1.0", "info": { "title": "Trigger.dev v3 REST API", "description": "The REST API lets you trigger and manage runs on Trigger.dev. You can trigger a run, get the status of a run, and get the results of a run. ", "version": "2024-04" }, "servers": [ { "url": "https://api.trigger.dev", "description": "Trigger.dev API" } ], "paths": { "/api/v1/schedules": { "post": { "operationId": "create_schedule_v1", "description": "Create a new schedule based on the specified options.", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreateScheduleOptions" } } } }, "responses": { "200": { "description": "Schedule created successfully", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ScheduleObject" } } } }, "400": { "description": "Invalid request parameters" }, "422": { "description": "Unprocessable Entity" }, "401": { "description": "Unauthorized" } }, "tags": [ "schedules" ], "security": [ { "bearerAuth": [] } ], "x-codeSamples": [ { "lang": "typescript", "source": "import { schedules } from \"@trigger.dev/sdk/v3\";\n\nconst schedule = await schedules.create({\n task: 'my-task',\n cron: '0 0 * * *'\n});" }, { "lang": "sh", "source": "curl --request POST \\\n\t--url https://api.trigger.dev/api/v1/schedules \\\n\t--header 'Authorization: Bearer ' \\\n\t--header 'Content-Type: application/json' \\\n\t--data '{\"task\":\"my-task\",\"cron\":\"0 0 * * *\"}'" } ] }, "get": { "operationId": "list_schedules_v1", "description": "List all schedules.", "parameters": [ { "in": "query", "name": "page", "schema": { "type": "integer" }, "required": false, "description": "Page number of the schedule listing" }, { "in": "query", "name": "perPage", "schema": { "type": "integer" }, "required": false, "description": "Number of schedules per page" } ], "responses": { "200": { "description": "Successful request", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ListSchedulesResult" } } } }, "401": { "description": "Unauthorized request" } }, "tags": [ "schedules" ], "security": [ { "bearerAuth": [] } ], "x-codeSamples": [ { "lang": "typescript", "source": "import { schedules } from \"@trigger.dev/sdk/v3\";\n\nconst allSchedules = await schedules.list();" }, { "lang": "sh", "source": "curl --request GET \\\n\t--url https://api.trigger.dev/api/v1/schedules \\\n\t--header 'Authorization: Bearer '" } ] } }, "/api/v1/schedules/{schedule_id}": { "get": { "operationId": "get_schedule_v1", "description": "Get a schedule by its ID.", "parameters": [ { "in": "path", "name": "schedule_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the schedule." } ], "responses": { "200": { "description": "Successful request", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ScheduleObject" } } } }, "401": { "description": "Unauthorized request" }, "404": { "description": "Resource not found" } }, "tags": [ "schedules" ], "security": [ { "bearerAuth": [] } ], "x-codeSamples": [ { "lang": "typescript", "source": "import { schedules } from \"@trigger.dev/sdk/v3\";\n\nconst schedule = await schedules.retrieve(scheduleId);" }, { "lang": "sh", "source": "curl --request GET \\\n\t--url https://api.trigger.dev/api/v1/schedules/{schedule_id} \\\n\t--header 'Authorization: Bearer '" } ] }, "put": { "operationId": "update_schedule_v1", "description": "Update a schedule by its ID.", "parameters": [ { "in": "path", "name": "schedule_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the schedule." } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreateScheduleOptions" } } } }, "responses": { "200": { "description": "Schedule updated successfully", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ScheduleObject" } } } }, "400": { "description": "Invalid request parameters" }, "401": { "description": "Unauthorized" }, "404": { "description": "Resource not found" }, "422": { "description": "Unprocessable Entity" } }, "tags": [ "schedules" ], "security": [ { "bearerAuth": [] } ], "x-codeSamples": [ { "lang": "typescript", "source": "import { schedules } from \"@trigger.dev/sdk/v3\";\n\nconst updatedSchedule = await schedules.update(scheduleId, {\n task: 'my-updated-task',\n cron: '0 0 * * *'\n});" }, { "lang": "sh", "source": "curl --request PUT \\\n\t--url https://api.trigger.dev/api/v1/schedules/{schedule_id} \\\n\t--header 'Authorization: Bearer ' \\\n\t--header 'Content-Type: application/json' \\\n\t--data '{\"task\":\"my-updated-task\",\"cron\":\"0 0 * * *\"}'" } ] }, "delete": { "operationId": "delete_schedule_v1", "description": "Delete a schedule by its ID.", "parameters": [ { "in": "path", "name": "schedule_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the schedule." } ], "responses": { "200": { "description": "Schedule deleted successfully" }, "401": { "description": "Unauthorized request" }, "404": { "description": "Resource not found" } }, "tags": [ "schedules" ], "security": [ { "bearerAuth": [] } ], "x-codeSamples": [ { "lang": "typescript", "source": "import { schedules } from \"@trigger.dev/sdk/v3\";\n\nawait schedules.del(scheduleId);" }, { "lang": "sh", "source": "curl --request DELETE \\\n\t--url https://api.trigger.dev/api/v1/schedules/{schedule_id} \\\n\t--header 'Authorization: Bearer '" } ] } }, "/api/v1/schedules/{schedule_id}/deactivate": { "post": { "operationId": "deactivate_schedule_v1", "description": "Deactivate a schedule by its ID.", "parameters": [ { "in": "path", "name": "schedule_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the schedule." } ], "responses": { "200": { "description": "Schedule updated successfully", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ScheduleObject" } } } }, "401": { "description": "Unauthorized request" }, "404": { "description": "Resource not found" } }, "tags": [ "schedules" ], "security": [ { "bearerAuth": [] } ], "x-codeSamples": [ { "lang": "typescript", "source": "import { schedules } from \"@trigger.dev/sdk/v3\";\n\nconst schedule = await schedules.deactivate(scheduleId);" }, { "lang": "sh", "source": "curl --request POST \\\n\t--url https://api.trigger.dev/api/v1/schedules/{schedule_id}/deactivate \\\n\t--header 'Authorization: Bearer '" } ] } }, "/api/v1/schedules/{schedule_id}/activate": { "post": { "operationId": "activate_schedule_v1", "description": "Activate a schedule by its ID.", "parameters": [ { "in": "path", "name": "schedule_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the schedule." } ], "responses": { "200": { "description": "Schedule updated successfully", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ScheduleObject" } } } }, "401": { "description": "Unauthorized request" }, "404": { "description": "Resource not found" } }, "tags": [ "schedules" ], "security": [ { "bearerAuth": [] } ], "x-codeSamples": [ { "lang": "typescript", "source": "import { schedules } from \"@trigger.dev/sdk/v3\";\n\nconst schedule = await schedules.activate(scheduleId);" }, { "lang": "sh", "source": "curl --request POST \\\n\t--url https://api.trigger.dev/api/v1/schedules/{schedule_id}/activate \\\n\t--header 'Authorization: Bearer '" } ] } }, "/api/v1/runs/{run_id}/replay": { "post": { "description": "Creates a new run with the same payload and options as the original run.", "parameters": [ { "in": "path", "name": "run_id", "required": true, "schema": { "type": "string" }, "description": "The ID of an existing run. When you trigger a run you will get an id in the response." } ], "responses": { "200": { "description": "Successful request", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string", "description": "The ID of the new run." } } } } } }, "400": { "description": "Invalid request", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string", "enum": [ "Invalid or missing run ID", "Failed to create new run" ] } } } } } }, "401": { "description": "Unauthorized request", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string", "enum": [ "Invalid or Missing API key" ] } } } } } }, "404": { "description": "Resource not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string", "enum": [ "Run not found" ] } } } } } } }, "tags": [ "run" ], "security": [ { "bearerAuth": [] } ], "operationId": "replay_run_v1", "x-codeSamples": [ { "lang": "typescript", "source": "import { runs } from \"@trigger.dev/sdk/v3\";\n\nconst handle = await runs.replay(\"run_1234\");" }, { "lang": "sh", "source": "curl --request POST \\\n\t--url https://api.trigger.dev/api/v1/runs/{run_id}/replay \\\n\t--header 'Authorization: Bearer '" } ] } }, "/api/v1/runs/{run_id}/cancel": { "post": { "description": "Cancels a run.", "parameters": [ { "in": "path", "name": "run_id", "required": true, "schema": { "type": "string" }, "description": "The ID of an existing run. When you trigger a run you will get an id in the response." } ], "responses": { "200": { "description": "Successful request", "content": { "application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string", "description": "Confirmation message that the run was canceled." } } } } } }, "400": { "description": "Invalid request", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string", "enum": [ "Invalid or missing run ID", "Failed to create new run" ] } } } } } }, "401": { "description": "Unauthorized request", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string", "enum": [ "Invalid or Missing API key" ] } } } } } }, "404": { "description": "Resource not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string", "enum": [ "Run not found" ] } } } } } } }, "tags": [ "run" ], "security": [ { "bearerAuth": [] } ], "operationId": "replay_run_v1", "x-codeSamples": [ { "lang": "typescript", "source": "import { runs } from \"@trigger.dev/sdk/v3\";\n\nawait runs.cancel(\"run_1234\");" }, { "lang": "sh", "source": "curl --request POST \\\n\t--url https://api.trigger.dev/api/v1/runs/{run_id}/cancel \\\n\t--header 'Authorization: Bearer '" } ] } }, "/api/v3/runs/{run_id}": { "get": { "description": "Retrieve a run", "parameters": [ { "in": "path", "name": "run_id", "required": true, "schema": { "type": "string" }, "description": "The ID of an existing run. When you trigger a run you will get an id in the response." } ], "responses": { "200": { "description": "Successful request", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RetrieveRunResponse" } } } }, "400": { "description": "Invalid request", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string", "enum": [ "Invalid or missing run ID" ] } } } } } }, "401": { "description": "Unauthorized request", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string", "enum": [ "Invalid or Missing API key" ] } } } } } }, "404": { "description": "Resource not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string", "enum": [ "Run not found" ] } } } } } } }, "tags": [ "run" ], "security": [ { "bearerAuth": [] } ], "operationId": "retrieve_run_v1", "x-codeSamples": [ { "lang": "typescript", "source": "import { runs } from \"@trigger.dev/sdk/v3\";\n\nawait runs.retrieve(\"run_1234\");" }, { "lang": "sh", "source": "curl --request GET \\\n\t--url https://api.trigger.dev/api/v3/runs/{run_id} \\\n\t--header 'Authorization: Bearer '" } ] } } }, "components": { "securitySchemes": { "bearerAuth": { "type": "http", "scheme": "bearer", "description": "Use your Secret API key in the form 'Bearer ' (without the quotation marks)" } }, "schemas": { "RetrieveRunResponse": { "type": "object", "required": [ "id", "status", "taskIdentifier", "createdAt", "updatedAt", "attempts" ], "properties": { "id": { "type": "string" }, "status": { "type": "string", "enum": [ "PENDING", "EXECUTING", "PAUSED", "COMPLETED", "FAILED", "CANCELED" ] }, "taskIdentifier": { "type": "string" }, "idempotencyKey": { "type": "string" }, "version": { "type": "string" }, "createdAt": { "type": "string", "format": "date-time" }, "updatedAt": { "type": "string", "format": "date-time" }, "attempts": { "type": "array", "items": { "type": "object", "required": [ "id", "status", "createdAt", "updatedAt" ], "properties": { "id": { "type": "string" }, "status": { "type": "string", "enum": [ "PENDING", "EXECUTING", "PAUSED", "COMPLETED", "FAILED", "CANCELED" ] }, "createdAt": { "type": "string", "format": "date-time" }, "updatedAt": { "type": "string", "format": "date-time" }, "startedAt": { "type": "string", "format": "date-time" }, "completedAt": { "type": "string", "format": "date-time" } } } } } }, "CreateScheduleOptions": { "type": "object", "properties": { "task": { "type": "string" }, "cron": { "type": "string" }, "deduplicationKey": { "type": "string" }, "externalId": { "type": "string" } }, "required": [ "task", "cron" ] }, "ScheduleObject": { "type": "object", "properties": { "id": { "type": "string", "example": "sched_1234", "description": "The unique ID of the schedule, prefixed with 'sched_'" }, "task": { "type": "string", "example": "my-scheduled-task", "description": "The id of the scheduled task that will be triggered by this schedule" }, "active": { "type": "boolean", "example": true, "description": "Whether the schedule is active or not" }, "deduplicationKey": { "type": "string", "example": "dedup_key_1234", "description": "The deduplication key used to prevent creating duplicate schedules" }, "externalId": { "type": "string", "example": "user_1234", "description": "The external ID of the schedule. Can be anything that is useful to you (e.g., user ID, org ID, etc.)" }, "generator": { "type": "object", "properties": { "type": { "type": "string", "enum": [ "CRON" ] }, "expression": { "type": "string", "description": "The cron expression used to generate the schedule", "example": "0 0 * * *" }, "description": { "type": "string", "description": "The description of the generator in plain english", "example": "Every day at midnight" } } }, "nextRun": { "type": "string", "format": "date-time", "description": "The next time the schedule will run", "example": "2024-04-01T00:00:00Z" }, "environments": { "type": "array", "items": { "$ref": "#/components/schemas/ScheduleEnvironment" } } } }, "ListSchedulesResult": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/ScheduleObject" } }, "pagination": { "type": "object", "properties": { "currentPage": { "type": "integer" }, "totalPages": { "type": "integer" }, "count": { "type": "integer" } } } } }, "ScheduleEnvironment": { "type": "object", "properties": { "id": { "type": "string" }, "type": { "type": "string" }, "userName": { "type": "string" } } } } }, "security": [ { "bearerAuth": [] } ] }