> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nelkap.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Start runs

> Start a run from your code, from an event, on a schedule, or from a past run.

## From your code

```ts theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
const { runId } = await nelkap.run(onboardUser, 'user_42');
```

Pass the workflow function itself, and its payload. The SDK finds the workflow's name.

Add tags to find the run later:

```ts theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
await nelkap.run(onboardUser, 'user_42', { tags: ['beta'] });
```

## From an event

List the events a workflow listens for. Each time one is emitted, the workflow starts a run with the event's payload:

```ts theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
nelkap.registerWorkflows([{ name: 'onboardUser', handler: onboardUser, events: ['user.created'] }]);

await nelkap.emit({ event: 'user.created', payload: 'user_42' });
```

A [webhook](https://docs.nelkap.com/guides/events.md#webhooks) emits an event too, each time another service calls it.

## On a schedule

```ts theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
nelkap.registerWorkflows([{ name: 'sendWeeklyReport', handler: sendWeeklyReport, cron: '0 9 * * 1' }]);
```

`cron` takes five fields: minute, hour, day of the month, month, and day of the week. Times are in UTC, so this one starts a run every Monday at 9:00 UTC. A scheduled run has no payload.

## Replay a run

Open a run and replay it. Nelkap starts a new run with the same payload and tags, and leaves the original as it was.

## How each run started

Each run shows its trigger: API, Event, Cron, or Manual for a replay.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.