Skip to content

Commit f2b1b76

Browse files
authored
docs: add list deployments endpoint, fix defaultMachine, and clarify wait token browser completion (#3350)
Adds missing list deployments API page, fixes defaultMachine → machine in config docs, and clarifies browser CORS usage for wait token completion with corrected warning placement
1 parent f739a5c commit f2b1b76

File tree

6 files changed

+203
-2
lines changed

6 files changed

+203
-2
lines changed

docs/config/config-file.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ import { defineConfig } from "@trigger.dev/sdk";
297297
export default defineConfig({
298298
project: "<project ref>",
299299
// Your other config settings...
300-
defaultMachine: "large-1x",
300+
machine: "large-1x",
301301
});
302302
```
303303

docs/docs.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@
306306
{
307307
"group": "Deployments API",
308308
"pages": [
309+
"management/deployments/list",
309310
"management/deployments/retrieve",
310311
"management/deployments/get-latest",
311312
"management/deployments/promote"

docs/management/deployments/get-latest.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,10 @@
22
title: "Get latest deployment"
33
openapi: "v3-openapi GET /api/v1/deployments/latest"
44
---
5+
6+
<Warning>
7+
This endpoint only returns **unmanaged** deployments, which are used in self-hosted setups. It
8+
will return `404` for standard CLI deployments made against Trigger.dev Cloud.
9+
10+
If you're using the CLI to deploy, use the [list deployments](/management/deployments/list) endpoint instead.
11+
</Warning>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: "List deployments"
3+
description: "List all deployments for the authenticated environment, ordered by most recent first."
4+
openapi: "v3-openapi GET /api/v1/deployments"
5+
---

docs/v3-openapi.yaml

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,145 @@ paths:
784784
785785
await runs.cancel("run_1234");
786786
787+
"/api/v1/deployments":
788+
get:
789+
operationId: list_deployments_v1
790+
summary: List deployments
791+
description: List deployments for the authenticated environment, ordered by most recent first.
792+
parameters:
793+
- in: query
794+
name: "page[after]"
795+
schema:
796+
type: string
797+
description: The deployment ID to start the search from, to get the next page.
798+
- in: query
799+
name: "page[size]"
800+
schema:
801+
type: integer
802+
minimum: 5
803+
maximum: 100
804+
default: 20
805+
description: The number of deployments to return (default 20, min 5, max 100).
806+
- in: query
807+
name: status
808+
schema:
809+
type: string
810+
enum:
811+
[
812+
"PENDING",
813+
"BUILDING",
814+
"DEPLOYING",
815+
"DEPLOYED",
816+
"FAILED",
817+
"CANCELED",
818+
"TIMED_OUT",
819+
]
820+
description: Filter deployments by status.
821+
- in: query
822+
name: period
823+
schema:
824+
type: string
825+
description: Filter deployments created within this period (e.g. 1d, 7d, 3h).
826+
- in: query
827+
name: from
828+
schema:
829+
type: string
830+
description: Filter deployments created on or after this date (ISO 8601).
831+
- in: query
832+
name: to
833+
schema:
834+
type: string
835+
description: Filter deployments created on or before this date (ISO 8601). Only applied when `from` is also provided.
836+
responses:
837+
"200":
838+
description: Successful request
839+
content:
840+
application/json:
841+
schema:
842+
type: object
843+
properties:
844+
data:
845+
type: array
846+
items:
847+
type: object
848+
properties:
849+
id:
850+
type: string
851+
description: The deployment ID
852+
createdAt:
853+
type: string
854+
format: date-time
855+
description: When the deployment was created
856+
shortCode:
857+
type: string
858+
description: The short code for the deployment
859+
version:
860+
type: string
861+
description: The deployment version (e.g., "20250228.1")
862+
runtime:
863+
type: string
864+
nullable: true
865+
description: The runtime used (e.g., "node")
866+
runtimeVersion:
867+
type: string
868+
nullable: true
869+
description: The runtime version
870+
status:
871+
type: string
872+
enum:
873+
[
874+
"PENDING",
875+
"BUILDING",
876+
"DEPLOYING",
877+
"DEPLOYED",
878+
"FAILED",
879+
"CANCELED",
880+
"TIMED_OUT",
881+
]
882+
description: The current status of the deployment
883+
deployedAt:
884+
type: string
885+
format: date-time
886+
nullable: true
887+
description: When the deployment was promoted to DEPLOYED
888+
git:
889+
type: object
890+
nullable: true
891+
description: Git metadata associated with the deployment
892+
error:
893+
type: object
894+
nullable: true
895+
description: Error data if the deployment failed
896+
pagination:
897+
type: object
898+
properties:
899+
next:
900+
type: string
901+
description: Cursor for the next page. Pass as `page[after]` to get the next page. Omitted if there are no more results.
902+
"401":
903+
description: Unauthorized - Access token is missing or invalid
904+
tags:
905+
- deployments
906+
security:
907+
- secretKey: []
908+
x-codeSamples:
909+
- lang: typescript
910+
source: |-
911+
const response = await fetch(
912+
"https://api.trigger.dev/api/v1/deployments",
913+
{
914+
method: "GET",
915+
headers: {
916+
"Authorization": `Bearer ${secretKey}`,
917+
},
918+
}
919+
);
920+
const { data, pagination } = await response.json();
921+
- lang: curl
922+
source: |-
923+
curl -X GET "https://api.trigger.dev/api/v1/deployments" \
924+
-H "Authorization: Bearer tr_dev_1234"
925+
787926
"/api/v1/deployments/{deploymentId}":
788927
parameters:
789928
- in: path

docs/wait-for-token.mdx

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ Waitpoint tokens pause task runs until you complete the token. They're commonly
88
You can complete a token using the SDK or by making a POST request to the token's URL.
99

1010
<Note>
11-
If you're waiting for data from an [input stream](/tasks/streams#input-streams), use [`inputStream.wait()`](/tasks/streams#wait--suspend-until-data-arrives) instead — it uses waitpoint tokens internally but provides a simpler API with full type safety from your stream definition.
11+
If you're waiting for data from an [input stream](/tasks/streams#input-streams), use
12+
[`inputStream.wait()`](/tasks/streams#wait--suspend-until-data-arrives) instead — it uses
13+
waitpoint tokens internally but provides a simpler API with full type safety from your stream
14+
definition.
1215
</Note>
1316

1417
## Usage
@@ -54,6 +57,52 @@ await wait.completeToken<ApprovalToken>(tokenId, {
5457
});
5558
```
5659

60+
## Completing from the browser
61+
62+
The `publicAccessToken` returned by `wait.createToken()` is scoped to that specific waitpoint and intended for client-side completion. The completion endpoint has CORS enabled, so you can call it directly from client-side code without proxying through your backend.
63+
64+
<Steps>
65+
<Step title="Create the token in your backend">
66+
```typescript
67+
import { wait } from "@trigger.dev/sdk";
68+
69+
const token = await wait.createToken({ timeout: "10m" });
70+
// Pass token.id and token.publicAccessToken to your frontend
71+
```
72+
</Step>
73+
<Step title="Complete the token from the browser">
74+
```typescript
75+
// tokenId and publicAccessToken passed from your backend
76+
const tokenId = token.id;
77+
const publicAccessToken = token.publicAccessToken;
78+
79+
const response = await fetch(
80+
`https://api.trigger.dev/api/v1/waitpoints/tokens/${tokenId}/complete`,
81+
{
82+
method: "POST",
83+
headers: {
84+
"Authorization": `Bearer ${publicAccessToken}`,
85+
"Content-Type": "application/json",
86+
},
87+
body: JSON.stringify({ data: { status: "approved" } }),
88+
}
89+
);
90+
91+
if (!response.ok) {
92+
throw new Error(`Failed to complete token: ${response.statusText}`);
93+
}
94+
```
95+
</Step>
96+
</Steps>
97+
98+
## Completing via webhook callback
99+
100+
<Warning>
101+
The `token.url` webhook callback URL is designed for server-to-server use and does **not** have
102+
CORS headers. Don't call it from the browser, use the [Completing from the
103+
browser](#completing-from-the-browser) pattern instead.
104+
</Warning>
105+
57106
Or you can make an HTTP POST request to the `url` it returns. This is an HTTP callback:
58107

59108
```ts

0 commit comments

Comments
 (0)