> This page is for version v1 (default).
> For other versions, use one of these documentation indexes:
> - v1 (default): https://docs.butterix.com/en/llms.txt
> - v0: https://docs.butterix.com/en/v0/llms.txt

> For the MDX source of any page, append .mdx to the page URL.
> For a complete documentation index, see https://docs.butterix.com/en/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.butterix.com/_mcp/server.
> If something on this page is wrong or missing, POST JSON {"page": "<page URL>", "message": "<what is wrong>"} to https://docs.butterix.com/_biti/feedback/agent.

# Add content source

`POST /sites/{site}/sources`

Requires the `editor` role. A `document` is Markdown; a `website` is a public website fetched from `url` (respecting robots.txt). A site can have up to 20 sources.

Base URL: https://api.butterix.com/v1

Authentication: bearer token in Authorization header or API key in cookie `biti_session`

## Path parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `site` | string | yes | Site slug or id |

## Request body

Content type: `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `kind` | enum | yes | Allowed: `document`, `website`. |
| `title` | string | no | Title; required for `document`, the host name by default for `website` |
| `url` | string | yes | Address to cite for a document, or where fetching starts |
| `document` | string | no | Markdown content, `document` only |
| `paths` | list of strings | no | Fetch only pages under these paths; the start URL's directory by default, `website` only |
| `exclude` | list of strings | no | Don't fetch pages under these paths, `website` only |
| `maxPages` | integer | no | Page limit, `website` only |
| `refresh` | enum | no | How often to fetch again, `website` only Allowed: `never`, `daily`, `weekly`, `monthly`. |

## Example request

```bash
curl -X POST https://api.butterix.com/v1/sites/acme-payments/sources \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json" \
     -d '{
         "kind": "website",
         "url": "https://help.acme.com/",
         "maxPages": 200,
         "refresh": "weekly"
       }'
```

## Responses

### 201

New content source; websites are fetched in the background

Content type: `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `id` | string | no |  |
| `kind` | enum | no | Allowed: `document`, `website`. |
| `title` | string | no |  |
| `url` | string | no |  |
| `config` | object | no | Fetch settings, `website` only |
| `config.paths` | list of strings | no |  |
| `config.exclude` | list of strings | no |  |
| `config.maxPages` | integer | no |  |
| `config.refresh` | enum | no | Allowed: `never`, `daily`, `weekly`, `monthly`. |
| `status` | enum | no | Allowed: `ready`, `queued`, `running`, `failed`. |
| `error` | string | no | Why the last fetch failed |
| `pageCount` | integer | no |  |
| `createdAt` | integer | no |  |
| `refreshedAt` | integer | no | When the content was last updated May be null. |
| `nextAt` | integer | no | When it's fetched next May be null. |
| `pages` | list of objects | no | Pages, 500 at most; not in lists |
| `pages[].url` | string | no |  |
| `pages[].title` | string | no |  |
| `pages[].size` | integer | no | Number of characters of text |
| `document` | string | no | Markdown content, `document` only; not in lists |

### 400

Invalid request parameters

Content type: `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | string | yes | Human-readable error message |
| `code` | string | no | Machine-readable error code (some endpoints) |

### Example response (201)

```json
{
  "id": "src_01jd8x2k7q",
  "kind": "document",
  "title": "help.acme.com",
  "url": "https://help.acme.com/",
  "config": {
    "paths": [
      "string"
    ],
    "exclude": [
      "string"
    ],
    "maxPages": 1,
    "refresh": "never"
  },
  "status": "ready",
  "error": "string",
  "pageCount": 86,
  "createdAt": 1,
  "refreshedAt": 1,
  "nextAt": 1,
  "pages": [
    {
      "url": "string",
      "title": "string",
      "size": 1
    }
  ],
  "document": "string"
}
```
