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

# Errors

> Understand how the Lasso API communicates errors.

The API uses standard HTTP status codes and returns a consistent JSON error body for all error responses.

## Error response format

```json theme={null}
{
  "status_code": 422,
  "error_type": "validation_error",
  "message": "Missing required field: name",
  "request_id": "550e8400-e29b-41d4-a716-446655440000"
}
```

<ResponseField name="status_code" type="integer">
  The HTTP status code.
</ResponseField>

<ResponseField name="error_type" type="string">
  A machine-readable error type. See the table below.
</ResponseField>

<ResponseField name="message" type="string">
  A human-readable explanation of what went wrong.
</ResponseField>

<ResponseField name="request_id" type="string">
  A unique identifier for the request. Include this when contacting support.
</ResponseField>

## Error types

| Error type             | Status code | Description                                                               |
| ---------------------- | ----------- | ------------------------------------------------------------------------- |
| `invalid_request`      | 400         | The request is malformed or uses an unsupported HTTP method.              |
| `unauthenticated`      | 401         | Missing, invalid, or deactivated API key.                                 |
| `insufficient_credits` | 402         | Your account does not have enough credits for this operation.             |
| `forbidden`            | 403         | The API key does not have permission for this action.                     |
| `not_found`            | 404         | The requested resource does not exist or does not belong to your company. |
| `conflict`             | 409         | The request conflicts with the current state of the resource.             |
| `validation_error`     | 422         | The request body is missing required fields or contains invalid values.   |
| `rate_limited`         | 429         | Too many requests. Back off and retry after a delay.                      |
| `internal_error`       | 500         | An unexpected error occurred on the server.                               |

## Handling errors with the SDK

<CodeGroup>
  ```typescript TypeScript theme={null}
  import LassoClient, { LassoError } from "@lasso-ai/sdk";

  const client = new LassoClient({ apiKey: "lasso_..." });

  try {
    await client.tables.get("nonexistent_id");
  } catch (err) {
    if (err instanceof LassoError) {
      console.log(err.statusCode);  // 404
      console.log(err.errorType);   // "not_found"
      console.log(err.message);     // "Table not found"
      console.log(err.requestId);   // "550e8400-..."
    }
  }
  ```

  ```python Python theme={null}
  from lasso import LassoClient, LassoError

  client = LassoClient(api_key="lasso_...")

  try:
      client.tables.get("nonexistent_id")
  except LassoError as err:
      print(err.status_code)   # 404
      print(err.error_type)    # "not_found"
      print(err.args[0])       # "Table not found"
      print(err.request_id)    # "550e8400-..."
  ```
</CodeGroup>
