Announcing our new Vercel integration
Join our Discord
Sign up for free

Function input and output

Input data

Functions are always triggered with input data. For event-based functions, Inngest invokes the function with the event data. For scheduled functions, Inngest invokes the function with a schedule event.

Each step gets the same input type, documented here as Typescript:

typescript
type Input = {
event: Event;
steps: {
[stepID: string]: { [k: string]: any };
};
ctx: {
[key: string]: any;
};
}

The input has the following keys:

  • event: the triggering event, using the event format documented here
  • steps: the output of each completed step, within step functions. This is a map keyed by step ID.
  • ctx: Context for the function. In the future, this will contain items such as opentelemetry IDs.

Reading input data

Input data is accessed in different ways, depending on the runtime.

  • docker: Custom docker-based functions can always read the input as a JSON-encoded string as a command line argument passed to the image's command or entrypoint (e.g. os.Args[1] in Go, process.argv[2] in Node)
  • http: The input can be read as a JSON-encoded string from the request body.
  • lambda: The input data is read as a normal AWS lambda event.

These methods were chosen because they're built in to every language - it's a standard, and requires no SDK.

Writing responses from steps

You can write your step's response depending on the step's runtime:

  • docker: Print the JSON-encoded response to stdout.
  • http: write the response as a JSON-encoded object in the response body.
  • lambda: return the response according to the AWS lambda guide.

For standard containers, printing to stdout is easy - and is built in to every language, without needing an SDK.

Response format

When a step completes it can return data that's usable by subsequent steps. The data also indicates how retries should be handled.

In keeping with standards, we strongly recommend returning HTTP-like responses:

json
{
status indicates the response status for this function.
status: 200,
body can be any data returned from your function.
body: {
records: [],
}
}

If status isn't provided, we fall back to statusCode (the field that AWS Lambda uses).

Status codes

Step responses can contain status codes, via the top level status or statusCode field. This allows you to configure retries; a 5xx indicates a temporary internal error, whereas a 4xx indicates an error that cannot be fixed by retries. Read more about retries here.

Body

You can return arbitrary data in the body, usable by any future steps. This data is recorded within the run state and is visible within the cloud UI for debugging.

Limits

The response size is currently limited to 1MB. To increase this limit, reach out to us: hi@inngest.com.