Using the Trigger.dev v3 management API
@trigger.dev/sdk
package used in defining and triggering tasks. If you have already installed the package in your project, you can skip this step.
v3
functionality is provided through the @trigger.dev/sdk/v3
module. You can import the entire module or individual resources as needed.
secretKey
), or using a personal access token (personalAccessToken
). Both methods should only be used in a backend server, as they provide full access to the project.
runs.list
function can be called using either a secretKey
or a personalAccessToken
, but the projectRef
argument is required when using a personalAccessToken
:
View endpoint support
Endpoint | Secret key | Personal Access Token |
---|---|---|
task.trigger | ✅ | |
task.batchTrigger | ✅ | |
runs.list | ✅ | ✅ |
runs.retrieve | ✅ | |
runs.cancel | ✅ | |
runs.replay | ✅ | |
envvars.list | ✅ | ✅ |
envvars.retrieve | ✅ | ✅ |
envvars.upload | ✅ | ✅ |
envvars.create | ✅ | ✅ |
envvars.update | ✅ | ✅ |
envvars.del | ✅ | ✅ |
schedules.list | ✅ | |
schedules.create | ✅ | |
schedules.retrieve | ✅ | |
schedules.update | ✅ | |
schedules.activate | ✅ | |
schedules.deactivate | ✅ | |
schedules.del | ✅ |
tr_pat_
prefix. Because a PAT does not scope access to a specific environment, you must provide the projectRef
argument when using a PAT (and sometimes the environment as well).
For example, when uploading environment variables using a PAT, you must provide the projectRef
and environment
arguments:
ApiError
that you can catch and handle:
requestOptions
option to the configure
function:
requestOptions
parameter as the last argument, which can be used to customize the request options. You can use this to disable retries for a specific request:
task.trigger
, task.batchTrigger
), and uses retry settings optimized for task execution.for await … of
syntax to iterate through items across all pages:
list
method to get the next/previous page of results:
Promise
subclass ApiPromise
that includes helpers for accessing the underlying HTTP response: