Add trigger and batch trigger API docs
This commit is contained in:
+80
-20
@@ -1,8 +1,14 @@
|
||||
{
|
||||
"$schema": "https://mintlify.com/schema.json",
|
||||
"name": "Trigger.dev",
|
||||
"openapi": ["/openapi.yml", "/v3-openapi.yaml"],
|
||||
"versions": ["v3 (Developer Preview)", "v2"],
|
||||
"openapi": [
|
||||
"/openapi.yml",
|
||||
"/v3-openapi.yaml"
|
||||
],
|
||||
"versions": [
|
||||
"v3 (Developer Preview)",
|
||||
"v2"
|
||||
],
|
||||
"api": {
|
||||
"playground": {
|
||||
"mode": "simple"
|
||||
@@ -96,7 +102,9 @@
|
||||
{
|
||||
"group": "",
|
||||
"version": "v3 (Developer Preview)",
|
||||
"pages": ["v3/introduction"]
|
||||
"pages": [
|
||||
"v3/introduction"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Getting Started",
|
||||
@@ -119,7 +127,10 @@
|
||||
"v3/apikeys",
|
||||
{
|
||||
"group": "Task types",
|
||||
"pages": ["v3/tasks-regular", "v3/tasks-scheduled"]
|
||||
"pages": [
|
||||
"v3/tasks-regular",
|
||||
"v3/tasks-scheduled"
|
||||
]
|
||||
},
|
||||
"v3/trigger-config"
|
||||
]
|
||||
@@ -127,7 +138,10 @@
|
||||
{
|
||||
"group": "Development",
|
||||
"version": "v3 (Developer Preview)",
|
||||
"pages": ["v3/cli-dev", "v3/run-tests"]
|
||||
"pages": [
|
||||
"v3/cli-dev",
|
||||
"v3/run-tests"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Deployment",
|
||||
@@ -138,7 +152,9 @@
|
||||
"v3/github-actions",
|
||||
{
|
||||
"group": "Deployment integrations",
|
||||
"pages": ["v3/vercel-integration"]
|
||||
"pages": [
|
||||
"v3/vercel-integration"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -172,6 +188,13 @@
|
||||
"version": "v3 (Developer Preview)",
|
||||
"pages": [
|
||||
"v3/management/overview",
|
||||
{
|
||||
"group": "Tasks API",
|
||||
"pages": [
|
||||
"v3/management/tasks/trigger",
|
||||
"v3/management/tasks/batch-trigger"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Runs API",
|
||||
"pages": [
|
||||
@@ -207,14 +230,20 @@
|
||||
},
|
||||
{
|
||||
"group": "Projects API",
|
||||
"pages": ["v3/management/projects/runs"]
|
||||
"pages": [
|
||||
"v3/management/projects/runs"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Open source",
|
||||
"version": "v3 (Developer Preview)",
|
||||
"pages": ["v3/github-repo", "v3/open-source-self-hosting", "v3/open-source-contributing"]
|
||||
"pages": [
|
||||
"v3/github-repo",
|
||||
"v3/open-source-self-hosting",
|
||||
"v3/open-source-contributing"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Troubleshooting",
|
||||
@@ -230,7 +259,11 @@
|
||||
{
|
||||
"group": "Help",
|
||||
"version": "v3 (Developer Preview)",
|
||||
"pages": ["v3/community", "v3/help-slack", "v3/help-email"]
|
||||
"pages": [
|
||||
"v3/community",
|
||||
"v3/help-slack",
|
||||
"v3/help-email"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Getting Started",
|
||||
@@ -422,7 +455,10 @@
|
||||
"pages": [
|
||||
{
|
||||
"group": "Airtable",
|
||||
"pages": ["integrations/apis/airtable", "integrations/apis/airtable-tasks"]
|
||||
"pages": [
|
||||
"integrations/apis/airtable",
|
||||
"integrations/apis/airtable-tasks"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "GitHub",
|
||||
@@ -448,16 +484,25 @@
|
||||
},
|
||||
{
|
||||
"group": "Plain",
|
||||
"pages": ["integrations/apis/plain", "integrations/apis/plain-tasks"]
|
||||
"pages": [
|
||||
"integrations/apis/plain",
|
||||
"integrations/apis/plain-tasks"
|
||||
]
|
||||
},
|
||||
"integrations/apis/replicate",
|
||||
{
|
||||
"group": "SendGrid",
|
||||
"pages": ["integrations/apis/sendgrid", "integrations/apis/sendgrid-tasks"]
|
||||
"pages": [
|
||||
"integrations/apis/sendgrid",
|
||||
"integrations/apis/sendgrid-tasks"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Resend",
|
||||
"pages": ["integrations/apis/resend", "integrations/apis/resend-tasks"]
|
||||
"pages": [
|
||||
"integrations/apis/resend",
|
||||
"integrations/apis/resend-tasks"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Shopify",
|
||||
@@ -469,7 +514,10 @@
|
||||
},
|
||||
{
|
||||
"group": "Slack",
|
||||
"pages": ["integrations/apis/slack", "integrations/apis/slack-tasks"]
|
||||
"pages": [
|
||||
"integrations/apis/slack",
|
||||
"integrations/apis/slack-tasks"
|
||||
]
|
||||
},
|
||||
"integrations/apis/stripe",
|
||||
{
|
||||
@@ -495,7 +543,9 @@
|
||||
"sdk/triggerclient/constructor",
|
||||
{
|
||||
"group": "Instance properties",
|
||||
"pages": ["sdk/triggerclient/store"]
|
||||
"pages": [
|
||||
"sdk/triggerclient/store"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Instance methods",
|
||||
@@ -558,7 +608,10 @@
|
||||
"sdk/dynamictrigger/constructor",
|
||||
{
|
||||
"group": "Instance methods",
|
||||
"pages": ["sdk/dynamictrigger/register", "sdk/dynamictrigger/unregister"]
|
||||
"pages": [
|
||||
"sdk/dynamictrigger/register",
|
||||
"sdk/dynamictrigger/unregister"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -569,7 +622,10 @@
|
||||
"sdk/dynamicschedule/constructor",
|
||||
{
|
||||
"group": "Instance methods",
|
||||
"pages": ["sdk/dynamicschedule/register", "sdk/dynamicschedule/unregister"]
|
||||
"pages": [
|
||||
"sdk/dynamicschedule/register",
|
||||
"sdk/dynamicschedule/unregister"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -582,7 +638,9 @@
|
||||
{
|
||||
"group": "HTTP Reference",
|
||||
"version": "v2",
|
||||
"pages": ["sdk/api-reference/events/create-an-event"]
|
||||
"pages": [
|
||||
"sdk/api-reference/events/create-an-event"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "React SDK",
|
||||
@@ -598,7 +656,9 @@
|
||||
{
|
||||
"group": "Overview",
|
||||
"version": "v2",
|
||||
"pages": ["examples/introduction"]
|
||||
"pages": [
|
||||
"examples/introduction"
|
||||
]
|
||||
}
|
||||
],
|
||||
"footerSocials": {
|
||||
@@ -606,4 +666,4 @@
|
||||
"github": "https://github.com/triggerdotdev",
|
||||
"linkedin": "https://www.linkedin.com/company/triggerdotdev"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1039,9 +1039,229 @@ paths:
|
||||
});
|
||||
}
|
||||
})
|
||||
"/api/v1/tasks/{taskIdentifier}/trigger":
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/taskIdentifier"
|
||||
post:
|
||||
operationId: trigger_task_v1
|
||||
summary: Trigger a task
|
||||
description: Trigger a task by its identifier.
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
"$ref": "#/components/schemas/TriggerTaskRequestBody"
|
||||
responses:
|
||||
"200":
|
||||
description: Task triggered successfully
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
"$ref": "#/components/schemas/TriggerTaskResponse"
|
||||
"400":
|
||||
description: Invalid request parameters or body
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
"$ref": "#/components/schemas/ErrorResponse"
|
||||
"401":
|
||||
description: Unauthorized request
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
"$ref": "#/components/schemas/ErrorResponse"
|
||||
"404":
|
||||
description: Resource not found
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
"$ref": "#/components/schemas/ErrorResponse"
|
||||
tags:
|
||||
- tasks
|
||||
security:
|
||||
- secretKey: []
|
||||
x-codeSamples:
|
||||
- lang: typescript
|
||||
source: |-
|
||||
import { task } from "@trigger.dev/sdk/v3";
|
||||
|
||||
export const myTask = await task({
|
||||
id: "my-task",
|
||||
run: async (payload: { message: string }) => {
|
||||
console.log("Hello, world!");
|
||||
}
|
||||
});
|
||||
|
||||
// Somewhere else in your code
|
||||
await myTask.trigger({ message: "Hello, world!" }, {
|
||||
idempotencyKey: "unique-key-123",
|
||||
concurrencyKey: "user123-task",
|
||||
queue: {
|
||||
name: "my-task-queue",
|
||||
concurrencyLimit: 5
|
||||
},
|
||||
});
|
||||
- lang: curl
|
||||
source: |-
|
||||
curl -X POST "https://api.trigger.dev/api/v1/tasks/my-task/trigger" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer tr_dev_1234" \
|
||||
-d '{
|
||||
"payload": {
|
||||
"message": "Hello, world!"
|
||||
},
|
||||
"context": {
|
||||
"user": "user123"
|
||||
},
|
||||
"options": {
|
||||
"queue": {
|
||||
"name": "default",
|
||||
"concurrencyLimit": 5
|
||||
},
|
||||
"concurrencyKey": "user123-task",
|
||||
"idempotencyKey": "unique-key-123"
|
||||
}
|
||||
}'
|
||||
- lang: python
|
||||
source: |-
|
||||
import requests
|
||||
|
||||
url = "https://api.trigger.dev/api/v1/tasks/my-task/trigger"
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": "Bearer tr_dev_1234"
|
||||
}
|
||||
data = {
|
||||
"payload": {
|
||||
"message": "Hello, world!"
|
||||
},
|
||||
"context": {
|
||||
"user": "user123"
|
||||
},
|
||||
"options": {
|
||||
"queue": {
|
||||
"name": "default",
|
||||
"concurrencyLimit": 5
|
||||
},
|
||||
"concurrencyKey": "user123-task",
|
||||
"idempotencyKey": "unique-key-123"
|
||||
}
|
||||
}
|
||||
|
||||
response = requests.post(url, headers=headers, json=data)
|
||||
print(response.json())
|
||||
|
||||
"/api/v1/tasks/{taskIdentifier}/batch":
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/taskIdentifier"
|
||||
post:
|
||||
operationId: batch_trigger_task_v1
|
||||
summary: Batch trigger a task
|
||||
description: Batch trigger a task with up to 100 payloads.
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
"$ref": "#/components/schemas/BatchTriggerRequestBody"
|
||||
responses:
|
||||
"200":
|
||||
description: Task batch triggered successfully
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
"$ref": "#/components/schemas/BatchTriggerTaskResponse"
|
||||
"400":
|
||||
description: Invalid request parameters or body
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
"$ref": "#/components/schemas/ErrorResponse"
|
||||
"401":
|
||||
description: Unauthorized request
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
"$ref": "#/components/schemas/ErrorResponse"
|
||||
"404":
|
||||
description: Resource not found
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
"$ref": "#/components/schemas/ErrorResponse"
|
||||
tags:
|
||||
- tasks
|
||||
security:
|
||||
- secretKey: []
|
||||
x-codeSamples:
|
||||
- lang: typescript
|
||||
source: |-
|
||||
import { task } from "@trigger.dev/sdk/v3";
|
||||
|
||||
export const myTask = await task({
|
||||
id: "my-task",
|
||||
run: async (payload: { message: string }) => {
|
||||
console.log("Hello, world!");
|
||||
}
|
||||
});
|
||||
|
||||
// Somewhere else in your code
|
||||
await myTask.batchTrigger({
|
||||
items: [
|
||||
{
|
||||
payload: { message: "Hello, world!" },
|
||||
options: {
|
||||
idempotencyKey: "unique-key-123",
|
||||
concurrencyKey: "user-123-task",
|
||||
queue: {
|
||||
name: "my-task-queue",
|
||||
concurrencyLimit: 5
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
- lang: curl
|
||||
source: |-
|
||||
curl -X POST "https://api.trigger.dev/api/v1/tasks/my-task/batch" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer tr_dev_1234" \
|
||||
-d '{
|
||||
"items": [
|
||||
{
|
||||
"payload": {
|
||||
"message": "Hello, world!"
|
||||
},
|
||||
"context": {
|
||||
"user": "user123"
|
||||
},
|
||||
"options": {
|
||||
"queue": {
|
||||
"name": "default",
|
||||
"concurrencyLimit": 5
|
||||
},
|
||||
"concurrencyKey": "user123-task",
|
||||
"idempotencyKey": "unique-key-123"
|
||||
}
|
||||
}
|
||||
]
|
||||
}'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
components:
|
||||
parameters:
|
||||
taskIdentifier:
|
||||
in: path
|
||||
name: taskIdentifier
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: The id of a task
|
||||
example: my-task
|
||||
runsFilterWithEnv:
|
||||
in: query
|
||||
name: filter
|
||||
@@ -1159,6 +1379,65 @@ components:
|
||||
configure({ secretKey: "tr_pat_1234" });
|
||||
```
|
||||
schemas:
|
||||
TriggerTaskResponse:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
description: The ID of the run that was triggered.
|
||||
example: run_1234
|
||||
QueueOptions:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
description: You can define a shared queue and then pass the name in to your task.
|
||||
concurrencyLimit:
|
||||
type: integer
|
||||
minimum: 0
|
||||
maximum: 1000
|
||||
description: An optional property that specifies the maximum number of concurrent run executions. If this property is omitted, the task can potentially use up the full concurrency of an environment.
|
||||
BatchTriggerRequestBody:
|
||||
type: object
|
||||
properties:
|
||||
items:
|
||||
type: array
|
||||
items:
|
||||
"$ref": "#/components/schemas/TriggerTaskRequestBody"
|
||||
description: An array of payloads to trigger the task with
|
||||
required: ["items"]
|
||||
BatchTriggerTaskResponse:
|
||||
type: object
|
||||
required: ["batchId", "runs"]
|
||||
properties:
|
||||
batchId:
|
||||
type: string
|
||||
description: The ID of the batch that was triggered
|
||||
example: batch_1234
|
||||
runs:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
description: An array of run IDs that were triggered
|
||||
TriggerTaskRequestBody:
|
||||
type: object
|
||||
properties:
|
||||
payload:
|
||||
description: The payload can include any valid JSON
|
||||
context:
|
||||
description: The context can include any valid JSON
|
||||
options:
|
||||
type: object
|
||||
properties:
|
||||
queue:
|
||||
$ref: '#/components/schemas/QueueOptions'
|
||||
concurrencyKey:
|
||||
type: string
|
||||
description: Scope the concurrency limit to a specific key.
|
||||
idempotencyKey:
|
||||
type: string
|
||||
description: An optional property that specifies the idempotency key used to prevent creating duplicate runs. If you provide an existing idempotency key, we will return the existing run ID.
|
||||
|
||||
EnvFilter:
|
||||
type: object
|
||||
properties:
|
||||
@@ -1350,6 +1629,7 @@ components:
|
||||
properties:
|
||||
error:
|
||||
type: string
|
||||
example: Something went wrong
|
||||
required: ["error"]
|
||||
ErrorWithDetailsResponse:
|
||||
type: object
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
---
|
||||
title: "Batch trigger"
|
||||
openapi: "v3-openapi POST /api/v1/tasks/{taskIdentifier}/batch"
|
||||
---
|
||||
@@ -0,0 +1,4 @@
|
||||
---
|
||||
title: "Trigger"
|
||||
openapi: "v3-openapi POST /api/v1/tasks/{taskIdentifier}/trigger"
|
||||
---
|
||||
Reference in New Issue
Block a user