Skip to content

Commit 94e2d96

Browse files
committed
update docs
1 parent 7df7c9d commit 94e2d96

2 files changed

Lines changed: 35 additions & 56 deletions

File tree

docs/apikeys.mdx

Lines changed: 32 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
11
---
22
title: "API keys"
3-
description: "Authenticate backend requests with environment-specific API keys and restrict additional keys to the access each integration needs."
3+
description: "Authenticate backend requests with environment-specific API keys."
44
---
55

6-
**API keys authenticate backend requests to a specific Trigger.dev project and environment.** Each environment has a root key, and you can create additional named keys for separate services and integrations.
6+
**API keys authenticate backend requests to a specific Trigger.dev project and environment.** Each environment can have multiple keys, with optional scopes and restrictions attached.
77

88
<Warning>
99
API keys grant access to your Trigger.dev environment. Store them in a secret manager or backend
1010
environment variable, never commit them to source control, and never expose them in frontend code.
1111
</Warning>
1212

13-
## Root and additional keys
14-
15-
Each environment has two types of API key:
16-
17-
| Key type | Access | Secret visibility | Lifecycle |
18-
| --- | --- | --- | --- |
19-
| **Root key** | Full access to the environment | Available to copy from the dashboard | Regenerate it with a 24-hour grace period for the previous value |
20-
| **Additional key** | Full or restricted access | Shown once when created, then stored as a hash and displayed only by its suffix | Set an optional expiration date or revoke it immediately |
21-
22-
Root keys use prefixes such as `tr_dev_`, `tr_stg_`, `tr_prod_`, and `tr_preview_`. Additional keys include `_sk_` after the environment, for example `tr_prod_sk_…`.
23-
24-
Use additional keys to give each backend service, deployment pipeline, or external integration its own credential. This lets you revoke one integration without rotating the environment's root key.
25-
2613
## Find your API keys
2714

2815
Open your project in the dashboard, select an environment, and open the **API keys** page.
@@ -38,12 +25,6 @@ API keys belong to one environment. A Development key cannot access Production,
3825

3926
Set `TRIGGER_SECRET_KEY` in your backend environment. The SDK reads it automatically for operations such as triggering tasks and retrieving runs.
4027

41-
```bash .env
42-
TRIGGER_SECRET_KEY="tr_prod_…"
43-
```
44-
45-
Additional keys use the same environment variable:
46-
4728
```bash .env
4829
TRIGGER_SECRET_KEY="tr_prod_sk_…"
4930
```
@@ -52,12 +33,13 @@ To configure the SDK in code, pass the key to `configure`:
5233

5334
```ts Your backend code
5435
import { configure, tasks } from "@trigger.dev/sdk";
36+
import type { sendEmail } from "./trigger/send-email";
5537

5638
configure({
5739
secretKey: process.env.TRIGGER_SECRET_KEY,
5840
});
5941

60-
await tasks.trigger("send-email", {
42+
await tasks.trigger<typeof sendEmail>("send-email", {
6143
to: "user@example.com",
6244
});
6345
```
@@ -71,7 +53,7 @@ TRIGGER_API_URL="https://trigger.example.com"
7153

7254
The default API URL is `https://api.trigger.dev`.
7355

74-
## Create an additional key
56+
## Create a key
7557

7658
Create a separate key for each service or integration that accesses Trigger.dev.
7759

@@ -97,79 +79,74 @@ Create a separate key for each service or integration that accesses Trigger.dev.
9779
</Step>
9880
</Steps>
9981

100-
The dashboard displays the key's status, access, creator, creation time, and last-used time without storing or revealing its plaintext value.
101-
10282
## Access presets
10383

104-
Access presets define what an additional key can do. The dashboard shows which presets are available for your plan.
84+
Access presets define what a key can do. Some presets require a paid plan. The dashboard shows which presets your organization can use — see [pricing](https://trigger.dev/pricing).
10585

10686
| Preset | Access |
10787
| --- | --- |
10888
| **Trigger only** | Trigger runs and batches for all or selected tasks. Trigger responses include scoped public access tokens for the runs and batches they create |
10989
| **Task operator** | Trigger all or selected tasks and inspect or operate on their runs |
110-
| **Environment observer** | Read runs, tasks, batches, logs, traces, and queues |
111-
| **Environment operator** | Observe and operate on runs and queues, and trigger tasks |
90+
| **Observer** | Read runs, tasks, batches, logs, traces, and queues |
91+
| **Operator** | Observe and operate on runs and queues, and trigger tasks |
11292
| **Deploy only** | Deploy new versions, read deployment status, and read environment variables |
113-
| **Environment variables only** | Read and write environment variables in this environment |
114-
| **No restrictions** | Full access to the environment, matching the root key |
115-
116-
**Trigger only** and **Task operator** can be restricted to selected tasks. Task restrictions use task identifiers, such as `send-email`, and continue to apply across deployments. A request involving multiple tasks succeeds only when the key can access every task in the request.
93+
| **Variables only** | Read and write environment variables in this environment |
94+
| **No restrictions** | Full access to the environment |
11795

118-
Access is fixed when you create a key. Changes to a preset do not alter existing keys. To change a key's access, revoke it and create a replacement.
96+
**Trigger only** and **Task operator** can be restricted to selected tasks. Task restrictions use task identifiers, such as `send-email`. A request involving multiple tasks — such as a batch trigger — succeeds only when the key can access every task in the request, so a task-restricted key can batch-trigger only its selected tasks.
11997

120-
<Warning>
121-
Streamed batch ingestion is not atomic. When using a task-restricted key, earlier items may be
122-
accepted before a later item fails validation or authorization.
123-
</Warning>
124-
125-
## Expire and revoke additional keys
98+
## Expire and revoke keys
12699

127100
Set an expiration date when creating a key if the integration only needs temporary access. An expired key stops authenticating automatically.
128101

129102
Revoking a key takes effect immediately and cannot be reversed. Requests using the key fail, and the key can no longer create public access tokens. Create a replacement before revoking a key when you need to rotate it without interrupting the integration.
130103

131-
Removing a team member does not revoke additional keys they created. Review and revoke their keys separately when their access changes.
132-
133-
## Regenerate the root key
134-
135-
Regenerating the root key creates a new value immediately. The previous root key remains valid for 24 hours so you can update services without downtime, then stops authenticating.
136-
137-
Public access tokens signed with the previous root key remain valid until the earlier of their own expiration and the end of the 24-hour grace period. Additional-key revocation does not have a grace period.
104+
Removing a team member does not revoke keys they created. Review and revoke their keys separately when their access changes.
138105

139106
## Create public access tokens
140107

141-
Additional keys can create scoped [Public Access Tokens](/realtime/auth) without receiving the environment's root key. Use `@trigger.dev/sdk` version 4.5.8 or later with additional keys.
108+
Keys can create scoped [Public Access Tokens](/realtime/auth) without receiving the environment's root key. Use `@trigger.dev/sdk` version 4.5.8 or later with keys.
142109

143-
When an additional key calls `auth.createPublicToken()`:
110+
When a key calls `auth.createPublicToken()`:
144111

145112
- The token must request at least one scope.
146-
- Its scopes cannot exceed the additional key's access.
113+
- Its scopes cannot exceed the key's access.
147114
- It expires after 15 minutes by default.
148115
- Its expiration cannot exceed 30 days.
149116
- A numeric `expirationTime` is a Unix timestamp in seconds.
150117

151-
Revoking or expiring an additional key does not revoke tokens it already created. Those tokens remain valid until their own expiration, unless the environment's root key is regenerated first.
118+
Revoking or expiring a key does not revoke tokens it already created. Those tokens remain valid until their own expiration, unless the environment's root key is regenerated first.
152119

153120
## Target Preview and Development branches
154121

155-
Preview and named Development branches use their parent environment's key set. Select the branch by setting `TRIGGER_PREVIEW_BRANCH` alongside the environment key:
122+
Preview and named Development branches use their parent environment's keys. Select the branch by setting `TRIGGER_PREVIEW_BRANCH` alongside the environment key:
156123

157124
```bash .env
158-
TRIGGER_SECRET_KEY="tr_preview_"
125+
TRIGGER_SECRET_KEY="tr_preview_sk_"
159126
TRIGGER_PREVIEW_BRANCH="feature/new-checkout"
160127
```
161128

162129
The SDK sends the branch automatically. When calling the API directly, send the same value in the `x-trigger-branch` header.
163130

131+
## Root keys
132+
133+
<Warning>
134+
Root keys are legacy, and are likely to be deprecated in the future. We recommend against using them.
135+
</Warning>
136+
137+
Each environment has a single legacy root key. It can be regenerated, which creates a new value immediately. The previous root key remains valid for 24 hours so you can update services without downtime, then stops authenticating.
138+
139+
Public access tokens signed with the previous root key remain valid until the earlier of their own expiration and the end of the 24-hour grace period.
140+
164141
## Self-hosting
165142

166-
Self-hosted installations support multiple additional keys with **No restrictions**. The restricted access presets are available in Trigger.dev Cloud.
143+
Self-hosted installations support multiple keys with **No restrictions**. The restricted access presets are available in Trigger.dev Cloud.
167144

168-
Keep your instance and SDK current before creating additional keys. Calling a public-token API with an additional key on a server that does not support server-minted tokens returns an upgrade error; use the root key until the server is upgraded.
145+
Keep your instance and SDK current before creating keys. Calling a public-token API with a key on a server that does not support server-minted tokens returns an upgrade error; use the root key until the server is upgraded.
169146

170147
## Security recommendations
171148

172-
- Create one additional key per service or integration instead of sharing the root key.
149+
- Create one key per service or integration instead of sharing keys.
173150
- Choose the narrowest access preset and task selection that supports the integration.
174151
- Store keys in a secret manager and inject them as backend environment variables.
175152
- Set expiration dates for temporary integrations and deployment credentials.

docs/realtime/auth.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,11 @@ const publicToken = await auth.createPublicToken({
128128
```
129129

130130
- If `expirationTime` is a string, it will be treated as a time span
131-
- If `expirationTime` is a number, it will be treated as a Unix timestamp
131+
- If `expirationTime` is a number, it will be treated as a Unix timestamp in **seconds**
132132
- If `expirationTime` is a `Date`, it will be treated as a date
133133

134+
The expiration cannot be more than 30 days from now.
135+
134136
The format used for a time span is the same as the [jose package](https://github.com/panva/jose), which is a number followed by a unit. Valid units are: "sec", "secs", "second", "seconds", "s", "minute", "minutes", "min", "mins", "m", "hour", "hours", "hr", "hrs", "h", "day", "days", "d", "week", "weeks", "w", "year", "years", "yr", "yrs", and "y". It is not possible to specify months. 365.25 days is used as an alias for a year. If the string is suffixed with "ago", or prefixed with a "-", the resulting time span gets subtracted from the current unix timestamp. A "from now" suffix can also be used for readability when adding to the current unix timestamp.
135137

136138
### Auto-generated tokens

0 commit comments

Comments
 (0)