> ## 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.

# step.run

> Run a piece of work once, and save what it returns.

```ts theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
nelkap.step.run<T>(name: string, fn: () => T | Promise<T>): Promise<T>
```

## Parameters

**name** `string` *required*

The step's name, up to 128 characters. It can repeat: steps of the same name are matched in order.

**fn** `() =\> T | Promise\<T\>` *required*

The work to do. What it returns must fit in JSON.

## Returns

What `fn` returned, passed through JSON. Once the step is saved, every call after gets this value back without running `fn` again.

## Errors

| Error | When |
| - | - |
| `StepError` | `fn` threw. The error is saved, and thrown again each time the run reaches the step. |
| `NelkapError` `badRequest` | The name breaks a rule above. |
| `NelkapError` `stepLimitReached` | The run has reached its limit of steps. |
| `NelkapError` `payloadLimitReached` | What `fn` returned is larger than your plan allows. |
| `Error` | It was called outside a run. |

## Example

```ts theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
const profile = await nelkap.step.run('profile', () => createProfile(userId));
```


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