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

# Error Handling

> Learn how to handle errors from the API.

# Error Structure

Our API returns a consistent error structure for all errors. The API always returns a JSON response with an array of `issues`, Onsi Issues always have a `code` and a `message`.

An exhaustive list can be found lower down.

```json theme={null}
{
  "issues": [
    {
      "code": "HeaderValidation",
      "message": "Required",
      "path": "x-api-key"
    },
    {
      "code": "BodyValidation",
      "message": "Required",
      "path": "currency"
    }
  ]
}
```

<Warning>
  Using the `message` field to conditionally handle errors is not recommended as the `message` field may change in the
  future. Always use the `code` field to conditionally handle errors, or any other property in a specific error, like
  the `row` in an `InvalidContent` error.
</Warning>

# Error List

### Generic

<Info>
  We may introduce more specific error codes to replace the existing generic ones in the future. For now, we recommend
  treating any generic error codes as a catch-all.
</Info>

#### InternalServerError

This is our generic internal server error, this will be returned in cases where an unexpected error occurs

<ParamField body="code" type="string" required="true" />

<ParamField body="message" type="string" required="true" />

#### BadRequest

This is our generic bad request error, this will be returned in cases where the request is malformed or invalid and there is no more specific error code to return

<ParamField body="code" type="string" required="true" />

<ParamField body="message" type="string" required="true">
  A human-readable message used for debugging and logging
</ParamField>

**Example:**

```json theme={null}
{
  "code": "BadRequest",
  "message": "The address provided must be based in the United Kingdom"
}
```

#### Forbidden

This is our generic forbidden error, this will be returned in cases where the user is not allowed to perform the requested action

<ParamField body="code" type="string" required="true" />

<ParamField body="message" type="string" required="true">
  A human-readable message used for debugging and logging
</ParamField>

**Example:**

```json theme={null}
{
  "code": "Forbidden",
  "message": "You are not allowed to perform this action"
}
```

#### NotFound

This is our generic not found error, this will be returned in cases where the requested resource does not exist

<ParamField body="code" type="string" required="true" />

<ParamField body="message" type="string" required="true">
  A human-readable message used for debugging and logging
</ParamField>

#### Conflict

This is our generic conflict error, this will be returned in cases where the request conflicts with the current state of the server

<ParamField body="code" type="string" required="true" />

<ParamField body="message" type="string" required="true">
  A human-readable message used for debugging and logging
</ParamField>

#### RateLimitExceeded

The request was rate limited

<ParamField body="code" type="string" required="true" />

<ParamField body="message" type="string" required="true">
  A human-readable message used for debugging and logging
</ParamField>

#### UnprocessableEntity

This is our generic unprocessable entity error, this will be returned in cases where the request is valid but cannot be processed due to business logic or other constraints

<ParamField body="code" type="string" required="true" />

<ParamField body="message" type="string" required="true">
  A human-readable message used for debugging and logging
</ParamField>

### Request Validation

#### BodyValidation

An error occurred while validating the request body

<ParamField body="code" type="string" required="true" />

<ParamField body="message" type="string" required="true">
  A human-readable message used for debugging and logging
</ParamField>

<ParamField body="path" type="string" required="true" />

#### QueryValidation

An error occurred while validating the request query parameters

<ParamField body="code" type="string" required="true" />

<ParamField body="message" type="string" required="true">
  A human-readable message used for debugging and logging
</ParamField>

<ParamField body="path" type="string" required="true" />

#### PathValidation

An error occurred while validating the request path parameters

<ParamField body="code" type="string" required="true" />

<ParamField body="message" type="string" required="true">
  A human-readable message used for debugging and logging
</ParamField>

<ParamField body="path" type="string" required="true" />

#### HeaderValidation

An error occurred while validating the request headers

<ParamField body="code" type="string" required="true" />

<ParamField body="message" type="string" required="true">
  A human-readable message used for debugging and logging
</ParamField>

<ParamField body="path" type="string" required="true" />

### Specific

#### MemberNotFound

The member could not be found

<ParamField body="code" type="string" required="true" />

<ParamField body="message" type="string" required="true">
  A human-readable message used for debugging and logging
</ParamField>

<ParamField body="memberId" type="string" required="true">
  The unique identifier for a Member, prefixed with mem\_
</ParamField>

**Example:**

```json theme={null}
{
  "code": "MemberNotFound",
  "message": "The member could not be found",
  "memberId": "mem_foo"
}
```

#### MemberNotEligible

The member is not eligible to perform the requested action

<ParamField body="code" type="string" required="true" />

<ParamField body="message" type="string" required="true">
  A human-readable message used for debugging and logging
</ParamField>

<ParamField body="memberId" type="string" required="true">
  The unique identifier for a Member, prefixed with mem\_
</ParamField>

#### MemberAlreadyInvited

The member has already been invited

<ParamField body="code" type="string" required="true" />

<ParamField body="message" type="string" required="true">
  A human-readable message used for debugging and logging
</ParamField>

<ParamField body="memberId" type="string" required="true">
  The ID of the member who already exists in the system
</ParamField>

#### MemberInsufficientFunds

The member does not have enough funds to perform the requested action

<ParamField body="code" type="string" required="true" />

<ParamField body="message" type="string" required="true">
  A human-readable message used for debugging and logging
</ParamField>

<ParamField body="memberId" type="string" required="true">
  The unique identifier for a Member, prefixed with mem\_
</ParamField>

#### BankAccountInvalid

The bank account provided is invalid

<ParamField body="code" type="string" required="true" />

<ParamField body="message" type="string" required="true">
  A human-readable message used for debugging and logging
</ParamField>

#### FileContent

An error occurred while processing the file content, commonly used for CSV/Ecxel files

<ParamField body="code" type="string" required="true" />

<ParamField body="message" type="string" required="true">
  A human-readable message used for debugging and logging
</ParamField>

<ParamField body="row" type="string" required="true">
  The row number in the file where the error occurred
</ParamField>

#### AmountBelowLowerLimit

The requested withdrawal intent amount is below the minimum which can be withdrawn, also returns the minimum amount which can be withdrawn

<ParamField body="code" type="string" required="true" />

<ParamField body="message" type="string" required="true">
  A human-readable message used for debugging and logging
</ParamField>

<ParamField body="lowerLimit" type="object" required="true">
  A monetary value with currency. See [Money](/docs/schemas/money)

  <Expandable title="properties">
    <ParamField body="amount" type="string" required="true">
      Price in lowest denomination of currency (e.g. cents)
    </ParamField>

    <ParamField body="currency" type="string" required="true">
      ISO 4217 currency code
    </ParamField>
  </Expandable>
</ParamField>

**Example:**

```json theme={null}
{
  "code": "AmountBelowLowerLimit",
  "message": "Withdrawal amount is below the lower limit of £10.00",
  "lowerLimit": {
    "amount": 1000,
    "currency": "GBP"
  }
}
```

#### AmountAboveUpperLimit

The requested withdrawal intent amount is above the maximum which can be withdrawn, also returns the maximum amount which can be withdrawn

<ParamField body="code" type="string" required="true" />

<ParamField body="message" type="string" required="true">
  A human-readable message used for debugging and logging
</ParamField>

<ParamField body="upperLimit" type="object" required="true">
  A monetary value with currency. See [Money](/docs/schemas/money)

  <Expandable title="properties">
    <ParamField body="amount" type="string" required="true">
      Price in lowest denomination of currency (e.g. cents)
    </ParamField>

    <ParamField body="currency" type="string" required="true">
      ISO 4217 currency code
    </ParamField>
  </Expandable>
</ParamField>

**Example:**

```json theme={null}
{
  "code": "AmountAboveUpperLimit",
  "message": "Withdrawal amount is above the upper limit of £200.00",
  "upperLimit": {
    "amount": 20000,
    "currency": "GBP"
  }
}
```

#### InvalidAddMemberPayload

The payload provided to add a member is invalid

<ParamField body="code" type="string" required="true" />

<ParamField body="message" type="string" required="true">
  A human-readable message used for debugging and logging
</ParamField>

<ParamField body="email" type="string" required="true">
  The email provided to add a member
</ParamField>

#### InvalidUpdateMemberPayload

The payload provided to update a member is invalid

<ParamField body="code" type="string" required="true" />

<ParamField body="message" type="string" required="true">
  A human-readable message used for debugging and logging
</ParamField>

<ParamField body="memberId" type="string" required="true">
  The unique identifier for a Member, prefixed with mem\_
</ParamField>

#### InvalidRemoveMemberPayload

The payload provided to remove a member is invalid

<ParamField body="code" type="string" required="true" />

<ParamField body="message" type="string" required="true">
  A human-readable message used for debugging and logging
</ParamField>

<ParamField body="memberId" type="string" required="true">
  The unique identifier for a Member, prefixed with mem\_
</ParamField>
