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

# API overview

> Introduction to the PocketBase REST API

PocketBase provides a comprehensive REST API for managing your backend. The API allows you to perform CRUD operations on records, authenticate users, upload files, and manage your database in real-time.

## Base URL

All API requests should be made to:

```
http://127.0.0.1:8090/api/
```

Replace with your actual PocketBase server URL in production.

## Authentication

PocketBase supports multiple authentication methods:

* **Admin authentication** - For superuser access to all API endpoints
* **User authentication** - For auth collection records with specific permissions
* **File tokens** - For accessing protected files

Include the auth token in the `Authorization` header:

```bash theme={null}
Authorization: Bearer YOUR_AUTH_TOKEN
```

## Request format

The API accepts and returns JSON by default. For file uploads, use `multipart/form-data`.

### Content-Type headers

* `application/json` - For JSON requests
* `multipart/form-data` - For file uploads

## Response format

All responses are returned in JSON format with appropriate HTTP status codes.

### Success responses

<ResponseField name="code" type="number">
  HTTP status code (200, 201, 204, etc.)
</ResponseField>

<ResponseField name="message" type="string">
  Human-readable success message
</ResponseField>

<ResponseField name="data" type="object">
  Response payload (varies by endpoint)
</ResponseField>

### Error responses

<ResponseField name="code" type="number">
  HTTP error code (400, 401, 403, 404, 500, etc.)
</ResponseField>

<ResponseField name="message" type="string">
  Human-readable error message
</ResponseField>

<ResponseField name="data" type="object">
  Additional error details including validation errors
</ResponseField>

## Common HTTP status codes

| Code | Description                                  |
| ---- | -------------------------------------------- |
| 200  | Success                                      |
| 201  | Created                                      |
| 204  | No Content (success with no response body)   |
| 400  | Bad Request (validation error)               |
| 401  | Unauthorized (missing or invalid auth token) |
| 403  | Forbidden (insufficient permissions)         |
| 404  | Not Found                                    |
| 429  | Too Many Requests (rate limit exceeded)      |
| 500  | Internal Server Error                        |

## Pagination

List endpoints support pagination using query parameters:

<ParamField query="page" type="number" default="1">
  Page number to retrieve
</ParamField>

<ParamField query="perPage" type="number" default="30">
  Number of items per page (max 500)
</ParamField>

### Pagination response

<ResponseField name="page" type="number">
  Current page number
</ResponseField>

<ResponseField name="perPage" type="number">
  Items per page
</ResponseField>

<ResponseField name="totalItems" type="number">
  Total number of items across all pages
</ResponseField>

<ResponseField name="totalPages" type="number">
  Total number of pages
</ResponseField>

<ResponseField name="items" type="array">
  Array of items for the current page
</ResponseField>

## Filtering and sorting

You can filter and sort list results using query parameters:

<ParamField query="filter" type="string">
  Filter expression (e.g., `status='active' && created>'2023-01-01'`)
</ParamField>

<ParamField query="sort" type="string">
  Sort fields (prefix with `-` for descending, e.g., `-created,title`)
</ParamField>

## Expanding relations

Use the `expand` parameter to include related records:

<ParamField query="expand" type="string">
  Comma-separated list of relation fields to expand (e.g., `author,categories`)
</ParamField>

## Field selection

Limit the fields returned in the response:

<ParamField query="fields" type="string">
  Comma-separated list of fields to include (e.g., `id,title,created`)
</ParamField>

## Rate limiting

PocketBase implements rate limiting on API endpoints to prevent abuse. When you exceed the rate limit, you'll receive a 429 status code.

<Note>
  Rate limits vary by endpoint and can be configured per collection.
</Note>

## CORS

Cross-Origin Resource Sharing (CORS) is enabled by default. You can configure allowed origins in the application settings.

## Next steps

<CardGroup cols={2}>
  <Card title="Authentication" icon="lock" href="/api/authentication">
    Learn how to authenticate users and manage sessions
  </Card>

  <Card title="Records" icon="database" href="/api/records">
    Perform CRUD operations on collection records
  </Card>

  <Card title="Realtime" icon="bolt" href="/api/realtime">
    Subscribe to real-time data changes
  </Card>

  <Card title="Files" icon="file" href="/api/files">
    Upload and download files
  </Card>
</CardGroup>
