LibraryDocsBlogPricing
Log inSign up for free →

Event transforms

On this page
  1. 1. Defining a transform
  2. 2. Limits

Inngest requires events to be in the documentented format in order to be properly processed. What if your events have a different structure, or you need to consume a webhook with a different payload?

Inngest allows you to create transforms which run every time an event is received. You can define a small Javascript functon that takes in the original payload and HTTP headers, runs transformations, and returns an event in our format.

This means you can send us data from anywhere without changes to your existing systems, or consume webhooks from any system with high availability.

Defining a transform

Transforms are defined per "ingest key" - an API key which you use to send us events. Typically, you create one key per webhook or per API implementation.

When you create or edit an ingest key you have the option to write a javascript-based transform function to alter the event shape. This transform function can run ES6 code, but must return within 20ms and has no network access.

Here's an example of a transform for consuming GitHub events:

js
function transform(evt, headers = {}) {
const { id, ...rest } = evt.actor ? evt.actor : {};
// GitHub sends the event name in HTTP headers
const name = headers["X-Github-Event"] || "";
return {
name: "github/" + name.trim().replace("Event", "").toLowerCase(),
data: evt,
user: { github_id },
};
};

The transform function gets the incoming event object and the HTTP headers, then returns data in our format. We add the github_id user identification field for audit tracking.

Limits

Transforms must be under 2KB in size and must run within 20ms. They have no disk access and no network access.

    On this page
  1. 1. Defining a transform
  2. 2. Limits