run() function.
Use eventTrigger() on a Job to listen for events.
For single events, use client.sendEvent() instead.
Parameters
array
required
Hide event properties
Hide event properties
string
required
The
name property must exactly match any subscriptions you want to
trigger.any
The
payload property will be sent to any matching Jobs and will appear
as the payload param of the run() function. You can leave this
parameter out if you just want to trigger a Job without any input data.any
The optional
context property will be sent to any matching Jobs and will
be passed through as the context.event.context param of the run()
function. This is optional but can be useful if you want to pass through
some additional context to the Job.string
The
id property uniquely identify this particular event. If unset it
will be set automatically using ulid.Date
This is optional, it defaults to the current timestamp. Usually you would
only set this if you have a timestamp that you wish to pass through, e.g.
you receive a timestamp from a service and you want the same timestamp to
be used in your Job.
string
This is optional, it defaults to "trigger.dev". It can be useful to set
this as you can filter events using this in the
eventTrigger().object
Hide properties
Hide properties
Date
An optional Date when you want the event to Trigger Jobs. The event will
be sent to the platform immediately but won't be acted upon until the
specified time.
number
An optional number of seconds you want to wait for the event to Trigger
any relevant Jobs. The event will be sent to the platform immediately but
won't be acted upon until the specified time.
string
This optional param will be used by the Trigger.dev Connect feature, which
is coming soon.
Returns
array
Hide properties
Hide properties
string
required
The
id of the event that was sent.string
required
The
name of the event that was sent.any
required
The
payload of the event that was sentDate
required
The
timestamp of the event that was sentany
The
context of the event that was sent. Is undefined if no context was
set when sending the event.Date
The timestamp when the event will be delivered to any matching Jobs. Is
undefined if deliverAt or deliverAfter wasn't set when sending the
event.Date
The timestamp when the event was delivered. Is
undefined if deliverAt
or deliverAfter were set when sending the event.const event = client.sendEvents([
{
name: "new.user",
payload: {
userId: "u_12345",
},
},
{
name: "new.user",
payload: {
userId: "u_67890",
},
},
]);
const event = client.sendEvents([
{
id: "e_12345", // You can use this to deduplicate events
name: "new.user",
payload: {
userId: "u_12345",
},
},
{
id: "e_67890", // You can use this to deduplicate events
name: "new.user",
payload: {
userId: "u_67890",
},
},
]);
const event = client.sendEvents(
[
{
id: "e_12345", // You can use this to deduplicate events
name: "new.user",
payload: {
userId: "u_12345",
},
},
{
id: "e_67890", // You can use this to deduplicate events
name: "new.user",
payload: {
userId: "u_67890",
},
},
],
{
deliverAt: new Date("2023-12-01T00:00:00.000Z"),
}
);

