A TriggerClient is used to connect to a specific Project by using an API Key.

Example
export const client = new TriggerClient({
  id: "my-webapp",
  apiKey: process.env.TRIGGER_API_KEY!,
});

The TriggerClient should only ever be used in a server-side environment. It is not safe to use in a browser environment because it exposes your API Key.

Constructor

TriggerClient()

Creates a new TriggerClient object.

Instance properties

id

A string that uniquely identifies the client.

store

An object to access namespaced Key-Value Stores in and outside of your Jobs.

Instance methods

sendEvent()

Sending an event triggers any Jobs that are listening for that event (based on the name). Use eventTrigger() on a Job to listen for events.

You can call this function from anywhere in your code to send an event. The other way to send an event is by using io.sendEvent() from inside a run() function.

sendEvents()

Sending multiple events triggers any Jobs that are listening for those events (based on the name). Use eventTrigger() on a Job to listen for events.

You can call this function from anywhere in your code to send multiple events. The other way to send multiple events is by using io.sendEvents() from inside a run() function.

getEvent()

The getEvent() method gets the event details for a given eventId.

cancelEvent()

The cancelEvent() method cancels an event that is scheduled to be delivered in the future.

cancelRunsForEvent()

The cancelRunsForEvent() method cancels the job runs (yet to be executed) that are triggered by a given eventId.

cancelRunsForJob()

The cancelRunsForJob() method cancels all runs for the specified job (yet to be executed).

getRuns()

The getRuns() method gets runs for a Job.

getRun()

The getRun() method gets the details for a given Run.

defineJob()

The defineJob() method defines a new Job.

defineHttpEndpoint()

The defineHttpEndpoint() method defines a new HTTP Endpoint.

defineDynamicTrigger()

The defineDynamicTrigger() method defines a new Dynamic Trigger.

defineDynamicSchedule()

The defineDynamicSchedule() method defines a new Dynamic Schedule.

defineAuthResolver()

The defineAuthResolver() method defines a new Auth Resolver.

on()

Use the on() method to listen for run notifications across all Jobs.