-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathopenapi.yml
More file actions
375 lines (372 loc) · 12.3 KB
/
openapi.yml
File metadata and controls
375 lines (372 loc) · 12.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
openapi: 3.0.0
info:
title: Trigger.dev API
description: API for triggering events in Trigger.dev
version: 1.0.0
servers:
- url: https://api.trigger.dev
description: Trigger.dev API server
security:
- BearerAuth: []
paths:
/api/v1/events:
post:
operationId: sendEvent
externalDocs:
description: Find more info here
url: "https://trigger.dev/docs/api/events/send-event"
tags:
- Events
summary: Create an event
description: Send an event to Trigger.dev to trigger job runs through eventTrigger()
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/EventRequest"
responses:
"200":
description: Event successfully sent
content:
application/json:
schema:
$ref: "#/components/schemas/EventResponse"
"400":
description: Invalid request
"401":
description: Unauthorized - API key is missing or invalid
"422":
description: Invalid request body
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/api/v3/batches:
post:
operationId: createBatch
externalDocs:
description: Find more info here
url: "https://trigger.dev/docs/triggering"
tags:
- Batches
summary: Create a batch (Phase 1)
description: |
Phase 1 of 2-phase batch API. Creates a batch record and optionally blocks the parent run for batchTriggerAndWait.
After creating a batch, stream items via POST /api/v3/batches/{batchId}/items.
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/CreateBatchRequest"
responses:
"202":
description: Batch successfully created
content:
application/json:
schema:
$ref: "#/components/schemas/CreateBatchResponse"
headers:
x-trigger-jwt-claims:
description: JWT claims for the batch
schema:
type: string
x-trigger-jwt:
description: JWT token for browser clients
schema:
type: string
"400":
description: Invalid request (e.g., runCount <= 0 or exceeds maximum)
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"401":
description: Unauthorized - API key is missing or invalid
"422":
description: Validation error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"429":
description: Rate limit exceeded
headers:
X-RateLimit-Limit:
description: Maximum number of requests allowed
schema:
type: integer
X-RateLimit-Remaining:
description: Number of requests remaining
schema:
type: integer
X-RateLimit-Reset:
description: Unix timestamp when the rate limit resets
schema:
type: integer
Retry-After:
description: Seconds to wait before retrying
schema:
type: integer
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"500":
description: Internal server error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/api/v3/batches/{batchId}/items:
post:
operationId: streamBatchItems
externalDocs:
description: Find more info here
url: "https://trigger.dev/docs/triggering"
tags:
- Batches
summary: Stream batch items (Phase 2)
description: |
Phase 2 of 2-phase batch API. Accepts an NDJSON stream of batch items and enqueues them.
Each line in the body should be a valid BatchItemNDJSON object.
The stream is processed with backpressure - items are enqueued as they arrive.
The batch is sealed when the stream completes successfully.
parameters:
- name: batchId
in: path
required: true
description: The batch ID returned from POST /api/v3/batches
schema:
type: string
requestBody:
required: true
content:
application/x-ndjson:
schema:
type: string
description: |
NDJSON (newline-delimited JSON) stream where each line is a BatchItemNDJSON object.
Example:
{"index":0,"task":"my-task","payload":{"key":"value1"}}
{"index":1,"task":"my-task","payload":{"key":"value2"}}
application/ndjson:
schema:
type: string
description: |
NDJSON (newline-delimited JSON) stream where each line is a BatchItemNDJSON object.
responses:
"200":
description: Items successfully processed
content:
application/json:
schema:
$ref: "#/components/schemas/StreamBatchItemsResponse"
"400":
description: Invalid request (e.g., invalid JSON, item exceeds maximum size)
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"401":
description: Unauthorized - API key is missing or invalid
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"415":
description: Unsupported Media Type - Content-Type must be application/x-ndjson or application/ndjson
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"422":
description: Validation error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"500":
description: Internal server error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
schemas:
Error:
type: object
properties:
message:
type: string
EventRequest:
type: object
properties:
event:
type: object
required:
- name
properties:
name:
type: string
description: The name of the event
payload:
type: object
additionalProperties: true
description: The payload of the event
context:
type: object
additionalProperties: true
description: An optional context object
id:
type: string
description: Unique identifier for the event. Auto-generated if not provided. If you provide an ID that already exists, the event will not be redelivered.
timestamp:
type: string
format: date-time
description: Event timestamp. Defaults to current timestamp if not provided.
source:
type: string
description: Event source, default is 'trigger.dev'.
options:
type: object
properties:
deliverAt:
type: string
format: date-time
description: Optional Date to deliver the event.
deliverAfter:
type: integer
description: Optional delay in seconds before delivering the event.
accountId:
type: string
description: Optional account ID to associate with the event.
EventResponse:
type: object
properties:
id:
type: string
description: The ID of the event that was sent.
name:
type: string
description: The name of the event that was sent.
payload:
$ref: "#/components/schemas/DeserializedJson"
context:
$ref: "#/components/schemas/DeserializedJson"
nullable: true
description: The context of the event that was sent. Null if no context was set.
timestamp:
type: string
format: date-time
description: The timestamp of the event that was sent.
deliverAt:
type: string
format: date-time
nullable: true
description: The timestamp when the event will be delivered. Null if not applicable.
deliveredAt:
type: string
format: date-time
nullable: true
description: The timestamp when the event was delivered. Null if not applicable.
cancelledAt:
type: string
format: date-time
nullable: true
description: The timestamp when the event was cancelled. Null if the event wasn't cancelled.
DeserializedJson:
type: object
additionalProperties: true
description: A JSON object that represents the deserialized payload or context.
CreateBatchRequest:
type: object
required:
- runCount
properties:
runCount:
type: integer
minimum: 1
description: Expected number of items in the batch. Must be a positive integer.
parentRunId:
type: string
description: Parent run ID (friendly ID) for batchTriggerAndWait.
resumeParentOnCompletion:
type: boolean
description: Whether to resume parent on completion. Set to true for batchTriggerAndWait.
idempotencyKey:
type: string
description: Idempotency key for the batch. If provided and a batch with this key already exists, the existing batch will be returned.
CreateBatchResponse:
type: object
required:
- id
- runCount
- isCached
properties:
id:
type: string
description: The batch ID (friendly ID). Use this to stream items via POST /api/v3/batches/{batchId}/items.
runCount:
type: integer
description: The expected run count.
isCached:
type: boolean
description: Whether this response came from a cached/idempotent batch.
idempotencyKey:
type: string
description: The idempotency key if provided.
BatchItemNDJSON:
type: object
required:
- index
- task
properties:
index:
type: integer
minimum: 0
description: Zero-based index of this item. Used for idempotency and ordering.
task:
type: string
description: The task identifier to trigger.
payload:
description: The payload for this task run. Can be any JSON value.
options:
type: object
additionalProperties: true
description: Options for this specific item.
StreamBatchItemsResponse:
type: object
required:
- id
- itemsAccepted
- itemsDeduplicated
- sealed
properties:
id:
type: string
description: The batch ID.
itemsAccepted:
type: integer
description: Number of items successfully accepted.
itemsDeduplicated:
type: integer
description: Number of items that were deduplicated (already enqueued).
sealed:
type: boolean
description: |
Whether the batch was sealed and is ready for processing.
If false, the batch needs more items before processing can start.
Clients should check this field and retry with missing items if needed.
enqueuedCount:
type: integer
description: Total items currently enqueued. Only present when sealed=false to help with retries.
expectedCount:
type: integer
description: Expected total item count. Only present when sealed=false to help with retries.
securitySchemes:
BearerAuth:
type: http
scheme: bearer
bearerFormat: JWT