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

# Errors

> Every error the SDK throws, and every reason a run can fail.

## NelkapError

Thrown when Nelkap turns a call down.

**status** `number`

The HTTP status of the answer.

**message** `string`

The reason's code, like `workflowNotFound`.

**issues** `\{ path: PropertyKey[]; message: string \}[]`

For `badRequest`, the fields at fault and what is wrong with each.

```ts theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
import { NelkapError } from '@nelkap/sdk';

try {
  await nelkap.run(onboardUser, 'user_42');
} catch (error) {
  if (error instanceof NelkapError && error.message === 'throughputLimitReached') {
    // Try again in a moment.
  }
}
```

## StepError

Thrown by [`step.run`](https://docs.nelkap.com/reference/step-run) when its function threw.

**message** `string`

The message of the error the function threw, up to 2,048 characters.

**cause** `unknown`

The error the function threw, on the call where the step ran.

## API errors

| Code | Status | When |
| - | - | - |
| `badRequest` | 400 | A value breaks a rule. `issues` lists which ones. |
| `apiKeyMissing` | 401 | The API key is empty. |
| `apiKeyInvalid` | 401 | The API key is wrong, deleted, or expired, or none is set. |
| `workspaceExpired` | 402 | The workspace is no longer active. |
| `workflowLimitReached` | 402 | You registered more workflows than your plan allows per project. |
| `stepLimitReached` | 402 | The run reached its limit of steps. |
| `ipNotAllowed` | 403 | The API key takes calls only from its allowed IPs. |
| `workflowNotFound` | 404 | The project has no enabled workflow with this name. |
| `runNotFound` | 404 | The run isn't running anymore, so the step wasn't saved. |
| `payloadLimitReached` | 413 | The request is larger than your plan allows. |
| `throughputLimitReached` | 429 | Too many requests in the same second for your plan. |
| `unexpected` | 500 | Something went wrong on Nelkap's side. |

When saving a step gets `throughputLimitReached` or `unexpected`, the SDK doesn't throw. See [Short outages](https://docs.nelkap.com/guides/failures.md#short-outages).

## Run failures

Besides your own errors, a run can fail for one of these reasons, shown on its page:

| Reason | Shown as |
| - | - |
| `deliveryFailed` | Your endpoint could not be reached after three attempts. |
| `stepLimitReached` | This run reached its maximum number or size of steps. |
| `waitExpired` | This run waited more than a year for its event. |

## SDK errors

The SDK throws a plain `Error` in three cases:

| Message | When |
| - | - |
| `Only a workflow passed to registerWorkflows can start a run.` | [`run`](https://docs.nelkap.com/reference/run) got a function that isn't registered. |
| `nelkap.step can only be called while Nelkap runs a workflow.` | A step was called outside a run. |
| `Invalid duration: …` | [`step.sleep`](https://docs.nelkap.com/reference/step-sleep) got a duration it can't read. |


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