Files
triggerdotdev--trigger.dev/docs/v3-openapi.json
T
Eric Allam 44e1b87547 v3: various schedule fixes (#1040)
* Improve the SDK function types and expose a new APIError instead of the APIResult type

* Skip triggering scheduled tasks if the task isn’t found in the current deployment

Also fixes an issue when editing the environments of a schedule
2024-04-17 15:10:23 +01:00

753 lines
21 KiB
JSON

{
"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 <token>' \\\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 <token>'"
}
]
}
},
"/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 <token>'"
}
]
},
"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 <token>' \\\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 <token>'"
}
]
}
},
"/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 <token>'"
}
]
}
},
"/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 <token>'"
}
]
}
},
"/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": "const handle = await runs.replay(existingRun.id);"
},
{
"lang": "sh",
"source": "curl --request POST \\\n\t--url https://api.trigger.dev/api/v1/runs/{run_id}/replay \\\n\t--header 'Authorization: Bearer <token>'"
}
]
}
},
"/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": "await runs.cancel(existingRun.id);"
},
{
"lang": "sh",
"source": "curl --request POST \\\n\t--url https://api.trigger.dev/api/v1/runs/{run_id}/cancel \\\n\t--header 'Authorization: Bearer <token>'"
}
]
}
}
},
"components": {
"securitySchemes": {
"bearerAuth": {
"type": "http",
"scheme": "bearer",
"description": "Use your Secret API key in the form 'Bearer <SECRET KEY>' (without the quotation marks)"
}
},
"schemas": {
"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": []
}
]
}