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

# 更新内容来源

`PATCH /sites/{site}/sources/{id}`

需要 `editor` 角色。只更新传入的字段；网站随后重新抓取。

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 | 站点 slug 或 id |
| `id` | string | yes | 内容来源 id |

## Request body

Content type: `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `title` | string | no |  |
| `url` | string | no |  |
| `document` | string | no |  |
| `paths` | list of strings | no |  |
| `exclude` | list of strings | no |  |
| `maxPages` | integer | no |  |
| `refresh` | enum | no | Allowed: `never`, `daily`, `weekly`, `monthly`. |

## Example request

```bash
curl -X PATCH https://api.butterix.com/v1/sites/acme-payments/sources/src_01jd8x2k7q \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json" \
     -d '{}'
```

## Responses

### 200

更新后的内容来源

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 | 抓取设置，仅 `website` |
| `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 | 上次抓取失败的原因 |
| `pageCount` | integer | no |  |
| `createdAt` | integer | no |  |
| `refreshedAt` | integer | no | 内容最近更新的时间 May be null. |
| `nextAt` | integer | no | 下一次抓取的时间 May be null. |
| `pages` | list of objects | no | 页面，最多 500 个；列表中不返回 |
| `pages[].url` | string | no |  |
| `pages[].title` | string | no |  |
| `pages[].size` | integer | no | 正文的字符数 |
| `document` | string | no | Markdown 正文，仅 `document`；列表中不返回 |

### 400

请求参数无效

Content type: `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | string | yes | 人类可读的错误信息 |
| `code` | string | no | 机器可读的错误码（部分接口提供） |

### Example response (200)

```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"
}
```
