# Inngest Functions

Inngest functions are durable, retriable units of background logic that run on your own compute and are triggered by events, cron schedules, or webhooks. Use them for background jobs, scheduled work, and multi-step workflows that need automatic retries, step-level state, and observability without adding a queue or workflow engine.

You write standard TypeScript, Python, or Go code, then expose functions with [`serve()`](/docs-markdown/learn/serving-inngest-functions) or [Connect](/docs-markdown/setup/connect) so Inngest can invoke and coordinate runs from the platform.

## What are Inngest functions?

An Inngest function is a regular function wrapped with Inngest trigger and execution metadata. Inngest starts a run when a matching event, schedule, or webhook arrives, then records each step so failed work can retry from the last successful checkpoint instead of restarting from scratch.

At a high level, an Inngest function has three core parts:

**Triggers**: [A list of Events, Cron schedules or webhook events that trigger Function runs.]('/docs-markdown/features/events-triggers')

**Flow Control**: [Control how Function runs get distributed in time with Concurrency, Throttling and more.]('/docs-markdown/guides/flow-control')

**Steps**: [Transform your Inngest Function into a workflow with retriable checkpoints.]('/docs-markdown/learn/inngest-functions')

```ts
inngest.createFunction({
    id: "sync-systems",
    // A Function is triggered by events
    triggers: { event: "auto/sync.request" },
    // Easily add Throttling with Flow Control
    throttle: { limit: 3, period: "1min"},
  },
  async ({ step }) => {
    // step is retried if it throws an error
    const data = await step.run("get-data", async () => {
      return getDataFromExternalSource();
    });

    // Steps can reuse data from previous ones
    await step.run("save-data", async () => {
      return db.syncs.insertOne(data);
    });
  }
);
```

```python
@inngest_client.create_function(
    id="sync-systems",
    # trigger (event or cron)
    trigger=inngest.TriggerEvent(event="auto/sync.request"),
)
def sync_systems(ctx: inngest.ContextSync) -> None:
    # step is retried if it throws an error
    data = ctx.step.run("Get data", get_data_from_external_source)

    # Steps can reuse data from previous ones
    ctx.step.run("Save data", db.syncs.insert_one, data)
```

```go
import (
	"context"

	"github.com/inngest/inngestgo"
	"github.com/inngest/inngestgo/step"
)

func loadSyncDataInngestFn(client inngestgo.Client) (inngestgo.ServableFunction, error) {
	return inngestgo.CreateFunction(client,
		inngestgo.FunctionOpts{ID: "sync-systems"},
		// Functions are triggered by events
		inngestgo.EventTrigger("auto/sync.request", nil),
		func(ctx context.Context, input inngestgo.Input[SyncRequestEvent]) (any, error) {
			// By wrapping code in step.run, the code will be retried if it throws an error and when successfuly.
			// It's result is saved to prevent unnecessary re-execution
			data, err := step.Run(ctx, "get-data", func(ctx context.Context) (any, error) {
				return getDataFromExternalSource()
			})
			if err != nil {
				return nil, err
			}

			// steps can reuse data from previous ones
			// can also be retried up to 4 times
			_, err = step.Run(ctx, "save-data", func(ctx context.Context) (any, error) {
				return InsertIntoDB(data.(DataType))
			})
			if err != nil {
				return nil, err
			}

			return nil, nil
		},
	)
}
```

## Using Inngest Functions

Start using Inngest Functions by using the pattern that fits your use case:

**Background jobs**: [Run long-running tasks out of the critical path of a request.]('/docs-markdown/guides/background-jobs')

**Delayed Functions**: [Schedule Functions that run in the future.]('/docs-markdown/guides/delayed-functions')

**Cron Functions**: [Build Inngest Functions as CRONs.]('/docs-markdown/guides/scheduled-functions')

**Workflows**: [Start creating workflows by leveraging Inngest Function Steps.]('/docs-markdown/learn/inngest-steps')

## Learn more about Functions and Steps

Functions and Steps are powered by Inngest's Durable Execution Engine. Learn about its inner working by reading the following guides:

**How Functions are executed**: [A deep dive into Inngest's Durable Execution Engine with a step-by-step workflow run example.]('/docs-markdown/learn/how-functions-are-executed')

**Thinking in Steps**: [Discover by example how steps enable more reliable and flexible functions with step-level error handling, conditional steps and waits.]('/docs-markdown/learn/inngest-steps')

## SDK References

**"TypeScript SDK"**: [API reference]("/docs-markdown/reference/typescript/v4/intro")

**"Python SDK"**: [API reference]("/docs-markdown/reference/python")

**"Go SDK"**: [Go API reference]("https://pkg.go.dev/github.com/inngest/inngestgo@v0.9.0/step")