Send events
Send events to Inngest. Functions with matching event triggers will be invoked.
import { inngest } from "./client";
await inngest.send({
name: "app/account.created",
data: {
accountId: "645e9f6794e10937e9bdc201",
billingPlan: "pro",
},
user: {
external_id: "645ea000129f1c40109ca7ad",
email: "taylor@example.com",
}
})
To send events from within of the context of a function, use step.sendEvent()
.
inngest.send(eventPayload | eventPayload[], options): Promise<{ ids: string[] }>
- Name
eventPayload
- Type
- object | object[]
- Required
- required
- Description
An event payload object or an array of event payload objects.
Properties- Name
name
- Type
- string
- Required
- required
- Description
The event name. We recommend using lowercase dot notation for names, prepending
prefixes/
with a slash for organization.
- Name
data
- Type
- object
- Required
- required
- Description
Any data to associate with the event. Will be serialized as JSON.
- Name
user
- Type
- object
- Required
- optional
- Description
Any relevant user identifying data or attributes associated with the event. This data is encrypted at rest.
Properties- Name
external_id
- Type
- string
- Required
- optional
- Description
An external identifier for the user. Most commonly, their user id in your system.
- Name
id
- Type
- string
- Required
- optional
- Description
A unique ID used to idempotently trigger function runs. If duplicate event IDs are seen, only the first event will trigger function runs. Read the idempotency guide here.
- Name
ts
- Type
- number
- Required
- optional
- Description
A timestamp integer representing the time (in milliseconds) at which the event occurred. Defaults to the time the Inngest receives the event.
If the
ts
time is in the future, function runs will be scheduled to start at the given time. This has the same effect as runningawait step.sleepUntil(event.ts)
at the start of the function.
- Name
v
- Type
- string
- Required
- optional
- Description
A version identifier for a particular event payload. e.g.
"2023-04-14.1"
- Name
options
- Type
- object
- Required
- optional
- Version v3.21.0+
- Description
- Properties
- Name
env
- Type
- string
- Required
- optional
- Description
The environment to send the events to.
// Send a single event
await inngest.send({
name: "app/post.created",
data: { postId: "01H08SEAXBJFJNGTTZ5TAWB0BD" }
});
// Send an array of events
await inngest.send([
{
name: "app/invoice.created",
data: { invoiceId: "645e9e024befa68763f5b500" }
},
{
name: "app/invoice.created",
data: { invoiceId: "645e9e08f29fb563c972b1f7" }
},
]);
// Send user data that will be encrypted at rest
await inngest.send({
name: "app/account.created",
data: { billingPlan: "pro" },
user: {
external_id: "6463da8211cdbbcb191dd7da",
email: "test@example.com"
}
});
// Specify the idempotency id, version, and timestamp
await inngest.send({
// Use an id specific to the event type & payload
id: "cart-checkout-completed-ed12c8bde",
name: "storefront/cart.checkout.completed",
data: { cartId: "ed12c8bde" },
user: { external_id: "6463da8211cdbbcb191dd7da" },
ts: 1684274328198,
v: "2024-05-15.1"
});
Return values
The function returns a promise that resolves to an object with an array of Event IDs that were sent. These events can be used to look up the event in the Inngest dashboard or via the REST API.
const { ids } = await inngest.send([
{
name: "app/invoice.created",
data: { invoiceId: "645e9e024befa68763f5b500" }
},
{
name: "app/invoice.created",
data: { invoiceId: "645e9e08f29fb563c972b1f7" }
},
]);
/**
* ids = [
* "01HQ8PTAESBZPBDS8JTRZZYY3S",
* "01HQ8PTFYYKDH1CP3C6PSTBZN5"
* ]
*/
User data encryption 🔐
All data sent in the user
object is fully encrypted at rest.
⚠️ When replaying a function, event.user
will be empty. This will be fixed in the future, but for now assume that you cannot replay functions that rely on event.user
data.
In the future, this object will be used to support programmatic deletion via API endpoint to support certain right-to-be-forgotten flows in your system. This will use the user.external_id
property for lookup.
Usage limits
See usage limits for more details.