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

# REST endpoints & URLs

> All ButterCMS REST endpoints for Pages, Collections, Blog Posts, Authors, Categories, Tags, and Feeds, with common query parameters.

## Base URL

```
https://api.buttercms.com/v2
```

> [!NOTE]
>
> All API requests should be made over HTTPS. A plain HTTP request is redirected (301) to the HTTPS equivalent rather than rejected outright, but clients that don't follow redirects should use HTTPS directly.

## Endpoint overview

### Pages endpoints

| Method | Endpoint | Description |
| - | - | - |
| `GET` | `/pages/` | List all Single Pages |
| `GET` | `/pages/{page_type}/` | List pages of a specific Page Type |
| `GET` | `/pages/{page_type}/{page_slug}/` | Retrieve a specific page by slug |
| `GET` | `/pages/search/` | Search pages by query string (`?query=term`) |
| `POST` | `/pages/` | Create a new page |
| `PUT` | `/pages/*/{page_slug}/` | Update an existing page |
| `PATCH` | `/pages/*/{page_slug}/` | Partially update a page |

> [!NOTE]
>
> There is no DELETE endpoint for Pages via the Write API.

### Collections endpoints

| Method | Endpoint | Description |
| - | - | - |
| `GET` | `/content/` | List all Collections |
| `GET` | `/content/{collection_key}/` | Retrieve items from a Collection |
| `GET` | `/content/{collection_key}/{item_id}/` | Retrieve a specific Collection item |
| `POST` | `/content/` | Create a new Collection item |
| `PUT` | `/content/{collection_key}/{item_id}/` | Update a Collection item |
| `PATCH` | `/content/{collection_key}/{item_id}/` | Partially update a Collection item |
| `DELETE` | `/content/{collection_key}/{item_id}/` | Delete a Collection item |

### Blog Posts endpoints

| Method | Endpoint | Description |
| - | - | - |
| `GET` | `/posts/` | List all blog posts |
| `GET` | `/posts/{slug}/` | Retrieve a specific blog post |
| `GET` | `/posts/search/` | Search blog posts |
| `POST` | `/posts/` | Create a new blog post |
| `PUT` | `/posts/{slug}/` | Update a blog post |
| `PATCH` | `/posts/{slug}/` | Partially update a blog post |
| `DELETE` | `/posts/{slug}/` | Delete a blog post |

### Blog metadata endpoints

| Method | Endpoint | Description |
| - | - | - |
| `GET` | `/authors/` | List all authors |
| `GET` | `/authors/{slug}/` | Retrieve a specific author |
| `GET` | `/categories/` | List all categories |
| `GET` | `/categories/{slug}/` | Retrieve a specific category |
| `GET` | `/tags/` | List all tags |
| `GET` | `/tags/{slug}/` | Retrieve a specific tag |

### Feeds endpoints

| Method | Endpoint | Description |
| - | - | - |
| `GET` | `/feeds/rss/` | RSS feed of blog posts |
| `GET` | `/feeds/atom/` | Atom feed of blog posts |
| `GET` | `/feeds/sitemap/` | XML sitemap |

## URL structure

### Pages URL pattern

```
/pages/{page_type}/{page_slug}/
```

**Parameters:**

* `page_type`: The slug of the Page Type (use `*` for Single Pages)
* `page_slug`: The unique slug identifier of the page

**Examples:**

```bash theme={null}
# Get a Single Page
GET /pages/*/homepage/

# Get a page from a Page Type
GET /pages/landing-pages/summer-sale/

# List all pages of a type
GET /pages/blog-posts/
```

### Collections URL pattern

```
/content/{collection_key}/
/content/{collection_key}/{item_id}/
```

**Parameters:**

* `collection_key`: The unique identifier/slug of the Collection
* `item_id`: The numeric ID of the Collection item

**Examples:**

```bash theme={null}
# Get all items from a Collection
GET /content/artists/

# Get a specific Collection item
GET /content/artists/123/
```

### Blog Posts URL pattern

```
/posts/{slug}/
```

**Parameters:**

* `slug`: The unique slug identifier of the blog post

**Examples:**

```bash theme={null}
# List all posts
GET /posts/

# Get a specific post
GET /posts/hello-world/

# Search posts
GET /posts/search/?query=butter
```

## Common query parameters

### Authentication

| Parameter | Description |
| - | - |
| `auth_token` | Your API token, read or write, passed as a query string parameter (alternative to the `Authorization` header). For Write tokens, prefer the header instead; see [Authentication & API tokens](https://buttercms.com/docs/api/concepts/authentication-api-tokens.md). |

### Pagination

| Parameter | Description | Default |
| - | - | - |
| `page` | Page number for page-based pagination | 1 |
| `page_size` | Number of items per page | 10 |
| `limit` | Number of items to return (offset pagination) | 10 |
| `offset` | Number of items to skip (offset pagination) | 0 |
| `order` | Sort order (`-field` for descending, `field` for ascending) | - |

### Content options

| Parameter | Description | Default |
| - | - | - |
| `preview` | Include draft content (`1` = enabled) | 0 |
| `locale` | Locale code for localized content (e.g., `en`, `es`) | Default locale |
| `levels` | Depth of reference field resolution (1-5) | 2 |

### Blog-specific

| Parameter | Description |
| - | - |
| `exclude_body` | Exclude post body for faster list responses (`true`/`false`) |
| `category_slug` | Filter posts by category |
| `tag_slug` | Filter posts by tag |
| `author_slug` | Filter posts by author |

## Example API calls

### Fetching Pages

```bash theme={null}
# List all pages of a Page Type with pagination
curl "https://api.buttercms.com/v2/pages/landing-pages/?auth_token=YOUR_TOKEN&page=1&page_size=10"

# Get a specific page with full reference resolution
curl "https://api.buttercms.com/v2/pages/landing-pages/summer-sale/?auth_token=YOUR_TOKEN&levels=3"

# Get a page in Spanish locale
curl "https://api.buttercms.com/v2/pages/landing-pages/summer-sale/?auth_token=YOUR_TOKEN&locale=es"

# Preview a draft page
curl "https://api.buttercms.com/v2/pages/landing-pages/summer-sale/?auth_token=YOUR_TOKEN&preview=1"
```

### Fetching Collections

```bash theme={null}
# Get all items from a Collection
curl "https://api.buttercms.com/v2/content/artists/?auth_token=YOUR_TOKEN"

# Filter Collection by field value
curl "https://api.buttercms.com/v2/content/artists/?auth_token=YOUR_TOKEN&fields.genre=Rock"

# Get a specific Collection item
curl "https://api.buttercms.com/v2/content/artists/123/?auth_token=YOUR_TOKEN"

# Paginated Collection with ordering
curl "https://api.buttercms.com/v2/content/artists/?auth_token=YOUR_TOKEN&page=2&page_size=20&order=-name"
```

### Fetching Blog Posts

```bash theme={null}
# List all published posts
curl "https://api.buttercms.com/v2/posts/?auth_token=YOUR_TOKEN"

# Get posts without body content (faster)
curl "https://api.buttercms.com/v2/posts/?auth_token=YOUR_TOKEN&exclude_body=true"

# Filter posts by category
curl "https://api.buttercms.com/v2/posts/?auth_token=YOUR_TOKEN&category_slug=technology"

# Search posts
curl "https://api.buttercms.com/v2/posts/search/?auth_token=YOUR_TOKEN&query=headless%20cms"

# Get a single post with next/previous navigation
curl "https://api.buttercms.com/v2/posts/hello-world/?auth_token=YOUR_TOKEN"
```

## Trailing slashes

> [!NOTE]
>
> Always end API URLs with a trailing slash, for example `/v2/posts/`. The API accepts both forms, but a `GET` to a Pages, Posts, or Collections endpoint without the slash gets a `301` redirect to the slashed URL. Most clients follow it automatically, so the call still works, but it makes two requests, both of which count toward your API usage, and adds a round trip.

```bash theme={null}
# Recommended: one request
GET /v2/posts/

# Works, but costs two requests (301 + follow-up)
GET /v2/posts

# Write requests are processed directly either way
POST /v2/posts/
```

## HTTPS

Use HTTPS for all API requests. A plain HTTP request is redirected (301) to HTTPS rather than rejected, but clients that don't follow redirects should use HTTPS directly.

```bash theme={null}
# Correct
https://api.buttercms.com/v2/posts/

# Redirected to HTTPS
http://api.buttercms.com/v2/posts/
```

## Next steps

> [card] [Request/Response Format](https://buttercms.com/docs/api/concepts/request-response-format.md)
>
> Learn about JSON data structures

> [card] [HTTP Status Codes](https://buttercms.com/docs/api/concepts/http-status-codes-errors.md)
>
> Understand error responses


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