---
title: "eventTrigger()"
description: "`eventTrigger()` is set as a [Job's trigger](/sdk/job) to subscribe to an event a Job from [a sent event](/sdk/triggerclient/instancemethods/sendevent)."
---
You can have multiple Jobs that subscribe to the same event, they will all trigger when the event gets delivered.
## Parameters
The name of the event you are subscribing to. Must be an exact match (case
sensitive).
A [Zod](/documentation/guides/zod) schema that defines the shape of the
event payload. The default is `z.any()` which is `any`.
You can use this to filter events based on the source.
Used to filter which events trigger the Job.
An example:
```typescript
{
name: ["John", "Jane"],
age: [18, 21]
}
```
This filter would match against an event with the following data:
```json
{
"name": "Jane",
"age": 18,
"location": "San Francisco"
}
```
Used to provide example payloads that are accepted by the job.
This will be available in the dashboard and can be used to trigger test runs.
The example's ID.
The name that's displayed in the dashboard.
The payload that's accepted by the job.
The icon to use for this example in the dashboard.
Used to configure batching options. An empty object will enable batching with server defaults.
Batching will cause the `payload` parameter of the run function to become an array of payloads instead.
How many event payloads you will at most receive per batch. May be reduced by server limits..
How many seconds to wait before sending out incomplete batches. May be cut short by server limits.
## Batching
Batching will cause the `payload` parameter of the run function to become an array of payloads instead.
It can be enabled via the `batch` property or alternatively via the `batch()` method on existing triggers:
```typescript
eventTrigger({
name: "batch.this",
batch: {
// receive no more than 5 payloads per batch
maxPayloads: 5,
// send out incomplete batches after 10 seconds
maxInterval: 10,
}
});
// alternatively
eventTrigger({ name: "batch.this" }).batch({
maxPayloads: 5,
maxInterval: 10,
});
// shortcut to enable with sensible defaults
eventTrigger({ name: "batch.this" }).batch();
```
```typescript eventTrigger()
//this Job subscribes to an event called new.user
client.defineJob({
id: "job-2",
name: "Second job",
version: "0.0.1",
//subscribes to the "new.user" event
trigger: eventTrigger({
//sent events with this name will trigger this Job
name: "new.user",
//the expected payload shape
schema: z.object({
userId: z.string(),
tier: z.union([z.literal("free"), z.literal("pro")]),
}),
//only events with the tier: "pro" will trigger this Job
filter: {
tier: ["pro"],
},
//(optional) example event object
examples: [
{
id: "issue.opened",
name: "Issue opened",
payload: {
userId: "1234",
tier: "free",
},
//optional
icon: "github",
},
],
}),
run: async (payload, io, ctx) => {
await io.logger.log("New pro user created", { userId: payload.userId });
//do stuff
},
});
```