> For the complete documentation index, see [llms.txt](https://planck-ai.gitbook.io/planck-ai-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://planck-ai.gitbook.io/planck-ai-docs/documentation/reference/error-handling.md).

# Error Handling

The Planck AI API uses standard HTTP status codes to indicate whether a request succeeded or failed.

Use this page to understand common API errors and how to troubleshoot them.

### Common error codes

| Status code | Meaning                                                                                    |
| ----------- | ------------------------------------------------------------------------------------------ |
| `400`       | Bad request. The request body, parameters, or target resource may be invalid.              |
| `401`       | Missing or invalid API key.                                                                |
| `403`       | The API key is valid, but the user does not have permission for this endpoint or resource. |
| `404`       | The requested resource was not found or is not accessible to the user.                     |
| `409`       | Conflict. For example, a user with the same email already exists.                          |
| `429`       | Rate limit exceeded.                                                                       |
| `500`       | Server error.                                                                              |

### Error response format

An error response may include a `detail` field explaining what went wrong.

Example:

```json
{
  "detail": "This endpoint is not available via API key: POST /api/v1/users/"
}
```

The exact error message may vary by endpoint and deployment.

### 400 Bad Request

A `400` error usually means the request is invalid.

Common causes:

* Missing required fields
* Invalid JSON body
* Invalid role value
* Invalid query parameter
* Inactive target user when issuing an API key
* Malformed request payload

How to fix:

* Check the request body
* Confirm required fields are present
* Confirm values match the expected format
* Review the endpoint documentation

### 401 Unauthorized

A `401` error means the API key is missing, invalid, or expired.

Common causes:

* Missing `X-API-Key` header
* Incorrect API key
* Deleted or inactive API key
* API key copied incorrectly

How to fix:

* Confirm the request includes the `X-API-Key` header
* Check that the key was copied correctly
* Create a new API key if needed
* Avoid extra spaces or hidden characters in environment variables

Example:

```
curl -H "X-API-Key: pk_live_your_key_here" \  "https://<your-planck-domain>/api/v1/workspaces"
```

### 403 Forbidden

A `403` error means the API key is valid, but the user does not have permission.

Common causes:

* User does not have access to the workspace
* User does not have access to the document or integration
* Non-admin user is calling an admin-only endpoint
* Endpoint is not allowed for API-key access

How to fix:

* Confirm the user has access to the workspace
* Confirm the user has the required role
* Use an Admin API key for admin endpoints
* Check whether the endpoint supports API-key access

### 404 Not Found

A `404` error means the requested resource was not found or is not accessible.

Common causes:

* Incorrect workspace ID
* Incorrect document ID
* Incorrect conversation ID
* Incorrect database integration ID
* User does not have access to the resource

How to fix:

* List workspaces before calling workspace-specific endpoints
* List documents before referencing a document ID
* List conversations before referencing a conversation ID
* Confirm the user has permission to access the resource

### 409 Conflict

A `409` error means the request conflicts with an existing resource.

Common cause:

* Creating a user with an email address that already exists

How to fix:

* Look up the existing user by email
* Add the existing user to the workspace if needed
* Issue an additional API key for the existing user if needed

Example existing-user lookup:

```
curl -H "X-API-Key: pk_live_admin_key_here" \  "https://<your-planck-domain>/api/v1/admin/users/by-email?email=existing.user@example.com"
```

### 429 Rate Limit Exceeded

A `429` error means too many requests were sent in a short period.

How to fix:

* Retry after a delay
* Use exponential backoff
* Avoid unnecessary polling
* Batch requests where supported
* Reduce concurrent requests

### 500 Server Error

A `500` error means the server encountered an unexpected issue.

How to fix:

* Retry the request after a short delay
* Check whether the same request fails repeatedly
* Capture the request ID or timestamp if available
* Contact Planck AI support with the endpoint, timestamp, and request details

### Troubleshooting checklist

Before contacting support, check:

* Is the base URL correct?
* Is the API key included in the `X-API-Key` header?
* Is the API key active?
* Does the API key owner have access to the workspace?
* Does the API key owner have the required role?
* Are the workspace, document, conversation, or integration IDs correct?
* Is the request body valid JSON?
* Are required fields present?
* Is the endpoint available for API-key access?

### Recommended next pages

* **Authentication** — learn how API keys work
* **Chat API** — send stateless chat messages
* **Conversations API** — create and manage multi-turn conversations
* **Admin API** — understand admin-only endpoints


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://planck-ai.gitbook.io/planck-ai-docs/documentation/reference/error-handling.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
