# 欢迎使用 ButterIX > ButterIX 是一个从 OpenAPI 与 MDX 生成 API 文档站的平台。本页介绍它能做什么、适合谁,以及从哪里开始。 ButterIX 把一个由 `docs.yml`、MDX 页面和 OpenAPI 规范组成的项目,构建成**一组纯静态文件**:每个页面都是可以直接被搜索引擎收录的 HTML,同时附带一份 Markdown 版本给 AI 阅读。ButterIX 托管平台负责构建与托管,并提供 Ask AI、MCP 与分析。 你正在阅读的这个站点本身就是一个 biti 项目(源码在仓库的 `apps/docs/`),它用到了本文档介绍的几乎所有功能。 ## 从这里开始 [**快速开始**](https://docs.butterix.com/guides/get-started/quickstart.md) 安装 CLI,五分钟内在本机预览并发布第一个文档站。 [**核心概念**](https://docs.butterix.com/guides/get-started/concepts.md) 项目、导航、变体(版本 × 语言)、静态产物与运行时。 [**docs.yml 参考**](https://docs.butterix.com/guides/configuration/docs-yml.md) 逐字段说明站点配置:品牌、布局、导航、版本、语言、SEO、AI。 [**组件**](https://docs.butterix.com/components/overview.md) 40 多个 MDX 组件,无需导入,直接在页面中使用。 ## 为什么选择 ButterIX **纯静态产物** 每页都是普通的 HTML / CSS / JS,零水合、首屏极快。 **API 参考** 从 OpenAPI 3.x / Swagger 2 生成端点页面、9 种语言的代码示例和在线调试。 **多版本与多语言** 版本切换、`translations//` 目录约定、AI 增量翻译与 hreflang。 **Agent 友好** 每页都有 `.md` 版本,自动生成 `llms.txt`,每个站点自带 MCP 服务器。 **Ask AI** 基于你的文档回答问题并给出引用,可选 Anthropic、DeepSeek 或 OpenRouter。 **安全的 MDX** 不执行任何作者代码:属性只允许字面量,托管多租户也安全。 ## 一个项目长什么样 ``` my-docs/ docs.yml pages/ introduction.mdx quickstart.mdx openapi.yml assets/ logo.svg ``` 最小的 `docs.yml` 只需要标题和导航: ```yaml title="docs.yml" title: Acme 文档 navigation: - section: 开始 contents: - page: 简介 path: pages/introduction.mdx slug: introduction ``` 运行 `biti dev` 即可在本机预览,`biti deploy` 发布到托管平台。详见[快速开始](https://docs.butterix.com/guides/get-started/quickstart.md)。 ## 已经在用 Fern 或 Mintlify? **Fern** ButterIX 的 `docs.yml` 字段与 Fern 保持一致(kebab-case),`fern/docs.yml` 可以被直接读取,组件名与属性也兼容。参见[从 Fern 迁移](https://docs.butterix.com/guides/reference/migrate-from-fern.md)。 **Mintlify** 项目根目录的 `docs.json` / `mint.json` 会在加载时自动转换为 ButterIX 的配置,``、``、`` 等组件开箱即用。参见[从 Mintlify 迁移](https://docs.butterix.com/guides/reference/migrate-from-mintlify.md)。 > **把文档交给 AI** > > 这个站点的每一页都可以在地址后加 `.md` 获取 Markdown;站点根目录的 [`/llms.txt`](https://docs.butterix.com/llms.txt) 列出了全部页面。也可以把本站的 MCP 服务器接入 Claude Code 或 Cursor,见 [Agent 友好](https://docs.butterix.com/guides/features/agents.md)。 --- # 快速开始 > 安装 biti CLI,用 biti init、biti login、biti dev 与 biti deploy 完成第一个文档站。 ## 准备 - Node.js **22.13** 或更高版本(`node -v` 确认)。 - 一个空目录,或一个已有的 Fern / Mintlify 文档项目。 - 一个 ButterIX 账号和组织 API Key:预览、检查与发布都在平台上进行。 ## 四步上线 ### 安装 CLI CLI 的包名是 `bitidocs`,命令名是 `biti`。 ```bash npm npm install -g bitidocs ``` ```bash pnpm pnpm add -g bitidocs ``` ```bash 在 ButterIX 仓库内 # 仓库根目录的 package.json 提供了 biti 脚本,无需全局安装 pnpm biti --help ``` 安装后运行 `biti --version` 确认。 ### 创建项目 ```bash biti init my-docs --title "Acme 文档" ``` `biti init` 会生成以下文件(目标目录已有 `docs.yml` 时会拒绝覆盖): ``` my-docs/ docs.yml pages/ introduction.mdx quickstart.mdx assets/ logo.svg AGENTS.md .gitignore ``` 已有 OpenAPI 规范?加上 `--openapi` 会把它复制为 `openapi.yml` 并生成「API Reference」标签页: ```bash biti init my-docs --openapi ./openapi.yaml ``` ### 登录并预览 ```bash cd my-docs biti login --token biti_xxxxxxxxxxxxxxxx biti dev ``` API Key 在控制台创建,见 [CLI 部署与 API Key](https://docs.butterix.com/guides/deploy/cli-deploy.md)。打开终端里打印的地址(默认 `http://localhost:3000`):页面由 ButterIX 平台渲染,biti 把改动同步上去,保存文件后浏览器自动刷新;只改 CSS 时只替换样式表,不整页刷新。这个预览只能在本机打开,搜索与 Ask AI 在发布后的站点上可用。 > **Note** > > 端口被占用时用 `biti dev --port 3100`。 ### 发布 ```bash biti deploy --site acme-payments ``` CLI 把项目上传到平台,构建完成后打印线上地址。见 [CLI 部署与 API Key](https://docs.butterix.com/guides/deploy/cli-deploy.md)。 ## 写下第一页 在 `pages/` 下新建 `guides/authentication.mdx`: ````mdx title="pages/guides/authentication.mdx" --- title: 认证 subtitle: 所有请求都需要在 Authorization 头中携带 API Key。 --- 不要把 API Key 提交到代码仓库。 ## 获取密钥 在控制台的 **设置 → API Keys** 中创建密钥,然后: ```bash curl https://api.example.com/v1/me \ -H "Authorization: Bearer $ACME_KEY" ``` ```` 再把它加到 `docs.yml` 的导航里: ```yaml title="docs.yml" {7-9} navigation: - section: Get started contents: - page: Introduction path: pages/introduction.mdx - page: Quickstart path: pages/quickstart.mdx - page: 认证 path: pages/guides/authentication.mdx slug: authentication ``` > **Info** > > 页面的 URL 默认由导航里的标题生成。标题是中文时请显式写 `slug`,否则 URL 会包含中文字符。规则见[导航](https://docs.butterix.com/guides/configuration/navigation.md#slug-规则)。 ## 提交前检查 ```bash biti check ``` `biti check` 会在平台上加载配置、解析每一页并渲染一遍,报告配置错误、缺失的页面、断开的链接、未知组件和缺失的资源文件。CI 或编码 Agent 中用 `--json` 获取机器可读的结果,用 `--strict` 把警告也当作错误: ```bash biti check --json --strict ``` ## 下一步 [**项目结构**](https://docs.butterix.com/guides/get-started/project-structure.md) 每个目录和文件的用途。 [**写作**](https://docs.butterix.com/guides/writing/markdown.md) Markdown、代码块、图片与组件。 [**导入 OpenAPI**](https://docs.butterix.com/guides/api/openapi.md) 从规范生成 API 参考。 --- # 核心概念 > ButterIX 的渲染管线、站点模型(标签页、分区、页面)、变体(产品 × 版本 × 语言)以及静态产物与动态运行时的分工。 ## 渲染管线 一次构建从读取 `docs.yml` 开始,到写出静态目录结束。整个过程**不执行任何作者代码**。 ```mermaid flowchart LR A["docs.yml
pages/*.mdx
openapi.yml"] --> B["@bitidocs/core
配置 · 导航 · MDX 安全子集"] B --> C["@bitidocs/builder
Shiki 预高亮 · 逐页渲染"] C --> D["@bitidocs/ui
React 服务端渲染 → HTML"] D --> E["静态产物
HTML · .md · llms.txt
sitemap · 搜索索引"] E --> F["运行时
Ask AI · MCP · 试调代理
反馈 · 统计"] ``` | 阶段 | 包 | 做什么 | | --- | ------------------- | --------------------------------------------------------------------------------- | | 解析 | `@bitidocs/core` | 加载并校验 `docs.yml`(也能读取 `docs.json`),解析导航,把 MDX 解析成语法树并安全求值属性 | | API | `@bitidocs/openapi` | 解析、升级(Swagger 2 / OAS 3.0 → 3.1)并解引用 OpenAPI,生成示例与 9 种语言的代码片段 | | 构建 | `@bitidocs/builder` | 用 Shiki 预先高亮所有代码块(浅色 / 深色双主题),逐页渲染,写出 HTML、Markdown、`llms.txt`、站点地图、Pagefind 搜索索引 | | 渲染 | `@bitidocs/ui` | React 服务端渲染(`renderToStaticMarkup`),输出零水合的静态 HTML | | 浏览器 | `@bitidocs/client` | 一个很小的入口脚本:无刷新导航、主题切换、交互组件;搜索、Ask AI、试调等重型浮层按需加载 | | 运行时 | `@bitidocs/runtime` | 静态文件分发 + 动态端点,由托管平台提供 | ## 站点模型 导航由三层组成:
标签页(tab) 显示在页头的一级入口,例如本站的「指南」「组件」「API 参考」「更新日志」。在 `docs.yml` 的 `tabs:` 中声明,在 `navigation:` 中用 `- tab: ` 引用。标签页可以有自己的 URL 段(`slug`),也可以用 `skip-slug: true` 省略。
分区(section) 侧栏里的分组,可以无限嵌套。分区可以有概览页(`path`),可以默认折叠(`collapsed`),并默认为下面的页面贡献一段 URL。
页面与其他节点 `page`(一个 MDX 文件)、`link`(外部或站内链接)、`folder`(按目录自动生成)、`api`(从 OpenAPI 生成一组端点页面)、`changelog`(按日期文件生成更新日志)。
完整写法见[导航](https://docs.butterix.com/guides/configuration/navigation.md)。 ## 变体:产品 × 版本 × 语言 同一份导航可以被展开成多个**变体**。每个变体有自己的 URL 前缀: | 维度 | 配置 | URL 前缀示例 | 默认项 | | -- | ------------------------------ | -------- | ----------- | | 语言 | `languages:` | `/en` | 默认语言没有前缀 | | 产品 | `products:` | `/sdk` | 第一个产品也有自己的段 | | 版本 | `versions:`(或产品下的 `versions:`) | `/v0` | 第一个版本没有前缀 | 前缀按 `basepath → 语言 → 产品 → 版本` 的顺序拼接。例如本站: - 中文 v1:`/guides/get-started/quickstart` - 英文 v1:`/en/guides/get-started/quickstart` - 中文 v0:`/v0/guides/get-started/quickstart` 不同变体中**标签页 id、分区标题和页面标题都相同**的页面被视为同一页面:语言切换器、版本切换器会直接跳到对应页,构建器据此输出 `hreflang` 和旧版本的 canonical。 ## 静态产物与运行时 ### 静态产物(总是有) - 每页一个 `index.html` 与一个 `.md` - `llms.txt`、`llms-full.txt`(每种语言一份) - `sitemap.xml`、`robots.txt`、`_redirects`、`404.html` - Pagefind 搜索索引、OpenAPI 规范与 API 目录、skills - 更新日志的 RSS - 预压缩的 `.br` / `.gz` ### 运行时 - `/_biti/ai/chat`:Ask AI(SSE 流式回答) - `/_mcp/server`:站点 MCP 服务器 - `/_biti/proxy`:API 试调代理 - `/_biti/feedback`:「这页有帮助吗」 - `/_biti/e`:页面统计事件 - 按 `Accept: text/markdown` 返回 Markdown,缺页时返回 Markdown 404 静态产物负责浏览与搜索,运行时在此之上叠加动态能力。托管平台为每个站点提供运行时。 ## 安全模型 ButterIX 是多租户平台,任何人上传的文档都会在同一套服务上构建。因此 MDX 只支持一个**安全子集**:可以使用组件和字面量属性,但不能 `import` 任意模块、不能写函数、不能运行脚本。原因与细节见[安全子集](https://docs.butterix.com/guides/writing/safe-mdx.md)。 > **Note** > > 站点级的自定义 `css` / `js`(在 `docs.yml` 中声明)仍然可用,它们作为普通的 `` 与 ` ``` | 输出 | 来源 | | ----------------------- | --------------------------------------------------------------------------------- | | `` | `seo.title-template`(默认 `{page} \| {site}`);页面标题可用 frontmatter `og:title` 覆盖 | | description | frontmatter `description` → `og:description` → `subtitle` → 正文摘要 | | keywords | frontmatter `keywords` | | `og:image` | frontmatter `og:image` → `seo.og-image`;有图片时 Twitter 卡片自动变为 `summary_large_image` | | `article:modified_time` | frontmatter `last-updated` | | `robots` | 页面 `noindex`、导航中的 `noindex`、`seo.noindex` 或预览部署时输出 `noindex, nofollow` | 字段说明见[页面元数据](https://docs.butterix.com/guides/configuration/frontmatter.md#seo)与 [docs.yml › SEO](https://docs.butterix.com/guides/configuration/docs-yml.md#seo)。 ## canonical - 默认是页面自身的绝对地址,域名使用站点的[主域名](https://docs.butterix.com/guides/deploy/custom-domains.md#生效后)。 - **旧版本页面**的 canonical 指向默认版本中的同一页面,避免多个版本的相似内容互相竞争排名。见[多版本](https://docs.butterix.com/guides/features/versions.md#同一页面在不同版本间的对应)。 - frontmatter `canonical-url` 可以手动指定。 ## 结构化数据 每页输出两段 JSON-LD: - `TechArticle`:标题、描述、地址、语言(`inLanguage`)、`dateModified`(设置了 `last-updated` 时)以及所属 `WebSite`。 - `BreadcrumbList`:由导航中的分区路径生成,与页面上的面包屑一致。 ## sitemap.xml `/sitemap.xml` 包含全部页面(所有语言与版本,`noindex` 页面与更新日志的日期详情页除外),每个地址都附带其他语言版本的 `xhtml:link`: ```xml title="sitemap.xml(节选)" <url> <loc>https://acme-payments-sites.butterix.com/guides/features/seo</loc> <xhtml:link rel="alternate" hreflang="zh" href="https://acme-payments-sites.butterix.com/guides/features/seo"/> <xhtml:link rel="alternate" hreflang="en" href="https://acme-payments-sites.butterix.com/en/guides/features/seo"/> </url> ``` ## robots.txt 与 AI 爬虫 默认的 `robots.txt` 允许所有爬虫,并声明站点地图: ```text title="robots.txt" User-agent: * Allow: / Sitemap: https://acme-payments-sites.butterix.com/sitemap.xml ``` ### 声明内容用途 `seo.content-signal` 在 `robots.txt` 中输出 `Content-Signal`,说明内容可以用来做什么。三项都是可选的布尔值,没写的不输出: ```yaml title="docs.yml" seo: content-signal: search: true # 建立搜索索引 ai-input: true # 作为 AI 回答的输入 ai-train: false # 训练模型 ``` ```text title="robots.txt" User-agent: * Content-Signal: search=yes, ai-input=yes, ai-train=no Allow: / ``` ### 禁止 AI 爬虫 设置 `seo.ai-crawlers: disallow` 后,会额外禁止以下 AI 训练与检索爬虫: - GPTBot - ChatGPT-User - OAI-SearchBot - ClaudeBot - Claude-User - Claude-SearchBot - anthropic-ai - PerplexityBot - Google-Extended - Applebot-Extended - CCBot - Bytespider - meta-externalagent ### 使用自己的 robots.txt ```yaml title="docs.yml" agents: robots-txt: robots.txt # 相对于 docs.yml ``` 文件内容原样发布,`ai-crawlers` 与 `content-signal` 不再起作用。 `seo.noindex: true` 或预览部署时,`robots.txt` 始终为 `Disallow: /`,自己的文件也不例外。 > **Info** > > 文档通常希望被 AI 读到:开发者越来越多地通过 ChatGPT、Claude、Cursor 了解一个 API。ButterIX 默认允许 AI 爬虫,并提供 `.md` 与 `llms.txt` 让它们读得更准确,见 [Agent 友好](https://docs.butterix.com/guides/features/agents.md)。 ## 重定向 改版时用 `redirects` 保住旧链接的排名: ```yaml title="docs.yml" redirects: - source: /docs/getting-started destination: /guides/get-started/quickstart - source: /api/v1/:endpoint destination: /api-reference/:endpoint ``` - 默认 301 永久重定向,`permanent: false` 为 302。 - 跳转时保留查询参数;访问 `.md`、`.mdx` 地址时跳到目标页的 Markdown。 - 首页不是 `/` 时,根地址会自动 302 到首页。 ## URL 规范化 - 页面地址没有尾斜杠;运行时把 `/guides/` 308 重定向到 `/guides`,避免重复地址。 - 不存在的地址返回真正的 **404 状态码**和 `404.html`(带 `noindex`);请求的是 Markdown 时返回 [Markdown 404](https://docs.butterix.com/guides/features/agents.md#重定向与缺页)。 ## 性能 速度本身就是排名因素: - 零水合:页面不需要在浏览器端重新渲染。 - 代码高亮在构建时完成,图标合并为页面内 SVG sprite,不加载图标字体。 - 构建时预压缩 `.br` 与 `.gz`,运行时按 `Accept-Encoding` 直接返回。 - 带哈希的静态资源(样式、脚本、字体)使用一年的 `immutable` 缓存,HTML 每次校验。 ## 预览部署 预览部署(拉取请求、编辑器预览、`biti deploy --preview`)的每一页都带 `noindex`,`robots.txt` 禁止抓取,页面顶部显示「Preview」横幅,不会与生产站点争夺索引。 --- # Agent 友好 > ButterIX 面向 AI 与编码 Agent 的能力:每页的 .mdx 源文件、干净的 Markdown 与页面指令、Accept 内容协商、Markdown 404、页面操作与一键连接 MCP、llms.txt 与 llms-full.txt、站点 MCP 服务器(search_docs、get_page、list_pages、send_feedback)、托管 skills、API 规范与目录、链接参数,以及让编码 Agent 编辑文档的技能包与 biti check --json。 越来越多的开发者通过 AI 助手阅读文档、通过编码 Agent 编写集成代码。ButterIX 把这些读者当作一等公民: [**每页的 Markdown**](#每页的-markdown) `.mdx` 源文件或 `Accept: text/markdown` [**llms.txt**](#llmstxt) 整站索引与全文 [**MCP 服务器**](#站点-mcp-服务器) 在 IDE 里直接检索文档 [**Skills**](#托管-skills) 一条命令装进编码 Agent ## 每页的 Markdown 构建时每个页面都会额外输出一份干净的 Markdown:组件被转换为等价的 Markdown 结构(提示框变为引用块、代码组展开为多个代码块、标签页展开为小节……)。API 端点页包含参数与请求体的字段表、cURL 示例、每个状态码的响应字段与响应示例;引用端点的[片段组件](https://docs.butterix.com/components/endpoint-request-snippet.md)会展开成真实的代码与字段表。 正文与组件里的站内链接写成绝对地址并指向目标页的 `.md`(例如 `https://docs.acme.com/prices/basic.md`),图片与文件也是绝对地址,AI 单独拿到一页也能继续往下读。 获取方式: **加 .mdx 后缀** 在任意页面地址后加 `.mdx`,返回这一页的源文件,和作者写的一样,组件保持 MDX 原样: ```bash curl https://acme-payments-sites.butterix.com/guides/features/agents.mdx ``` 站点根页面对应 `/index.mdx`,`.md` 后缀跳转到 `.mdx`。接口页、更新日志这类自动生成的页面没有源文件,`.md` 与 `.mdx` 都返回干净的 Markdown。 **内容协商** 请求头 `Accept` 首选 `text/markdown` 时,运行时对同一地址直接返回 Markdown: ```bash curl https://acme-payments-sites.butterix.com/guides/features/agents \ -H "Accept: text/markdown" ``` HTML 响应同时带有 `Link: </guides/features/agents.md>; rel="alternate"; type="text/markdown"` 头,页面 `<head>` 中也有对应的 `<link rel="alternate" />`,Agent 可以据此发现 Markdown 版本。 **页面操作** 每个页面标题下方都有一组按钮: - **复制页面**:把 Markdown 复制到剪贴板,粘贴给任何 AI。 - **查看 Markdown**:在新标签页打开 `.md`。 - **更多**:在 ChatGPT 或 Claude 中打开(提示里附上本页 `.md` 的完整地址);连接 Claude Code(复制安装命令)、Cursor 与 VS Code(直接打开编辑器安装);复制 MCP 地址。 用 [`theme.page-actions`](https://docs.butterix.com/guides/configuration/docs-yml.md#主题) 选择显示哪些。站点关闭了 MCP 或受密码保护时,连接与复制 MCP 地址的几项不显示。 ### 页面指令 干净的 Markdown 开头有一段引用,告诉 Agent 怎样继续读: ```markdown > For the MDX source of any page, append .mdx to the page URL. > For a complete documentation index, see https://docs.acme.com/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.acme.com/_mcp/server. > If something on this page is wrong or missing, POST JSON {"page": "<page URL>", "message": "<what is wrong>"} to https://docs.acme.com/_biti/feedback/agent. ``` 所有页面都有,包括接口页与更新日志;索引地址按页面的语言给出,MCP 一行只在站点提供 MCP 服务器时出现,最后一行只在托管站点开启了[页面反馈](https://docs.butterix.com/guides/configuration/docs-yml.md#页面反馈)时出现,提交的内容见[分析 › 反馈](https://docs.butterix.com/guides/features/analytics.md#反馈)。用 `agents.page-directive` 换成自己的文字,写成空字符串则不输出: ```yaml title="docs.yml" agents: page-directive: | 先阅读 https://docs.acme.com/llms.txt。 示例代码优先使用 TypeScript。 ``` 有多个[版本或产品](https://docs.butterix.com/guides/features/versions.md)时,指令前还会注明本页属于哪个版本或产品,并列出其他版本、产品的索引地址。 指令只写在干净的 Markdown 里,源文件、网页、「复制页面」、`llms-full.txt` 与 Ask AI 都不包含它。 ### 重定向与缺页 - [重定向](https://docs.butterix.com/guides/features/seo.md#重定向)对 `.md`、`.mdx` 地址同样有效:最终跳到目标页的源文件,保留查询参数。 - 请求的 Markdown 不存在时,返回 404 状态码和一份 Markdown:列出地址最相近的页面,以及全部页面的索引。 ## llms.txt 构建时为每种语言生成两个文件(遵循 [llmstxt.org](https://llmstxt.org) 约定): | 文件 | 内容 | | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | | `/llms.txt` | 站点标题、摘要(`agents.llms-txt.description` 或 `description`),以及按标签页分组的全部页面链接(指向 `.md`)与一句话描述 | | `/llms-full.txt` | 全部页面的 Markdown 全文拼接,适合一次性放进上下文 | | `/en/llms.txt`、`/en/llms-full.txt` | 英文版 | | `/v0/llms.txt` 等 | 其他版本与产品各有一份索引,地址是它们的路径加 `/llms.txt`(隐藏的版本除外) | | `/changelog.md`、`/changelog/llms.txt` | 每个更新日志(或博客)各有一份:最新 20 条的 Markdown 全文,以及全部条目的索引,见[更新日志](https://docs.butterix.com/guides/configuration/changelog.md#面向-agent-的输出) | 根目录与各语言的 `llms.txt` 只包含默认版本、未隐藏、没有设 `noindex` 的页面;站点有 API 时,末尾的「Specifications」一节列出各规范的下载地址。`llms-full.txt` 同样不含 `noindex` 的页面。 ### 只取需要的部分 在地址后面加参数,去掉用不到的内容,给 AI 省一些上下文: | 参数 | 用在 | 去掉 | | ------------------------ | -------------------------- | ------------------ | | `?excludeSpec=true` | `llms.txt` | 「Specifications」一节 | | `?excludeChangelog=true` | `llms.txt`、`llms-full.txt` | 更新日志与博客 | 两个参数可以一起用。值写 `true`、`1` 或只写参数名都算开启。站点没有对应的内容时,`llms.txt` 开头不会提到这个参数,加了也返回完整文件。 本站的 [`/llms.txt`](https://docs.butterix.com/llms.txt) 开头是这样的: ```markdown title="llms.txt" # ButterIX > ButterIX 的官方文档:docs.yml 配置、MDX 组件、OpenAPI 参考、多版本与多语言…… For the MDX source of any page, append `.mdx` to its URL. Full content: https://docs.butterix.com/llms-full.txt ## 指南 - [ButterIX 文档](https://docs.butterix.com/guides/get-started/introduction.md): ButterIX 是一个从 OpenAPI 与 MDX 生成 API 文档站的平台…… - [快速开始](https://docs.butterix.com/guides/get-started/quickstart.md): 安装 biti CLI…… ``` ## 站点 MCP 服务器 每个托管站点都在 `/_mcp/server` 提供一个 [Model Context Protocol](https://modelcontextprotocol.io) 服务器,使用 Streamable HTTP 传输(JSON 响应)。公开站点无需认证,受密码保护的站点见[访问控制](https://docs.butterix.com/guides/deploy/access-control.md#ai-工具与程序的访问)。它提供以下工具: - `search_docs` (tool): 在站点中检索,返回最相关的若干段落及其地址。参数:`query`(必填,自然语言或关键词)、`limit`(1–20,默认 6)、`locale`(语言代码,如 `en`)。 - `get_page` (tool): 按地址获取页面的完整 Markdown。参数:`path`(页面路径或完整 URL,例如 `/guides/get-started/quickstart`)。 - `list_pages` (tool): 列出一种语言全部页面的标题、地址与描述。参数:`locale`。 - `send_feedback` (tool): 告诉文档团队某页写错了、过时了或缺了内容。参数:`page`(页面地址)、`message`(必填,最多 2000 字)。只在托管站点开启了页面反馈时提供;每个地址每分钟最多 5 次。 站点有多种语言时才有 `locale` 参数。不传时,`search_docs` 按问题的语言选择,判断不出时用默认语言,该语言没有结果才给出其他语言的;`list_pages` 列出默认语言。传入站点没有的语言会返回错误,并列出可用的语言。 检索索引只包含默认版本的页面。每个 IP 每分钟最多 120 次调用。 ### 在编码工具中配置 把下面的地址换成你的文档站地址(托管站点的地址可在控制台站点概览页「复制 MCP 地址」获得): ```bash Claude Code claude mcp add --transport http acme-docs https://docs.acme.com/_mcp/server ``` ```jsonc Cursor // ~/.cursor/mcp.json 或项目中的 .cursor/mcp.json { "mcpServers": { "acme-docs": { "url": "https://docs.acme.com/_mcp/server" } } } ``` ```jsonc VS Code // .vscode/mcp.json { "servers": { "acme-docs": { "type": "http", "url": "https://docs.acme.com/_mcp/server" } } } ``` 配置后,在对话中直接提问(例如「用 acme-docs 查一下如何验证 Webhook 签名」),Agent 会先调用 `search_docs`,再用 `get_page` 读取完整页面。 ### 手动调用 ```bash curl -X POST https://docs.acme.com/_mcp/server \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"search_docs","arguments":{"query":"自定义域名","limit":3}}}' ``` 完整的请求与响应格式见 API 参考中的 [MCP 服务器](https://docs.butterix.com/api-reference/runtime/mcp.md)。 ### 关闭 MCP ```yaml title="docs.yml" agents: mcp: false ``` 关闭后 `/_mcp/server` 返回 404,页面菜单、页面指令与 Ask AI 也不再提到它。 > **Info** > > 想让编码助手查询站点的部署、分析、提问与反馈,用[组织 MCP 服务器](https://docs.butterix.com/guides/deploy/platform.md#组织-mcp-服务器)。 **让 Agent 用你的文档写代码** ```text 使用 ButterIX 文档的 MCP 服务器,查找如何通过平台 API 创建预览部署,然后写一个 Node.js 脚本:打包当前目录、上传为预览部署,并轮询直到部署完成后打印预览地址。 ``` ## 托管 skills 把 skill 放进项目根目录(`docs.yml` 旁边)的 `.well-known/agent-skills/`,随站点一起发布: ``` docs/ docs.yml .well-known/ agent-skills/ acme-payments/ SKILL.md references/ errors.md ``` ```markdown title="SKILL.md" --- name: acme-payments description: 用 Acme Payments API 创建与查询付款。编写支付集成代码时使用。 --- # 集成 Acme Payments …… ``` 读者一条命令即可安装: ```bash npx skills add https://docs.acme.com ``` 构建时自动生成索引 `/.well-known/agent-skills/index.json`,`SKILL.md` 在 `/.well-known/agent-skills/<name>/SKILL.md`。含有其他文件的 skill 会另外打包成一个 `.tar.gz`,索引指向它。自己放一份 `index.json` 时使用你的。 `biti check` 与构建会校验: - 每个 skill 一个文件夹,里面有 `SKILL.md`;没有时警告,并且不进索引; - `name` 与文件夹同名,只用小写字母、数字和单个连字符,最多 64 个字符; - `description` 必填,最多 1024 个字符; - 全部 skill 文件合计不超过 20 MB; - 自己的 `index.json` 必须是有效的 JSON,并有 `skills` 列表。 ## API 规范与目录 有 API 参考的站点会发布规范文件 `/openapi.json` 与 `/openapi.yaml`,以及 API 目录 `/.well-known/api-catalog`,Agent 不用解析页面就能找到全部接口。见[下载规范](https://docs.butterix.com/guides/api/openapi.md#下载规范)。 ## 链接参数 | 参数 | 效果 | | ------------- | ---------------------------------------------------------------------------- | | `?ask-ai` | 打开页面时展开[提问面板](https://docs.butterix.com/guides/features/ask-ai.md#用链接打开提问面板) | | `?ask-ai=问题` | 同上,并在输入框里写好问题,由读者自己发送 | | `?search=关键词` | 打开搜索框并搜索这些词 | 参数值要做 URL 编码,可以加在任意页面地址后面。 ## 让编码 Agent 编辑你的文档 ButterIX 的设计让 Claude Code、Cursor 等 Agent 可以安全地修改文档项目: - **编写技能包**:`biti init --skill` 把它写入 `.claude/skills/butterix-docs`,也可以用 `npx skills add https://docs.butterix.com` 安装。其中有写作规则、工作流程,以及配置与全部组件的参考。 - `biti init` 生成 `AGENTS.md`,说明内容在哪里、改完要做什么。 - `biti check --json` 输出机器可读的诊断(错误码、文件、行号、提示),Agent 可以据此自我修正,`--strict` 把警告也视为错误。 - `biti components --json` 列出全部组件与属性,Agent 不需要猜测组件名。 - MDX 只允许字面量属性(见[安全子集](https://docs.butterix.com/guides/writing/safe-mdx.md)),Agent 写出的内容不会执行任意代码。 ```json title="biti check --json 的输出(节选)" { "ok": false, "pages": 94, "diagnostics": [ { "severity": "warning", "code": "link/broken", "message": "Link target not found: ./quickstrat.mdx", "file": "pages/introduction.mdx" } ] } ``` ## 了解 AI 流量 托管平台会区分人类、AI 爬虫与 AI 助手的访问,并单独统计 `.md` 请求、索引与规范文件的请求和 MCP 调用,见[分析](https://docs.butterix.com/guides/features/analytics.md)。 --- # Ask AI > ButterIX 的 Ask AI:读者能问什么、回答依据什么、如何选择模型与填写密钥、额外指引、指定问答、内容来源、docs.yml 中的 ai 配置、隐藏个人信息、用量限制,以及提问记录与解决率。 ## 读者看到什么 托管站点的页头有一个 **Ask AI** 按钮,每个页面标题下方还有「就本页提问」。对话面板中: - 回答逐字出现,可以随时停止; - 句子后面的 `[1]`、`[2]` 链接到被引用的文档段落,回答下方列出来源; - 支持多轮追问,对话在页面间跳转时保留; - 每条回答都可以点赞或点踩,评价记入[提问记录](#提问记录)。 在你自己的网站或产品里也可以放同样的助手,见[网页嵌入](https://docs.butterix.com/guides/features/ask-ai-embed.md)。 ### 用链接打开提问面板 在任意页面地址后加上 `?ask-ai`,打开页面时会同时展开提问面板,适合放在官网、产品界面或邮件里: ```text https://docs.example.com/?ask-ai https://docs.example.com/guides/quickstart?ask-ai ``` `?ask-ai=问题` 会在输入框里预先写好问题(最多 512 个字符,要做 URL 编码),由读者确认后自己发送: ```text https://docs.example.com/?ask-ai=How%20do%20I%20verify%20webhooks%3F ``` ## 它怎么回答 Ask AI 先理解问题,在你的文档里搜索,再根据找到的内容作答: - **听得懂口语**:读者不需要知道文档里的正式说法,也可以用其他语言提问; - **可以加工文档内容**:翻译、总结、换成其他编程语言或工具的写法,例如文档只有 Cursor 的配置时,要一份 Codex 的版本。这类回答会注明不是文档原文; - **能帮读者接入**:知道本站 [MCP 服务器](https://docs.butterix.com/guides/features/agents.md#站点-mcp-服务器)的地址,可以直接给出接入命令; - **不编造**:文档没有写的会直说,并给出最接近的页面; - **不跑题**:与你的产品和文档无关的问题会被礼貌拒绝;示例数据、文件名、模板里要填的其他主题内容,用占位符代替。 回答使用**默认版本**、未隐藏的页面,以及你添加的[指定问答](#指定问答)与[内容来源](#内容来源)。 > **Tip** > > 在页面 frontmatter 里写清楚 `description`,并把读者常用的别称放进 `keywords`,AI 就更容易找到这一页。 ### 在回答里显示图片 回答默认只有文字。希望读者在回答里直接看到某张图片时(例如客服群二维码、架构图),给它的 `<img />` 加上 `askAi`: ```mdx <img src="/assets/support-qr.png" alt="用户群二维码" width="240" askAi /> ``` - 回答用到这张图片所在的段落、读者又需要看到它时,图片直接显示在回答里; - `alt`(或 `caption`)要写清楚图片是什么,AI 靠它判断要不要用;两者都没有时构建会给出提示,这张图片不会被使用; - 设了 `width` 时按这个宽度显示;点击图片在新标签页打开原图; - 没有 `askAi` 的图片不会显示。一条回答最多显示 4 张,目前只支持图片。 Markdown 写法的图片把 `askAi` 写在标题的位置,单引号、双引号都可以;它只是标记,不会当作图片标题显示: ```mdx ![用户群二维码](/assets/support-qr.png 'askAi') ``` 在可视化编辑器里点 `<img />` 图片,勾选「Ask AI 回答里可以显示」即可。[网页嵌入](https://docs.butterix.com/guides/features/ask-ai-embed.md)的助手同样生效。 ## 提供商与模型 **Anthropic** 默认模型 `claude-opus-5-5`。 | 模型 | id | 上下文 | 价格(输入 / 输出,每百万 tokens) | | ------------------- | ------------------- | --- | ---------------------- | | Claude Opus 5.5(推荐) | `claude-opus-5-5` | 1M | \$4 / \$20 | | Claude Sonnet 5.5 | `claude-sonnet-5-5` | 1M | \$2 / \$10 | | Claude Haiku 5.5 | `claude-haiku-5-5` | 1M | \$0.1 / \$0.5 | | Claude Fable 5.2 | `claude-fable-5-2` | 1M | \$8 / \$40 | **DeepSeek** 默认模型 `deepseek-flash`,也可以选择 `deepseek-v4-pro`。 **OpenRouter** 可以使用 OpenRouter 上的任意模型,默认 `~deepseek/deepseek-flash-latest`(始终指向 DeepSeek Flash 的最新版本)。 控制台会列出你的密钥可用的模型与价格,列表里没有的也可以直接输入模型 id。 ## 在控制台中配置 打开站点「设置」里的 **Ask AI** 区块: ### 启用并选择提供商与模型 启用后页面上出现提问入口,关闭后自动隐藏,都不需要重新部署。 ### 填写密钥 填写提供商的 API Key,或使用平台管理员配置的密钥。密钥会先验证再加密保存,只用于这个站点的 Ask AI 与 AI 翻译。 ### 调整推理强度与指引 推理强度越高回答越周到,但更慢、更贵,文档问答建议「低」。额外指引可以设定语气、强调产品名,也可以收窄或放宽回答范围,例如「也可以回答通用的 HTTP 问题」。 ### 测试提问 向线上文档提一个问题,查看回答、来源与耗时。 同样的操作可以通过 [Ask AI 设置 API](https://docs.butterix.com/api-reference/ai/update-ai-settings.md) 完成。 ## 答不上时转人工 在站点「设置」的**答不上时转人工**里打开,并填写支持页面、支持邮箱或两者。默认关闭;没有填写联系方式时不能开启。改动立即生效,不需要重新部署,也可以通过 [Ask AI 设置 API](https://docs.butterix.com/api-reference/ai/update-ai-settings.md) 修改(需要 admin 角色)。 开启后,下面几种情况会在回答下方显示联系方式: - 文档没有答案,或只答上一部分; - 回答生成失败,或当天的提问次数已用完; - 读者给回答点了踩。 | 按钮 | 作用 | | ---- | --------------------------------- | | 联系支持 | 打开支持页面:`https://` 地址或 `/` 开头的站内路径 | | 发送邮件 | 打开读者自己的邮件程序,正文已写好问题与所在页面,由读者确认后发送 | | 复制对话 | 复制整段问答与页面地址,方便粘贴到工单或聊天里 | 与产品无关、被婉拒的提问不显示。平台不会替读者发送任何内容;开启了[隐藏个人信息](#隐藏个人信息与密钥)时,写进邮件与复制的内容也会处理。 ## 指定问答 有些问题需要固定的答案,比如定价、支持渠道或尚未写进文档的限制。在站点的「Ask AI → 指定问答」里添加,也可以从「对话」里读者的提问直接创建: - **问题**:1–20 个示例问法,每个最多 500 个字符。读者的问题与其中任何一个相近时采用; - **回答**:Markdown,最多 8000 个字符。 相近时 AI 优先按你写的回答作答,与文档不一致时也以它为准,不标引用。每个站点最多 200 条,可以单独停用;保存后很快生效,不需要重新部署。需要 editor 角色。 也可以通过 [API](https://docs.butterix.com/api-reference/ai/create-guidance.md) 管理: ```bash curl -X POST https://api.butterix.com/v1/sites/acme-payments/guidance \ -H "Authorization: Bearer $BITI_TOKEN" \ -H "Content-Type: application/json" \ -d '{"context":["怎么联系支持?","有客服吗"],"document":"发邮件到 support@acme.com,工作日 4 小时内回复。"}' ``` ## 内容来源 在站点的「Ask AI → 内容来源」里添加文档以外的内容,供 Ask AI 一并参考。回答的引用会链接到来源的地址。来源只用于 Ask AI,不出现在站内搜索与 MCP 中。 **Markdown 文档** 粘贴或从文件读入一份 Markdown(最多 50 万字符),填写标题与引用地址。 **网站** 填写一个公开网站的起始地址,平台沿着页面里的链接抓取: - 只抓同一主机上、起始地址所在目录下的页面;也可以指定路径(如 `/help/`),并排除某些路径; - 遵守网站的 `robots.txt`(名称为 `ButterIXBot`)与页面的 `noindex`、`nofollow`; - 页数上限 1–500,默认 100; - 按周期重新抓取:不刷新、每天、每周(默认)或每月,也可以随时手动刷新。抓取失败时继续使用上次的内容。 只能抓取不需要登录的公网地址。 每个站点最多 20 个来源,每个网站的正文合计最多 500 万字符。需要 editor 角色,也可以通过 [API](https://docs.butterix.com/api-reference/ai/create-source.md) 管理。 ## 在 docs.yml 中配置内容 欢迎语、推荐问题等写在 `docs.yml` 里,随文档一起版本化: ```yaml title="docs.yml" ai: enabled: true greeting: 你好!我可以回答关于 Acme API 的问题。 suggestions: - 如何创建第一笔付款? - Webhook 签名怎么验证? system-prompt: 回答时优先给出 TypeScript 示例;涉及金额时提醒单位是「分」。 disclaimer: 回答由 AI 生成,涉及合同条款请以正式文本为准。 mask-pii: true ``` `ai.system-prompt` 与控制台中的「额外指引」会同时生效。`ai.enabled: false` 会关闭 Ask AI。 `ai.disclaimer` 替换面板顶部的提示文字。欢迎语、推荐问题与提示文字都可以在 [`labels.yml`](https://docs.butterix.com/guides/features/i18n.md#labelsyml翻译导航与站点文字) 里翻译。 ### 隐藏个人信息与密钥 `ai.mask-pii: true` 会在读者发送前,把问题里的个人信息与密钥换成 `[EMAIL]` 这样的占位符,并请读者确认后再次发送。只想隐藏某几类时写成列表: ```yaml title="docs.yml" ai: mask-pii: [email, phone, secret] ``` | 类别 | 内容 | | ----------- | -------------------------- | | `email` | 邮箱地址 | | `phone` | 电话号码 | | `id-number` | 居民身份证号 | | `bank-card` | 银行卡号 | | `secret` | API Key、令牌、私钥,以及写明是密码或密钥的值 | 交给模型和写入提问记录的内容同样经过处理。 ## 用量限制 | 项目 | 限制 | | ---- | -------------------------------------------------- | | 单个访客 | 每分钟 12 次、每天 200 次 | | 单个问题 | 最多 512 个字符。Ask AI 回答文档问题,报错或代码较长时只问关键的部分 | | 单个站点 | 24 小时内 200 次,可在 Ask AI 设置中调整或取消。达到上限后读者仍能看到相关文档的链接 | | 组织 | 「AI 提问 / 月」配额用完后,暂停到下个月 | 平台内置了防滥用措施,只接受来自你站点页面的提问;同一位读者短时间内反复问无关内容时,会暂停带上文作答,再继续则需要等一会儿。 组织的[定时任务](https://docs.butterix.com/guides/features/automations.md)也使用同一项配额,每次运行计 10 次。 ## 提问记录 每次提问的问题、回答、来源、所在页面与地区可在站点的「Ask AI → 对话」中查看(鼠标悬停在页面上显示完整地址,点开一条显示全部信息),按结果、评价与有无来源筛选,并导出为 CSV。每条记录有: - **结果**:已解决、部分解决、文档缺失、无关、越界或未完成。「越界」是回答写了站点主题以外的内容,这一轮不会作为后续追问的上文; - **读者的评价**:赞、踩或没有评价。 **解决率** = 已解决 ÷(已解决 + 部分解决 + 文档缺失),与站点无关、越界和未完成的提问不计入。 最值得看的是「文档缺失」「部分解决」、被踩的,以及没有引用任何来源的回答——它们就是要补写的内容,或者适合加成[指定问答](#指定问答)。[文档缺口](https://docs.butterix.com/guides/features/console-agent.md#文档缺口)会把它们按主题归并。 同样的数据可以通过 API 获取,见[提问记录](https://docs.butterix.com/api-reference/analytics/list-questions.md)、[导出 CSV](https://docs.butterix.com/api-reference/analytics/export-questions.md)与[解决率](https://docs.butterix.com/api-reference/analytics/question-summary.md)。 --- # 网页嵌入 Ask AI > 把 ButterIX 的 Ask AI 嵌入其他网站:允许的来源、按钮与输入框两种入口、亮暗两套强调色与颜色模式、面板大小与位置、用 window.ButterIX 从代码打开与修改选项、随提问带上读者所在页面的地址与面包屑、内容安全策略(CSP)需要放行的指令,以及适用范围与限制。 嵌入的助手与文档站上的 [Ask AI](https://docs.butterix.com/guides/features/ask-ai.md) 完全相同:同样的模型、指引、指定问答与内容来源,提问记入同一份[提问记录](https://docs.butterix.com/guides/features/ask-ai.md#提问记录),也使用同样的用量限制。 ## 开始使用 ### 填写允许的来源 在站点的「Ask AI → 嵌入」里填写可以嵌入助手的网站(需要 admin 角色),例如 `https://app.acme.com`;`https://*.acme.com` 表示任意子域名。最多 20 个,必须是 https,只有 `localhost` 可以用 http。保存后立即生效。 也可以通过 [API](https://docs.butterix.com/api-reference/ai/update-embed.md) 设置。没有填写来源时不能嵌入。 ### 加入脚本 复制同一页的嵌入代码,粘贴到网页的 `</body>` 之前: ```html <script src="https://docs.acme.com/_biti/embed.js" async></script> ``` 页面上会出现控制台里设置的默认入口(没设置过时是右下角的提问按钮),点击打开面板。想在这个网页上固定用按钮或输入框,加上 `data-trigger="button"` 或 `data-trigger="bar"`。 ## 入口样式 `data-trigger` 决定读者从哪里打开面板: - `button`:右下角的悬浮按钮,显示图标和「问 AI」。 - `bar`:屏幕底部居中的输入框。读者直接在里面输入问题,按回车后面板展开并立即回答。已经有对话时,点进输入框会直接打开面板;还没有对话时,输入框上方浮现最多三个推荐问题(取自 [`ai.suggestions`](https://docs.butterix.com/guides/features/ask-ai.md)),点一下即可提问。 - `none`:不显示入口,只用[代码](#从代码打开)打开。 - CSS 选择器(如 `#ask-docs`):点击页面上匹配的元素时打开。 不写 `data-trigger` 时,用站点「Ask AI → 嵌入 → 外观」里设置的默认入口样式(没设置过时是按钮)。写了就以网页为准,不受控制台影响。例如整个网站用按钮,只在帮助中心页用输入框: ```html <script src="https://docs.acme.com/_biti/embed.js" data-trigger="bar" async></script> ``` 面板从入口所在的位置展开。读者可以: - 拖动面板的上边、左右两边或上方两角调整大小,双击边缘恢复默认大小和位置; - 按住面板的标题栏移动面板; - 用面板右上角的按钮切换亮色和暗色,或把面板放大到接近整屏高度; - 把入口拖到屏幕上任意位置:按钮直接按住拖动,输入框按住左侧的星标拖动;双击按钮或星标放回网站设定的位置。 这些调整会在读者的浏览器里保留一天,期间再打开面板时沿用。在手机等窄屏上,面板改为从底部弹出的抽屉。 ## 皮肤 有两套皮肤: - **经典**(默认):简洁的实色入口与面板。 - **极光**:入口与面板是毛玻璃质感,边缘有缓缓流动的彩色光;读者聚焦输入框时光变亮,面板展开时有一次光晕。 两套皮肤在 AI 回答的过程中,面板边缘都会向内亮起一圈旋转的霓虹光,回答结束后淡出。系统开启「减少动态效果」时光效静止。 皮肤和下面的入口样式、颜色模式、强调色,都可以在站点的「Ask AI → 嵌入 → 外观」里设置,保存后立即生效,不用重新部署,也不用改网站上的代码。 ## 选项 也可以在网页上用脚本标签的 data 属性指定。写了的属性以网页为准,没写的沿用控制台的外观设置: ```html <script src="https://docs.acme.com/_biti/embed.js" data-trigger="bar" data-skin="aurora" data-theme="light" data-color="#7c5cff" data-color-dark="#9e8aff" data-width="520" data-height="680" data-left="50" data-bottom="32" data-breadcrumb="控制台 / 存储桶 / 设置" async ></script> ``` - `data-trigger` ("button" | "bar" | "none" | string): 入口样式:`button` 按钮,`bar` 输入框,见[入口样式](#入口样式)。写了就以这里为准;不写时用控制台设置的默认入口样式。 - `data-skin` ("classic" | "aurora"): 皮肤,见[皮肤](#皮肤)。默认 `classic`。 - `data-theme` ("dark" | "light" | "auto", default: dark): 颜色模式。`auto` 跟随访客的系统设置。读者在面板里切换过时,以读者的选择为准,直到网站再次修改这个属性。 - `data-color` (string): 亮色模式的强调色,十六进制,如 `#7c5cff`。用于入口图标、发送按钮和面板里的强调色。不写时使用文档站亮色模式的强调色。 - `data-color-dark` (string): 暗色模式的强调色,十六进制。不写时:写了 `data-color` 就由它推出(太暗时自动提亮),否则使用文档站暗色模式的强调色。 - `data-width` (number, default: 480): 面板展开时的默认宽度(像素),360 到 1600。 - `data-height` (number, default: 640): 面板展开时的默认高度(像素),440 到 1600。屏幕放不下时自动缩小;放不下最小尺寸时改为从底部滑出的抽屉。 - `data-left` (number, default: 按钮 100,输入框 50): 入口离屏幕左边的位置,按屏幕宽度的百分比计,0 到 100:`0` 靠最左,`50` 居中,`100` 靠最右。入口始终完整留在屏幕内。也可以在「Ask AI → 嵌入 → 嵌入代码」里填写,复制的代码会带上这个属性。 - `data-bottom` (number, default: 20): 入口离屏幕底边的距离(像素),最小 16。可以用来避开网页底部固定的栏或其他浮动按钮;推荐问题和展开的面板随入口一起上移。屏幕放不下时自动下移,入口始终完整留在屏幕内。也可以在「Ask AI → 嵌入 → 嵌入代码」里填写,复制的代码会带上这个属性。 - `data-label` (string): 按钮上的文字,或输入框里的提示文字,最多 40 个字符。按钮写成空字符串时只显示图标。 - `data-lang` (string): 面板的语言,取文档站支持的语言之一。不写时使用网页 `<html lang>` 的语言,都不匹配时用文档站的默认语言。 - `data-breadcrumb` (string): 读者当前所在页面的面包屑,例如 `控制台 / 存储桶 / 设置`,最多 200 个字符。不写时使用网页当前的标题。详见[读者所在的页面](#读者所在的页面)。 颜色太浅或太深时,用作图标和描边的地方会自动调整到在当前背景上看得清。 这些属性随时可以修改,修改后立即生效。例如跟随网站自己的主题开关切换亮色和暗色: ```js document.querySelector('script[src$="/_biti/embed.js"]').dataset.theme = "dark"; // 或者 ButterIX.configure({ theme: "dark" }); ``` ## 从代码打开 脚本加载后提供 `window.ButterIX`: ```js ButterIX.open(); // 打开面板 ButterIX.open({ question: "如何验证 Webhook 签名?" }); // 打开并写好问题,由读者自己发送 ButterIX.close(); ButterIX.toggle(); ButterIX.configure({ theme: "light", color: "#0ea5e9", left: 20 }); // 修改选项,写 null 恢复默认 ``` `configure` 接受的键与 data 属性相同(去掉 `data-` 前缀,连字符改为驼峰):`trigger`、`skin`、`theme`、`color`、`colorDark`、`width`、`height`、`left`、`bottom`、`label`、`lang`、`breadcrumb`。 ## 读者所在的页面 每次提问时,面板会带上读者此刻所在网页的地址和面包屑。AI 据此理解"这里""这个页面""这个设置"指的是什么,优先回答与这个页面相关的内容。 面包屑默认取网页当前的标题(单页应用切换页面后改了标题,也会取到新的)。标题不能说明位置时,用 `data-breadcrumb` 传入更清楚的路径,并在切换页面时更新: ```js router.afterEach((to) => { ButterIX.configure({ breadcrumb: ["控制台", ...to.matched.map((r) => r.meta.title)].join(" / ") }); }); ``` 在控制台的 Ask AI 提问记录里,渠道显示为"嵌入";鼠标悬停在页面上可以看到面包屑与完整地址,展开一条记录可以看到完整的提问、回答与全部信息。地址里像密钥、令牌的参数会被打码。 ## 内容安全策略 网站设置了 CSP 时,需要放行文档站的地址: ```text script-src https://docs.acme.com; frame-src https://docs.acme.com; font-src https://docs.acme.com; ``` 把这些值加进网站已有的指令里。 ## 限制 - 受[密码保护](https://docs.butterix.com/guides/deploy/access-control.md)的站点不提供嵌入。 - 关闭 Ask AI(`ai.enabled: false`)时不提供嵌入。 - 面板里的来源链接在新标签页打开。 --- # 控制台 Agent > ButterIX 控制台 Agent:能做什么、草稿与审阅、需要确认的改动、建议、文档缺口、对话记录、权限与开关、用量与限制,以及它与读者的 Ask AI 的区别和安全边界。 ## 它能做什么 在控制台任意页面底部点「随便问点什么」,或在[可视化编辑器](https://docs.butterix.com/guides/deploy/editor.md)右上角打开 Agent。它只为当前站点工作: | 能力 | 做法 | | ------- | -------------------------------------------- | | 写文档 | 新建、修改、删除页面,调整导航与外观;改动进草稿,由你审阅后发布 | | 分析数据 | 流量、来源、地区、设备、搜索词、404、AI 访问;可以和上一段时间对比 | | 处理读者的问题 | 查看提问与答案、解决率、反馈;从[文档缺口](#文档缺口)直接起草修改 | | 管理站点 | 修改 `docs.yml` 里的内容与外观;建议指定问答、定时任务;其余设置给出对应页面 | **从数据到草稿** ```text 找出最近 7 天没答上来最多的问题,起草一页回答它,并加到导航里。 ``` **对比流量** ```text 最近 7 天和再往前 7 天相比,流量有什么变化?主要来自哪些页面? ``` 输入框上方有两种模式:**可修改(草稿)**与**只分析**。只分析时没有任何修改的能力。 ## 草稿与审阅 在控制台里,一次对话的改动存在同一个草稿里。每轮结束后列出改动的文件,点「在编辑器中审阅」查看、修改、发布或丢弃,也可以「撤销」这一轮。在编辑器里,改动直接成为未保存的内容。 - Agent 不能发布、合并或推送; - 停止、出错或你的权限被收回时,这一轮什么都不写; - 期间有人改过同一个文件时,不会覆盖,整轮不写并列出冲突的文件。 ### 需要你确认的改动 改动里新出现下列内容时,会先列出来等你确认,确认之前不写到任何地方: - 会自动加载的外部地址,例如图片、视频、字体; - 指向新的外部网站的链接; - 脚本、`iframe`、表单等可执行或可嵌入的内容; - `docs.yml` 里内容与外观以外的设置,例如脚本、统计、Ask AI 的指引、收录; - 无法确定指向哪里的地址; - 删除页面。 你在对话里亲自写明的地址,以及文档里已经有的地址,不需要再确认。需要确认的内容太多时,请让 Agent 分几次改。 ## 建议 指定问答、每周报告这类操作,Agent 会给出一张**建议**卡片,写明全部内容。点「确认」后以你的身份执行;不点就什么都不会发生。 域名、访问权限、成员、密钥、账单、Git 连接、发布与下线,Agent 都不能操作,只会给出对应页面的按钮。 ## 文档缺口 「Ask AI → 文档缺口」把读者没得到答案的地方按主题归并:没答上来或被踩的提问、没有结果的搜索、写了原因的差评、反复出现的 404。每个缺口有说明、建议、严重程度与全部证据,可以: - **起草修改**:交给 Agent 写成草稿; - **添加指定问答**:直接写好答案; - **标为已解决或已忽略**:已解决的再次出现同类问题时会重新打开。 点「整理」随时归并新的内容,也可以在站点设置的「控制台 AI」里打开每天自动整理。原提问按[保留天数](https://docs.butterix.com/guides/features/ask-ai.md#提问记录)删除时,对应的证据一并删除。 ## 对话记录 对话按站点保存,只有你自己看得到,最后一次更新后保留 30 天。在面板标题或侧栏的「智能体」里打开。关掉页面后,控制台里正在进行的一轮会继续跑完。 ## 权限与开关 需要 editor 及以上角色,登录控制台使用;API Key 不能使用 Agent。 站点「设置 → 控制台 AI」可以整体关闭 Agent、定时任务、AI 翻译与文档缺口,与读者的 Ask AI 分开开关。它使用 [Ask AI 设置](https://docs.butterix.com/guides/features/ask-ai.md#在控制台中配置)里的提供商、模型与密钥。 ## 用量与限制 | 项目 | 限制 | | ---- | ----------------------------------------------------------------------------------------------- | | 额度 | 使用平台提供的密钥时,按用量计入[每月 AI 问答](https://docs.butterix.com/guides/deploy/platform.md#配额与用量);使用自己的密钥不计 | | 单轮 | 最长 10 分钟,最多改 40 个文件 | | 同时进行 | 每人 1 轮,每个组织 3 轮 | ## 安全边界 读者能接触到的 AI 与控制台 Agent 完全分开: | | 读者的 Ask AI 与站点 MCP | 控制台 Agent | | ---- | ------------------ | ---------------- | | 谁能用 | 能访问文档站的人 | 本组织 editor 及以上成员 | | 能看到 | 已发布的文档、指定问答、内容来源 | 当前站点的源文件与数据 | | 能做什么 | 只能回答问题、读取文档 | 写草稿、提建议 | Ask AI 没有任何管理能力,接触不到控制台、源文件、统计数据与设置。 控制台 Agent: - 只能访问当前站点,不能发布、联网或执行命令; - 看不到密钥与访客的身份信息; - 把读者写的内容当作数据,不当作指令; - 可能带出数据的改动必须由你确认。 > **Note** > > AI 仍然可能写错内容或误读数据。发布之前请审阅草稿。 --- # 定时任务 > ButterIX 的定时任务:任务说明、每天或每周的计划与时区、只出报告或允许修改文档、草稿分支与审阅、运行记录、AI 额度与限制,以及对应的 API。 ## 它能做什么 一个定时任务就是一段任务说明加一个计划。到时间后,AI 阅读站点的文档,结合热门页面、搜索词、404、负面反馈与没答上来的提问,完成任务并写一份报告。例如: **每周找出文档缺口** ```text 查看最近 7 天没有答上来的提问与没有结果的搜索,按主题归类,列出最值得补写的 5 处,并说明应该写在哪一页。 ``` **每周检查过时内容** ```text 检查快速开始与 CLI 参考里的命令和参数是否一致,列出不一致的地方;直接修正明确的笔误。 ``` ## 创建任务 在站点的「定时任务」里点击「新建任务」(需要 editor 角色),或调用 [API](https://docs.butterix.com/api-reference/automations/create-automation.md): - `名称` (string, required): 最多 100 个字符。 - `任务说明` (string, required): 要做什么,最多 2000 个字符。报告使用任务说明的语言。 - `计划` (object, required): 每天,或每周的某一天;指定时间与时区。 - `允许改文档` (boolean, default: false): 默认只出报告,不能改任何文件。 - `启用` (boolean, default: true): 停用后不再按计划运行,仍可以手动运行。 任务也可以随时手动运行,不影响下一次计划。 ## 修改文档 打开「允许改文档」时,AI 只在任务明确要求修改时动手,全部改动提交到一个新的草稿分支 `automation/…`,从不直接发布。没有人在场确认,所以带有[需要确认的内容](https://docs.butterix.com/guides/features/console-agent.md#需要你确认的改动)的改动不会保存,报告里会说明。从运行记录点击「在编辑器中打开」,在[可视化编辑器](https://docs.butterix.com/guides/deploy/editor.md)里审阅后发布或丢弃。 ## 运行记录 每次运行都有记录:状态、报告、修改的文件与草稿分支、开始与结束时间、token 用量,失败时有原因。记录保留 30 天。 ## 用量与限制 | 项目 | 限制 | | ---- | ------------------------------------------------------------------------------------------ | | 每个站点 | 20 个任务 | | 频率 | 按计划最多每天一次;手动运行每小时最多 10 次,同一任务不能同时运行两次 | | 单次运行 | 最长 15 分钟 | | 额度 | 每次运行计 10 次[每月 AI 问答](https://docs.butterix.com/guides/deploy/platform.md#配额与用量);额度用完后运行会失败 | 任务使用站点 [Ask AI](https://docs.butterix.com/guides/features/ask-ai.md#在控制台中配置) 设置的提供商、模型与密钥,没有设置时无法运行。站点的源文件需要在平台上。 --- # 文档考卷 > ButterIX 的文档考卷:evals.yml 的写法,biti eval 用自己的模型密钥作答与评分、在 CI 里设及格线、从读者提问生成题目,以及在控制台查看历次成绩。 文档改得越勤,越容易改丢一句关键的话。文档考卷像测试用例一样守着文档:题目随文档保存在一起,每次改动后让 AI 只看文档作答,再逐条核对要点。没答对的题目会指出缺了哪条、检索有没有找到该看的页面。 ## 写题目 在 `docs.yml` 旁边新建 `evals.yml`: ```yaml title="evals.yml" pass: 80 questions: - id: refund-time question: 退款多久到账? expect: - 三个工作日内到账 - 原路退回 avoid: - 可以退到其他账户 pages: [/guides/refund] - question: 怎么开发票? expect: - 在控制台的「账单」里申请 ``` - `pass` (number, default: 80): 及格线:答对的题目占多少(百分比)。 - `questions[].question` (string, required): 题目,按读者会用的说法写。 - `questions[].expect` (string[], required): 正确答案必须说到的要点,全部说到才算答对。每条写一件事。 - `questions[].avoid` (string[]): 不能说的内容,说了就算没答对。 - `questions[].pages` (string[]): 答案应该来自哪些页面,只用于诊断,不影响对错。 - `questions[].id` (string): 题目的名称,用于 `--only`。默认 `q1`、`q2`…… - `questions[].locale` (string): 题目的语言,默认是站点的默认语言。 - `questions[].draft` (boolean): 草稿,不参加考试。没有要点的题目同样不参加。 ## 运行 需要先 [`biti login`](https://docs.butterix.com/guides/reference/cli.md#biti-login)(或设置 `BITI_TOKEN`):考题用的是平台生成的、读者能看到的文档内容。作答与评分用你自己的模型密钥。 ```bash export DEEPSEEK_API_KEY=sk-… biti eval ``` 作答的过程与读者用 [Ask AI](https://docs.butterix.com/guides/features/ask-ai.md) 相同:先检索文档,再只依据检索到的内容回答,`ai.system-prompt` 同样生效。每道题调用模型 3 次:生成搜索词、作答、评分。费用由你自己的密钥承担,结束时显示用掉的 token。 - `--provider` (string): `anthropic`、`deepseek` 或 `openrouter`,默认用已设置密钥的那一个。 - `--model` (string): 作答的模型。 - `--judge-model` (string): 评分的模型,默认与作答相同。 - `--min` (number): 及格线,覆盖 `evals.yml` 的 `pass`。 - `--only` (string): 只跑这些题目,多个 `id` 用逗号分开。 - `--concurrency` (number, default: 4): 同时作答几道题,最多 16。 - `--report` (string): 把结果写成 Markdown。 - `--json` (boolean): 输出机器可读的 JSON。 - `--site` (string): 上传成绩到这个站点。 低于及格线,或有题目无法评分时,退出码为 1。 > **Note** > > 模型的回答不是每次都一样,评分也由模型完成。及格线不要设成 100%,要点写得具体、可以核对,结果才稳定。控制台里的[指定问答](https://docs.butterix.com/guides/features/ask-ai.md#指定问答)与[内容来源](https://docs.butterix.com/guides/features/ask-ai.md#内容来源)不参与作答,考的只是文档本身。 ## 放进 CI ```yaml title=".github/workflows/docs.yml" - run: biti check docs env: BITI_TOKEN: ${{ secrets.BITI_TOKEN }} - run: biti eval docs --site acme-docs --report eval.md env: DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }} BITI_TOKEN: ${{ secrets.BITI_TOKEN }} ``` ## 从读者提问出题 ```bash biti eval --import --site acme-docs --days 30 --limit 20 ``` 把最近读者问得最多的问题加进 `evals.yml`,标为草稿;已有的不会重复。补上要点、去掉 `draft` 后参加考试。也可以在控制台「Ask AI → 对话」里点击一条提问旁的**复制为考题**,粘贴到 `questions` 下。 > **Warning** > > 提问是读者写的,可能含有个人信息,提交到仓库之前请先检查。 ## 历次成绩 用 `--site` 上传的成绩在控制台「Ask AI → 文档考卷」里,包括得分走势、每道题的对错、缺少的要点、AI 的回答与来源。每个站点保留最近 100 次,也可以通过 [API](https://docs.butterix.com/api-reference/ai/list-evals.md) 读取。 --- # 页面核验 > ButterIX 的页面核验:frontmatter 中的 owner、verified 与 review-every,复核周期与状态,控制台的待复核清单,给读者与 AI 看的核验日期,biti check --review 与定时任务提醒。 文档多人维护、时间一长,就说不清哪些内容还可信。页面核验让每一页写明负责人与最近一次确认的日期,过了复核周期就提醒你再看一次。 ## 在页面里写 ```mdx title="pages/quickstart.mdx" --- title: 快速开始 owner: alice verified: 2026-11-01 review-every: 90d --- ``` - `owner` (string | string[]): 负责人。只有团队看得到,不会出现在发布的任何内容里。 - `verified` (date | false): 最近一次确认内容正确的日期(`YYYY-MM-DD`)。写成 `false` 表示可能过时。 - `review-every` (string): 复核周期:数字加 `d`(天)、`w`(周)、`m`(月)或 `y`(年),例如 `90d`、`6m`。 在[可视化编辑器](https://docs.butterix.com/guides/deploy/editor.md)里,打开「页面设置」的**核验**一栏填写,或点击「今天已核验」。 ## 默认周期与给读者看 ```yaml title="docs.yml" page-review: every: 180d show: true ``` - `page-review.every` (string): 没有写 `review-every` 的页面用的周期。都没有时,核验不会到期。 - `page-review.show` (boolean, default: false): 在页面底部显示核验日期;过了复核日期或标为可能过时的页面,多一句「本页内容可能已过时」。是否过期按读者打开页面的日期判断,不需要重新部署。 无论是否给读者看,页面的 [Markdown 版本](https://docs.butterix.com/guides/features/agents.md#每页的-markdown)开头都会写明核验日期与复核日期,AI 工具据此判断内容是否可信。复制页面、`llms-full.txt` 与站内检索不含这一句。 ## 待复核的页面 站点的「内容检查 → 页面核验」列出每个页面的负责人、日期与状态,到期与可能过时的排在前面。点击一页,在编辑器里打开并修改。 | 状态 | 含义 | | ---- | ----------------- | | 可能过时 | `verified: false` | | 已到期 | 过了复核日期 | | 已核验 | 有核验日期,还没到期 | | 未核验 | 没有核验日期 | 多语言站点按原文列出,译文可以有自己的 `verified`。 ## 提醒 - **定时任务**:新建一个[定时任务](https://docs.butterix.com/guides/features/automations.md),每周列出待复核的页面与负责人: **每周提醒复核** ```text 列出已到期或标为可能过时的页面,按负责人分组,说明每一页应该重点看什么。 ``` - **命令行**:[`biti check --review`](https://docs.butterix.com/guides/reference/cli.md#biti-check) 列出待复核的页面,适合放进 CI;加 `--json` 时在 `reviews` 里。 - **API**:[页面核验](https://docs.butterix.com/api-reference/analytics/list-page-reviews.md)。 --- # 分析 > ButterIX 托管平台的分析:服务器端访问日志、人类与 AI 流量分类规则、Markdown 请求、索引与规范文件、MCP 调用、热门页面、AI 代理、来源、404、搜索词、AI 提问记录与页面反馈,以及接入 GA4、Plausible、PostHog 等第三方分析。 ## 为什么需要区分 AI 流量 传统的分析脚本只统计执行了 JavaScript 的浏览器。AI 爬虫与 AI 助手(ChatGPT 的浏览、Claude 的联网搜索、Cursor 的文档检索……)通常不执行脚本,在 GA 之类的工具里完全不可见——而它们可能已经是你文档最大的读者群。 ButterIX 在**服务器端**记录每一次页面与 Markdown 请求,按 User-Agent 分类,无需任何配置,也不使用 Cookie。真人的浏览在页面脚本回报之后才计数,冒充浏览器的脚本和扫描器不会混进来。 ## 流量分类 | 类别 | 判定依据(User-Agent 包含) | | ----- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | AI 助手 | ChatGPT-User、OAI-SearchBot、Claude-User、Claude-SearchBot、Perplexity-User、Gemini、MistralAI-User、DuckAssistBot、Cursor、Windsurf、Claude-Code、copilot 等;或请求头 `Accept` 包含 `text/markdown` | | AI 爬虫 | GPTBot、ClaudeBot、anthropic-ai、CCBot、Google-Extended、Applebot-Extended、Bytespider、meta-externalagent、Amazonbot、PerplexityBot、cohere-ai 等 | | 搜索引擎 | Googlebot、Bingbot、DuckDuckBot、Baiduspider、YandexBot、Sogou、Applebot | | 其他爬虫 | 含 bot / crawler / spider 字样,或 curl、wget、python-requests、axios 等程序化客户端;以及无头浏览器、扫描器和没有 User-Agent 的请求 | | 人类 | 其余请求 | 控制台中「AI 访问」= AI 助手 + AI 爬虫,「爬虫」= 搜索引擎 + 其他爬虫。 ## 控制台中的数据 站点的 **分析** 标签页(默认最近 30 天,最多 365 天): **总览** 总访问、人类访问、AI 访问、爬虫、Markdown 请求、索引与规范文件的请求、MCP 调用、AI 提问、搜索次数、反馈有帮助率。 **人类与 AI 流量** 每日人类、AI、爬虫访问趋势(含 `.md` 请求)。 **热门页面与 404** 人类访问最多的页面,以及被请求最多的不存在地址——它们往往是该加的重定向。 **AI 代理来源** 具体是哪些 AI 在读:ClaudeBot、GPTBot、Cursor…… **来源与地区** 来源网站(Referer 主机名),以及国家 / 地区(按访客 IP 识别,使用 DB-IP 国家库)。 **搜索与提问** 站内热门搜索词、Ask AI [提问记录](https://docs.butterix.com/guides/features/ask-ai.md#提问记录)(问题、回答、来源、结果、读者评价)与解决率,以及「这页有帮助吗?」的反馈与评论。 同样的数据可以通过 API 获取:[访问统计](https://docs.butterix.com/api-reference/analytics/get-analytics.md)、[AI 提问记录](https://docs.butterix.com/api-reference/analytics/list-questions.md)、[解决率](https://docs.butterix.com/api-reference/analytics/question-summary.md)、[页面反馈](https://docs.butterix.com/api-reference/analytics/list-feedback.md)。 ## 反馈 「反馈」页按来源分开: - **页面**:读者在页面底部回答「这页有帮助吗?」,可以附上原因。 - **代码问题**:读者点代码块旁的旗子,选「跑不通」「写错了」或「过时了」。记录里有是第几个代码块、语言与第一行,一眼就能找到。 - **AI 工具**:AI 工具读文档时发现错误或缺漏,经站点的 [MCP 服务器](https://docs.butterix.com/guides/features/agents.md#站点-mcp-服务器)或每页 Markdown 开头写明的地址提交。内容由 AI 生成,核实后再改文档。 只在 `docs.yml` 的 `feedback.enabled` 开启时收集(默认开启)。 ## 404 推荐重定向 「内容检查 → 404 重定向」列出最近 30 天读者访问过、但不存在的地址,并推荐地址最像的页面。确认后点「加上」: - **立即生效**,不用重新部署; - **只在原地址没有页面时跳转**:以后那个地址又有了页面,读者看到的是页面,规则自动不再起作用; - 好几个地址都是同一段搬到了别处(例如 `/docs/old/…` 都对应 `/docs/new/…`),会合并成一条通配规则 `/docs/old/*` → `/docs/new/:splat`。 扫描器探测的地址(如 `/wp-login.php`)不会出现在这里。想让重定向随文档一起管理,把它们写进 `docs.yml` 的 [`redirects`](https://docs.butterix.com/guides/features/seo.md#重定向)。 > **Tip** > > 定期看一看 AI 提问记录和「没帮助」的反馈:读者问了而文档答不上来的问题,就是下一篇该写的文档。 ## 实时访客 「分析」页的 **实时访客** 列出最近 30 分钟的逐条页面请求,每 10 秒刷新,顶部是过去 5 分钟和 30 分钟的真人访客数。可以只看真人、AI 或爬虫。每一条包括: - 时间、请求方法、页面与来源;带查询参数的,悬停在页面上查看(令牌、密码等参数会打码); - 访客类别:真人,或具体的 AI 代理与爬虫名称; - 浏览器与系统,是否在 iframe 里打开; - 国旗与国家名,以及打码的网段(只保留 IP 前三段),便于认出自己人或云厂商的扫描; - 是否计为一次浏览。标着「预取」的是读者把鼠标移到链接上时提前取的,没有打开页面;标着「无 JS」的没有收到页面脚本的回报,可能是脚本或扫描器,也可能是拦截了统计脚本的浏览器;标着「不计入」的来自控制台,或是 404 页。 ## 风险实时访问 **风险实时访问** 单独列出探测、攻击和被拒绝的请求,不混进访客与页面统计。显示最近 24 小时,保留 7 天,需要编辑者及以上的角色: | 类型 | 说明 | | --- | ----------------------------------------------------------- | | 探测 | 扫描 `.env`、`wp-login.php` 等路径,试探内部接口,或对页面使用 `POST`、`PUT` 等方法 | | 攻击 | 路径或参数里有注入、跨站脚本、目录穿越等特征 | | 被拒绝 | 跨站调用、触发限流,或输错访问密码 | 悬停查看完整的参数、User-Agent 与请求内容。`POST`、`PUT` 等请求的内容最多记录前 4 KB,二进制内容和访问密码不记录。 搜索引擎也会试探页面源码里出现的地址,列在这里不一定是恶意访问。 ## 统计口径 - **真人浏览**:请求 HTML 页面,并且页面脚本在浏览器里运行之后回报。从控制台打开、预览与 404 页不计入。 - **AI 与爬虫访问**:对 HTML 页面与 `.md` 的请求(服务器端记录,它们通常不执行脚本)。静态资源、搜索索引不计入。 - **Markdown 请求**:`.md` 地址或通过 `Accept: text/markdown` 内容协商返回 Markdown 的请求。 - **索引与规范文件**:对 `llms.txt`、`llms-full.txt` 与 API 规范文件(`/openapi.json` 等)的请求,单独统计,不计入总访问、AI 访问与爬虫。 - **MCP 调用**:对 `/_mcp/server` 的 JSON-RPC 请求。 - **搜索**:浏览器端上报的站内搜索事件(只记录搜索词)。 - 预览部署的访问也会计入同一站点。 ## 第三方分析 需要与现有分析体系打通时,在 `docs.yml` 中配置,脚本会注入到每个页面,并在无刷新导航时上报页面浏览: ```yaml title="docs.yml" analytics: ga4: measurement-id: G-XXXXXXXXXX plausible: domain: docs.acme.com posthog: api-key: phc_xxxxxxxx endpoint: https://eu.i.posthog.com ``` 支持 GA4、Google Tag Manager、Plausible、PostHog 与 Segment,详见 [docs.yml › 分析](https://docs.butterix.com/guides/configuration/docs-yml.md#分析)。预览部署和编辑器预览中不会注入这些脚本。 --- # 导出与打印 > ButterIX 的导出与打印:单页打印、栏目与整站 PDF、带图片的 Markdown 压缩包,以及 biti export 的参数。 ## 打印一页 读者在页面的「更多操作」里选「打印 / 存为 PDF」,或直接按 Ctrl / ⌘ + P。纸上只有正文: - 标签页、代码组、折叠面板、接口的嵌套字段与各状态的响应示例全部展开; - 长代码换行,不截断; - 深色模式下按浅色打印; - 视频与嵌入的网页换成地址。 不需要这一项时,用 [`theme.page-actions`](https://docs.butterix.com/guides/configuration/docs-yml.md#主题) 去掉。 ## 导出栏目或整站 在控制台打开站点概览,点「导出」下的「PDF 或 Markdown…」,选语言、版本与范围(全部、一个标签页或一个分组)。导出的是线上版本,隐藏的页面不包含在内。 **PDF** 打开站点的打印页:封面、目录,然后按导航顺序排好每一页。准备好后在浏览器的打印窗口里选「存储为 PDF」。目录和页面之间的链接在 PDF 里可以点。 页数很多时,按标签页或分组分开导出更快。 **Markdown** 下载一个 zip:每页一个 `.md`,`README.md` 是目录。页面之间的链接和图片都指向包里的文件,解压后可以离线看;指向包外页面的链接保留线上地址。图片与文件合计超过 50 MB 的部分也保留线上地址;内容太多时,按标签页或分组导出。 > **Warning** > > 站点有密码保护时,导出的文件没有:拿到文件的人都能看。 ## 命令行 `biti export` 导出平台上已发布的版本,适合放进 CI 归档。需要先 `biti login`(CI 中设置 `BITI_TOKEN`): ```bash biti export --format markdown --out docs.zip biti export --format pdf --only "API Reference" --lang en ``` - `--site` (string): 站点 slug,默认取 `docs.yml` 中 `instances[0].url` 的第一段子域名。 - `--format` ("markdown" | "pdf", default: markdown): Markdown 由平台打包。PDF 由本机的 Chrome、Chromium 或 Edge 打开站点的打印页生成,不在默认位置时,用环境变量 `CHROME_PATH` 指定;只支持公开站点,有密码保护的站点请在浏览器里[打开打印页](#导出栏目或整站)打印。 - `-o, --out` (string): `.zip`、`.pdf`,或一个空文件夹(Markdown)。省略时按站点名命名,放在当前目录。 - `--only` (string): 只导出一个标签页或分组,写它的标题。 - `--list` (boolean): 列出语言、版本、标签页与分组。 - `--lang, --product, --docs-version` (string): 语言、产品与版本,省略时用站点的默认值。 - `--paper` ("a4" | "letter", default: a4): PDF 的纸张。 `biti export` 生成的 PDF 带书签。 --- # 托管平台 > ButterIX 托管平台概览:主机划分、组织与角色、配额与用量、创建站点的模板、三种内容来源(托管仓库、Git、CLI 上传)、构建队列与部署保留策略,以及系统控制台。 ## 主机划分 ButterIX 用主机名区分不同的服务: | 主机 | 用途 | | ------------------------------------ | --------------------------------------------------------------------------------------------------------- | | `butterix.com`(`www.butterix.com`) | 官网 | | `console.butterix.com` | 组织控制台 | | `api.butterix.com` | 平台 API(`https://api.butterix.com/v1`) | | `managements.butterix.com` | 系统控制台,仅平台管理员可用 | | `<子域名>-sites.butterix.com` | 文档站的生产部署 | | `<子域名>--<部署短 id>-sites.butterix.com` | 预览部署 | | 你的域名(如 `docs.acme.com`) | CNAME 到 `sites.butterix.com`,验证后映射到站点,见[自定义域名](https://docs.butterix.com/guides/deploy/custom-domains.md) | 例如本文档站的地址是 `https://docs.butterix.com`,示例站点是 `https://acme-payments-sites.butterix.com`。 文档站只能从上表中平台提供的地址访问。页面在别的地址上被打开(例如整站被镜像)时,顶部会提示官方地址,搜索、Ask AI 与接口调试不可用。 ## 组织与角色 用户注册时自动获得一个个人组织,也可以创建更多组织并邀请成员。站点、API Key、配额与审计日志都属于组织。 | 角色 | 权限 | | ------ | ------------------------------------------- | | owner | 全部权限,组织至少保留一位 | | admin | 成员与邀请、API Key、站点创建与删除、域名、Git、访问控制、Ask AI 设置 | | editor | 部署、切换生产、编辑与发布内容、测试 Ask AI | | viewer | 只读 | 邀请尚未注册的邮箱时,控制台生成一次性邀请链接,由你发送给对方。平台关闭自助注册后,持有邀请链接的人仍然可以注册并加入组织。 每位成员可以为自己的账户开启两步验证、绑定 Passkey、管理登录会话,见[账户安全](https://docs.butterix.com/guides/deploy/account-security.md)。 ## 配额与用量 每个组织使用一个套餐,套餐规定下表各项配额的上限。新建的组织使用默认套餐;平台管理员可以更换组织的套餐,也可以为单个组织单独调整某几项: | 配额项 | 统计方式 | 达到上限后 | | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------- | | 站点数 | 组织下的站点总数 | 不能再创建站点 | | 成员数 | 组织成员总数 | 不能再邀请或添加成员 | | 自定义域名数 | 组织下所有站点连接的域名总数 | 不能再添加域名 | | 每日部署次数 | 当天(UTC)创建的部署数 | 当天不能再创建部署 | | 存储空间(MB) | 所有成功部署的产物大小之和 | 不能再创建部署 | | 每月 AI 问答次数 | 当月(UTC)Ask AI 的提问次数;[定时任务](https://docs.butterix.com/guides/features/automations.md)每次运行计 10 次;站点使用平台提供的密钥时,[Agent](https://docs.butterix.com/guides/features/console-agent.md)、文档缺口、AI 翻译与控制台里的试问也按用量计入 | 当月 Ask AI 暂停回答,定时任务不再运行;使用平台密钥的 Agent、文档缺口、AI 翻译与试问也不能再用 | | 每月页面浏览量 | 当月(UTC)文档站的页面浏览次数 | **只统计不拦截**,站点照常访问 | 在组织控制台打开「用量」页,可以看到每一项的当前用量、配额上限与近期趋势。达到上限时,相应的操作会返回「已达配额」的提示;需要更高的配额请联系平台管理员。平台会自动清理旧部署(见下文),因此存储空间通常不会无限增长。 > **Note** > > 组织被平台管理员停用后,站点、部署等写操作都会被拒绝,直到恢复为止。 ## 创建站点 在控制台点击「新建站点」,填写名称与子域名,选择模板: **入门** 简介、快速开始、写作指南三页,适合从零开始。 **空白** 只有一个首页。 **OpenAPI** 粘贴或上传 OpenAPI 3.x 规范,直接生成 API 参考。 子域名决定站点的默认地址 `https://<子域名>-sites.butterix.com`,规则如下: - 5–40 个字符,只能使用小写字母、数字与连字符,首尾不能是连字符; - 不能包含连续的 `--`(预览地址用它分隔); - `console`、`managements`、`butterix`、`sites`、`dashboard`、`support`、`billing`、`assets`、`static`、`status` 等为保留字。 创建后平台会初始化一个托管 Git 仓库并立即开始首次部署。 ## 内容来源 每个站点的内容来自以下三种来源之一: | 来源 | 如何更新 | 可视化编辑器 | 适合 | | ------------ | -------------------- | ------------ | ------------------- | | **托管仓库**(默认) | 在控制台的编辑器里修改并发布 | 支持 | 非技术同事维护的文档 | | **Git 仓库** | 推送到生产分支自动部署,拉取请求生成预览 | 支持(发布时推送回仓库) | 文档与代码放在一起的团队 | | **CLI 上传** | `biti deploy` 打包上传 | 不支持 | 在 CI 中构建、或不想让平台访问仓库 | - 对**还没有生产部署**的托管站点,第一次用 CLI 发布生产部署会把来源切换为「CLI 上传」;此后控制台的「重新部署」和编辑器不可用(平台没有源码),请继续用 `biti deploy`。 - 已有生产部署的托管站点也可以接收 CLI 上传,但来源仍是托管仓库:之后在控制台重新部署或在编辑器中发布,会用托管仓库的内容重新构建并替换 CLI 上传的版本。建议一个站点只使用一种来源。 - 连接 Git 仓库见 [Git 自动部署](https://docs.butterix.com/guides/deploy/git.md),CLI 见 [CLI 部署与 API Key](https://docs.butterix.com/guides/deploy/cli-deploy.md)。 ## 部署 - 每次构建产生一个**不可变**的部署(`queued → building → ready / failed`,排队中可取消),带有构建日志、页面数、产物大小与耗时。 - 生产地址指向某一个部署;切换生产只是改指针,即时生效,详见[预览与回滚](https://docs.butterix.com/guides/deploy/previews-and-rollbacks.md)。 - 较晚开始的构建先完成时,不会被更早开始、更晚完成的构建覆盖。 - 平台为每个站点保留最近 20 个成功的部署(当前生产部署始终保留),更早的部署文件会被清理。 - 构建是增量的:只重新渲染内容变化的页面。改一篇文字只渲染这一篇;改导航、标题、站点设置等每页都会显示的内容时,渲染全部页面。 - 没变的页面在各次部署中逐字节相同,ETag 也不变,浏览器与 CDN 不必重新下载。 - 启用对象存储与 CDN 时,样式、脚本、字体、图片等按内容命名:内容不变地址就不变,CDN 缓存跨部署有效,已有的文件不再上传。主题与客户端脚本由各站点共用。清理旧部署时,只删除不再被任何保留的部署使用的文件。 - 用相对路径引用其他文件的自定义样式与脚本(如 `url(../a.png)`、`import "./b.js"`),以及 HTML、JSON 等文件,仍由站点域名返回。 - 单次构建超时为 10 分钟。 ## 平台为每个站点提供 - 自定义域名与自动路由 - 预览部署与一键回滚 - 密码保护与访问令牌 - 可视化编辑器与 AI 翻译 - 定时任务 - Ask AI(站点密钥或平台密钥)与网页嵌入 - MCP 服务器 `/_mcp/server` - API 试调代理 - 区分人类与 AI 的分析、页面反馈 ## 组织 MCP 服务器 把组织接入 Claude Code 等编码助手,用对话查询站点、部署、分析、读者的提问与反馈。地址是平台 API 地址加 `/mcp`,在组织设置里可以复制,用组织 API Key 认证: ```bash claude mcp add --transport http butterix https://api.butterix.com/v1/mcp \ --header "Authorization: Bearer $BITI_TOKEN" ``` 全部工具都是只读的,只能访问该 API Key 所属的组织: | 工具 | 内容 | | ------------------ | ------------------------------ | | `list_sites` | 组织的全部站点 | | `get_site` | 一个站点的地址、域名、来源、生产部署与访问模式 | | `list_deployments` | 最近的部署,含状态与错误 | | `get_deployment` | 一个部署及其构建日志 | | `get_analytics` | 访问量、访客、AI 与爬虫流量、热门页面、搜索、404、来源 | | `list_searches` | 读者搜索了什么 | | `list_questions` | 读者的提问与回答,可按结果与评价筛选 | | `question_summary` | 各结果的数量与解决率 | | `list_feedback` | 页面反馈 | | `list_automations` | 定时任务及最近一次运行 | 每个 API Key 每分钟最多 120 次调用。这与站点自带的 [MCP 服务器](https://docs.butterix.com/guides/features/agents.md#站点-mcp-服务器)不同,后者供读者检索文档内容。 ## 系统控制台 系统控制台(`https://managements.butterix.com`)只对平台管理员开放,用于运营整个平台: **组织管理** 停用与恢复组织、更换套餐、为单个组织调整配额,以及允许该组织去掉站点页脚的「Powered by ButterIX」标志。 **用户管理** 查看每个用户的套餐与额度用量(其拥有的组织合计)、设为平台管理员、停用账户、为丢失验证器的用户重置两步验证。 **套餐管理** 新建与修改套餐及其额度、指定新组织使用的默认套餐、查看各套餐的组织数。 **平台设置** 是否允许自助注册、是否要求管理员开启两步验证、对象存储与 CDN。 **分析与审计** 全平台的访问与用量分析,以及平台级审计日志。 开启「要求管理员开启两步验证」后,平台管理员必须先开启两步验证才能进入系统控制台,且不能再关闭。 ### 套餐 在左侧选择「套餐」管理全部套餐: ### 新建或修改套餐 点击「新建套餐」,填写名称、标识与各项额度;额度留空表示不限。修改已有套餐的额度会立即对使用它的组织生效,组织单独调整过的项除外。 ### 指定默认套餐 在套餐右侧的菜单里选择「设为默认套餐」。之后新建的组织使用它,已有组织不变。 ### 为组织更换套餐 在左侧选择「组织」,点开该组织,在右上角选择套餐。用量超出新上限时,已有内容保留,但不能再新增。 默认套餐和仍有组织使用的套餐不能删除。 ### 用户的额度用量 「用户」列表显示每个用户所在的套餐与额度用量。用量与上限都是该用户**拥有**(角色为 owner)的组织的合计:任意一个组织的某项不限,合计就显示不限;有多位所有者的组织会计入每一位所有者。点击用量可以查看全部配额项与各组织的明细。 ### Powered by 标志 所有站点的页脚默认都显示「Powered by ButterIX」标志,组织自己不能去掉。允许某个组织去掉它: ### 打开组织详情 以平台管理员身份登录系统控制台,在左侧选择「组织」,搜索并点开该组织。 ### 打开开关 在组织详情页找到「允许去掉“Powered by ButterIX”标志」,打开右侧的开关。修改立即保存,并记入平台审计日志。 ### 由组织关闭标志 该组织的成员在编辑器「文档设置 → 页头与页脚」里关闭「显示 Powered by ButterIX」(或在 `docs.yml` 写 `powered-by: false`),提交并发布后,站点页脚不再显示标志。 再次关掉这个开关,该组织所有站点在下次部署时恢复显示标志,即使它们的 `docs.yml` 里写了 `powered-by: false`。 --- # CLI 部署与 API Key > 创建 ButterIX 组织 API Key,用 biti login 或 BITI_TOKEN 认证,biti deploy 的参数、打包规则与预览部署,以及 GitHub Actions 等 CI 的配置示例。 ## 创建 API Key ### 打开组织设置 在控制台进入「组织设置 → API Keys」(需要 admin 角色)。 ### 生成密钥 填写一个便于识别的名称(例如「GitHub Actions」),点击生成。密钥以 `biti_` 开头,**只显示这一次**,请立即保存到密码管理器或 CI 的密钥库中。 API Key 属于组织,以 `editor` 角色行事:可以部署、切换生产、编辑内容,但不能管理成员、域名或其他密钥。删除密钥后,使用它的 CLI 与 CI 立即失效。列表中会显示每个密钥的前缀与最近使用时间。 ## 登录 **交互式** ```bash biti login ``` CLI 会提示粘贴密钥,调用平台的 `/api/v1/whoami` 验证后,把凭据保存到 `~/.config/bitidocs/credentials.json`(设置了 `XDG_CONFIG_HOME` 时保存在其下,文件权限 600)。 **非交互式** ```bash biti login --token biti_xxxxxxxxxxxxxxxx ``` 默认连接 ButterIX 托管平台。 **环境变量(CI)** 不需要登录,直接设置环境变量: ```bash export BITI_TOKEN=biti_xxxxxxxxxxxxxxxx ``` 设置了 `BITI_TOKEN` 时,它优先于已保存的凭据。 ## 发布 ```bash biti deploy --site acme-payments --message "发布 v1.2 文档" ``` ```text title="输出" ButterIX · biti ◆ Packing .… ◆ Uploading 412 KB to https://console.butterix.com… queued building ✔ Published 94 pages in 6.1s https://acme-payments-sites.butterix.com ``` - `[dir]` (string, default: .): 项目目录。 - `--site` (string): 站点 slug。省略时取 `docs.yml` 中 `instances[0].url` 的主机名推断(`acme-payments-sites.butterix.com` → `acme-payments`)。 - `--preview` (boolean): 创建预览部署,不影响生产地址,得到 `<site>--<短 id>` 形式的独立地址。 - `--message` (string, default: Deployed with biti CLI): 部署说明,显示在控制台的部署列表中。 ### 发生了什么 ### 校验配置 读取 `docs.yml`;配置有错误时停止并提示先运行 `biti check`。 ### 打包 把项目目录打成 gzip tar 包,跳过 `node_modules`、`.git`、`.biti`、`dist`、`.DS_Store`,以及 `.env`、`.npmrc`、SSH 私钥等可能带凭证的文件(会列出来)。平台接受最大 200 MB 的上传。 ### 上传 `POST /api/v1/sites/<site>/deployments`,返回部署 id。 ### 等待构建 每秒查询一次部署状态,打印状态变化;成功后打印地址,失败或被取消时打印错误并以非零状态退出。 查询时碰到断网、限流或平台重启(5xx)会自动重试。连续 2 分钟查不到才退出,此时上传已经成功,构建可能仍在进行,请先到控制台的部署列表确认,再决定是否重新发布。 > **Tip** > > 构建在平台上进行,你的机器上不需要构建产物。发布前在本地运行一次 `biti check --strict`,可以在几秒内发现问题,而不必等到平台构建失败。 ## 与在线编辑器同步 `biti deploy` 会检查:上次部署或拉取之后,线上编辑器是否又发布过改动。 | 情况 | 结果 | | ------------------------------- | --------------------------------------------- | | 线上没有新改动 | 直接部署 | | 线上改过的文件,本地都没改 | 列出改动,自动合并到本地目录后继续部署 | | 同一文件两边都改过,但不在同一处 | 按行合并到本地目录,两边的改动都保留,继续部署 | | 同一处两边都改过 | 停止部署,用 `!` 标出这些文件,本地文件不动。运行 `biti pull` 后处理冲突 | | 没有同步记录(`.biti/sync.json`,例如 CI) | 停止部署,不自动合并 | `biti pull --dry-run` 只列出会改哪些文件。`biti deploy --force` 会用本地内容覆盖线上改动。 ### 处理冲突 `biti pull` 会在冲突的文件里标出两份内容,其余改动照常合并: ```yaml <<<<<<< local - url: https://api.example.com/v1 ======= - url: https://api.example.com/v2 >>>>>>> online ``` 改成想要的内容并删掉标记行,或者直接取一边: ```bash biti resolve . --online # 全部取线上 biti resolve . openapi/api.yml --local # 这个文件取本地 ``` 图片等无法按行合并的文件,以及线上删除、本地修改过的文件,会保留本地版本;线上的版本放在 `.biti/conflicts/`。用 `biti resolve` 选择一边,不带参数表示就用现在的内容。 冲突全部处理完之前,`biti deploy` 不会发布,`biti pull` 也不会再次拉取。`biti deploy --force` 会取本地的一边发布。 在编辑器里,「文件」按钮上的数字是还没提交的草稿数;旁边的橙色圆点表示线上有已发布、命令行还没拉取的改动,展开菜单可以看到文件列表。 ## 在 CI 中部署 ### GitHub Actions 推送到 `main` 时发布生产,拉取请求时创建预览: ```yaml title=".github/workflows/docs.yml" name: Docs on: push: branches: [main] pull_request: jobs: deploy: runs-on: ubuntu-latest env: BITI_TOKEN: ${{ secrets.BITI_TOKEN }} BITI_API: https://console.butterix.com steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 22 - run: npm install -g bitidocs - run: biti check --strict - if: github.event_name == 'push' run: biti deploy --site acme-payments --message "${{ github.event.head_commit.message }}" - if: github.event_name == 'pull_request' run: biti deploy --site acme-payments --preview --message "PR #${{ github.event.number }}" ``` ### GitLab CI ```yaml title=".gitlab-ci.yml" docs: image: node:22 variables: BITI_API: https://console.butterix.com script: - npm install -g bitidocs - biti check --strict - biti deploy --site acme-payments --message "$CI_COMMIT_TITLE" rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH ``` 在 CI 的密钥设置中添加 `BITI_TOKEN`。 > **Note** > > 如果仓库托管在 GitHub 上,也可以不使用 CI,直接让平台连接仓库,推送和拉取请求会自动触发构建,见 [Git 自动部署](https://docs.butterix.com/guides/deploy/git.md)。 ## 直接调用 API CLI 只是平台 API 的一层封装。在没有 Node.js 的环境中,可以用 `curl` 完成同样的事: ```bash tar --exclude=node_modules --exclude=.git --exclude=dist -czf site.tgz . curl -X POST https://api.butterix.com/v1/sites/acme-payments/deployments \ -H "Authorization: Bearer $BITI_TOKEN" \ -H "Content-Type: application/gzip" \ -H "x-biti-preview: 1" \ --data-binary @site.tgz ``` 然后轮询 [获取部署](https://docs.butterix.com/api-reference/deployments/get-deployment.md) 直到 `status` 为 `ready`。 --- # Git 自动部署 > 把 ButterIX 站点连接到 Git 仓库:仓库地址、分支与访问令牌,配置 GitHub Webhook(Payload URL、Secret、事件),推送与拉取请求的部署规则,签名校验,与可视化编辑器的配合,以及断开连接。 ## 连接仓库 ### 准备仓库 仓库中需要有 `docs.yml`(可以在仓库根目录,也可以在 `fern/` 或 `biti/` 子目录中,CLI 与平台按 `docs.yml` → `docs.yaml` → `fern/docs.yml` → `biti/docs.yml` → `docs.json` → `mint.json` 的顺序查找)。 ### 在控制台中填写 打开站点的「设置 → Git 仓库」,填写: - **仓库地址**:`https://` 开头,例如 `https://github.com/acme/docs.git`。 - **分支**:生产分支,默认 `main`。 - **访问令牌**:私有仓库需要具有读取权限的令牌;如果要在可视化编辑器中发布(推送回仓库),还需要写权限。令牌加密存储,之后留空表示保持不变。 点击「连接仓库」,平台会拉取仓库并立即开始一次生产部署。 ### 配置 Webhook 连接后,设置页会显示 **Payload URL** 与 **Secret**。在 GitHub 仓库的 Settings → Webhooks → Add webhook 中: | 字段 | 值 | | ------------ | --------------------------------------------------------------------- | | Payload URL | 设置页显示的地址,形如 `https://api.butterix.com/v1/webhooks/github/site_2m4k8p` | | Content type | `application/json` | | Secret | 设置页显示的 Secret | | 事件 | 选择 **Pushes** 与 **Pull requests** | 也可以用 API 连接:[连接 Git 仓库](https://docs.butterix.com/api-reference/git/connect-git.md)。 ## 什么会触发部署 ```mermaid flowchart LR P[push] -->|生产分支| A[生产部署] P -->|其他分支| I[忽略] PR[pull_request] -->|opened / synchronize / reopened| B[该分支的预览部署] PING[ping] --> OK[返回 ok] ``` | GitHub 事件 | 条件 | 结果 | | -------------- | ------------------------------------- | -------------------------------- | | `push` | 推送到连接时设置的生产分支 | 生产部署,说明取提交信息的第一行,记录提交 SHA | | `pull_request` | 动作为 `opened`、`synchronize`、`reopened` | 以 PR 的源分支创建预览部署,说明为 `PR #编号: 标题` | | `ping` | GitHub 添加 Webhook 时发送 | 返回 `{ "ok": true }` | | 其他 | | 返回 `{ "ignored": true }` | 预览部署完成后,在控制台的部署列表中可以打开它的独立地址,详见[预览与回滚](https://docs.butterix.com/guides/deploy/previews-and-rollbacks.md)。 ## 安全 - 每个请求都必须带 `X-Hub-Signature-256` 头,平台用站点的 Secret 计算 HMAC-SHA256 并做常数时间比较,不匹配时返回 401。 - Webhook 地址使用站点 id(而不是 slug),只有连接了 Git 的站点才会接受请求。 - 平台只从仓库**读取**内容并在单独的工作线程中构建;MDX 不会执行任何代码(见[安全子集](https://docs.butterix.com/guides/writing/safe-mdx.md))。 ## 与可视化编辑器配合 连接 Git 后仍然可以使用可视化编辑器: - 编辑发生在草稿分支上,**不能直接修改生产分支**; - 「发布」会把草稿合并到生产分支并**推送到远程仓库**,然后触发生产部署(需要令牌有写权限); - 团队成员既可以在 IDE 里提交,也可以在编辑器里修改,二者经由 Git 合并。 ## 手动重新部署 控制台的「重新部署」与「创建预览部署」按钮会从仓库最新的提交重新构建,也可以调用 [创建部署](https://docs.butterix.com/api-reference/deployments/create-deployment.md) 并传 `{ "branch": "feature/x", "preview": true }` 构建任意分支。 ## 断开连接 「断开连接」后站点回到 ButterIX 托管仓库,之后的推送不再触发部署,Webhook 请求返回 404。 --- # 预览与回滚 > ButterIX 的部署模型:不可变部署与生产指针、部署状态、预览部署的来源与地址、预览的 noindex 与横幅、设为生产(回滚)、取消排队中的部署,以及部署保留策略。 ## 部署模型 ```mermaid flowchart LR subgraph 部署历史 D1[dpl_…a1<br/>ready] D2[dpl_…b2<br/>ready] D3[dpl_…c3<br/>ready · 预览] D4[dpl_…d4<br/>failed] end P((生产指针)) --> D2 D2 -. 设为生产 .-> D1 ``` - 每个部署是一个完整的静态产物目录,生成后**不会再被修改**。 - 站点的生产地址只是一个指向某个部署的**指针**。发布新版本、回滚、把预览设为生产,都只是移动这个指针,**即时生效**,不需要重新构建。 - 失败的构建不会影响线上站点。 ### 部署状态 ```mermaid stateDiagram-v2 [*] --> queued queued --> building queued --> canceled: 取消 building --> ready building --> failed ``` | 状态 | 说明 | | ---------- | ------------------------ | | `queued` | 排队等待构建,可以取消 | | `building` | 构建中,控制台可以查看实时日志 | | `ready` | 成功,可以访问、设为生产 | | `failed` | 失败,`error` 中有原因,日志中有完整输出 | | `canceled` | 已取消(或因超出保留数量被清理) | ### 触发者 控制台的部署列表显示每次部署由谁触发。用 API Key 部署(`biti deploy`、CI)时,显示创建该密钥的成员,以及密钥名称和只露出首尾的密钥,例如 `biti_a1B2c••••Kd82mQx0Zt`,便于确认是哪一把。由 Git 推送触发的部署按来源显示。 ## 预览部署 预览部署与生产部署完全相同,只是不会移动生产指针,并拥有自己的地址: ```text https://<子域名>--<部署 id 后 8 位>-sites.butterix.com ``` 预览部署的来源: [**拉取请求**](https://docs.butterix.com/guides/deploy/git.md) 连接 Git 后,PR 打开或更新时自动创建。 [**CLI**](https://docs.butterix.com/guides/deploy/cli-deploy.md) `biti deploy --preview` [**可视化编辑器**](https://docs.butterix.com/guides/deploy/editor.md) 在编辑器中为草稿创建预览。 **控制台** 站点概览页的「创建预览部署」。 预览部署中: - 页面顶部显示「Preview」横幅; - 每一页都带 `noindex`,`robots.txt` 禁止抓取,不会被搜索引擎收录; - canonical、站点地图、`llms.txt` 使用预览地址作为源站; - Ask AI、MCP、试调代理与正式站点一样可用,便于完整验收; - 站点开启了密码保护时,预览地址同样需要密码。 每次构建的预览地址保留 30 天,过期后打开会提示预览已过期;草稿的固定预览地址跟着草稿走,不受这个期限影响。 ## 回滚:设为生产 在控制台的「部署」页,任何状态为 `ready` 的部署(包括预览部署和更早的生产部署)都有「设为生产」按钮。确认后生产地址立即切换到该部署,随时可以切回。 通过 API: ```bash curl -X POST https://api.butterix.com/v1/deployments/dpl_01jd8x2k7q/promote \ -H "Authorization: Bearer <token>" ``` ```typescript const response = await fetch("https://api.butterix.com/v1/deployments/dpl_01jd8x2k7q/promote", { method: "POST", headers: { "Authorization": "Bearer <token>" } }); const data = await response.json(); console.log(data); ``` > **Info** > > 把一个预览部署设为生产,等于「审阅通过后原样上线」——上线的就是你审阅过的那份产物,不会重新构建。 ## 取消部署 排队中(`queued`)的部署可以取消。已经开始构建的部署无法中途停止,构建超过 10 分钟会被判定失败。 ## 保留策略 平台为每个站点保留最近 20 个成功部署的文件(当前生产部署始终保留);更早的部署会被清理并标记为 `canceled`,记录仍保留在列表中,但不能再设为生产。平台重启时,正在排队或构建中的部署会被标记为失败,需要重新部署。 --- # 自定义域名 > 为 ButterIX 托管站点配置自定义域名:添加域名、CNAME 到 sites.butterix.com、_butterix TXT 所有权验证、自动签发与续期 HTTPS 证书、多个域名、子路径部署,以及常见问题。 每个站点默认就有一个地址 `https://<子域名>-sites.butterix.com`。连接自定义域名(例如 `docs.acme.com`)后,两个地址同时可用,指向同一个生产部署。 ## 配置步骤 ### 添加域名 在组织控制台(`https://console.butterix.com`)打开站点的「域名」标签页,点击「添加域名」,输入完整域名,例如 `docs.acme.com`(需要 admin 角色)。粘贴带 `https://` 或路径的地址也可以,平台会自动去掉多余部分。 一个域名只能连接到一个站点;组织能连接的域名总数受[配额](https://docs.butterix.com/guides/deploy/platform.md#配额与用量)限制。 ### 添加 CNAME 记录 在你的 DNS 服务商处添加一条 CNAME 记录,把域名指向 ButterIX: | 类型 | 名称 | 值 | | ----- | ------------------------- | -------------------- | | CNAME | `docs`(即 `docs.acme.com`) | `sites.butterix.com` | ### 添加 TXT 记录 再添加一条 TXT 记录,证明你拥有这个域名。记录值中的令牌以控制台显示的为准: | 类型 | 名称 | 值 | | --- | ------------------------- | ------------------------------- | | TXT | `_butterix.docs.acme.com` | `butterix-verify=a1b2c3d4e5f6…` | 部分 DNS 服务商的「名称」一栏只需要填写主域名之前的部分,此时填 `_butterix.docs`。 ### 验证 回到控制台点击「验证」。平台查询 `_butterix.<你的域名>` 的 TXT 记录,匹配后把域名标记为「已验证」,域名立即开始指向站点。 DNS 记录生效可能需要几分钟到数小时;验证失败时稍后重试即可。 ### 自动启用 HTTPS 验证通过后,平台自动通过 Let's Encrypt 为域名签发 HTTPS 证书,通常一两分钟内生效,你不需要上传或配置任何证书。证书在到期前 30 天自动续期。 ## 通过 API ```bash curl -X POST https://api.butterix.com/v1/sites/acme-payments/domains \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "domain": "docs.acme.com" }' ``` 201: 新域名(未验证) ```json { "domain": "docs.acme.com", "verified": false, "primary": false, "verifyRecord": { "type": "TXT", "name": "_butterix.docs.acme.com", "value": "butterix-verify=a1b2c3d4e5f6" }, "cname": "sites.butterix.com", "createdAt": 1 } ``` 响应中的 `verifyRecord` 是需要添加的 TXT 记录,`cname` 是 CNAME 目标。添加好记录后调用[验证域名](https://docs.butterix.com/api-reference/domains/verify-domain.md)。 ## 生效后 - 自定义域名与默认的 `<子域名>-sites.butterix.com` 地址同时可用,指向同一个生产部署。 - 一个站点可以连接多个自定义域名,每个域名都需要单独验证。 - **主域名**:canonical、站点地图、`robots.txt`、`llms.txt`、订阅源与 `.md` 里的绝对地址都使用主域名。默认是最近验证的自定义域名,HTTPS 证书生效后自动启用;要换成别的,在「域名」标签页点「设为主域名」(或调用[设为主域名](https://docs.butterix.com/api-reference/domains/set-primary-domain.md)),之后新绑定的域名不会再自动接替。没有自定义域名时使用默认地址。 - 主域名变化时,平台自动重新部署线上的版本,完成后绝对地址随之更新;在自己的 CI 里构建、直接上传到 Git 站点的部署没有可重建的来源,下次部署时更新。 - 站点开启了密码保护时,自定义域名同样需要密码。 - 移除域名后,它立即不再指向站点;之后可以删除 DNS 中对应的 CNAME 与 TXT 记录。 ## 部署在子路径下 希望文档出现在主站的子路径(如 `acme.com/docs`)时: 1. 在 `docs.yml` 中设置 `basepath: /docs`(或在 `instances[0].custom-domain` 中写 `acme.com/docs`,会自动推断)。所有页面、资源和 `llms.txt` 都会带上这个前缀。 2. 在主站的反向代理上把 `/docs/*` 转发到文档站的默认地址。 ```nginx title="nginx:把 /docs 转发到托管文档站" location /docs/ { proxy_pass https://acme-payments-sites.butterix.com; proxy_set_header Host acme-payments-sites.butterix.com; proxy_ssl_server_name on; } ``` ## 常见问题 <details> <summary>根域名(acme.com)不能设置 CNAME 怎么办?</summary> 多数 DNS 规范不允许在根域名上设置 CNAME。请使用子域名(如 `docs.acme.com`),或使用 DNS 服务商提供的 ALIAS / ANAME / CNAME 拉平功能,把根域名指向 `sites.butterix.com`。 </details> <details> <summary>验证一直失败</summary> 用 `dig TXT _butterix.docs.acme.com +short` 检查 TXT 记录是否已经生效、值是否与控制台显示的完全一致(包括 `butterix-verify=` 前缀)。也请确认 DNS 服务商没有自动补上主域名,把记录名变成了 `_butterix.docs.acme.com.acme.com`。 </details> <details> <summary>还没验证时打开域名会看到什么?</summary> CNAME 生效后、验证通过前,用 `http://` 打开会看到说明页,告诉你域名还没有添加到站点,或者还差 TXT 验证。证书在验证通过后才签发,所以这时用 `https://` 打开会提示无法建立安全连接。 </details> <details> <summary>HTTPS 证书多久生效?需要自己上传吗?</summary> 不需要上传。域名验证通过后,平台自动通过 Let's Encrypt 签发证书,通常一两分钟内生效;到期前 30 天自动续期。如果几分钟后浏览器仍然提示证书无效,请确认 CNAME 记录指向 `sites.butterix.com`,并且域名上没有阻止 Let's Encrypt 签发的 CAA 记录。 </details> <details> <summary>域名前面还有自己的 CDN 或代理可以吗?</summary> 证书签发需要 Let's Encrypt 能直接访问到 ButterIX。请让该域名的 CNAME 记录保持「仅 DNS」模式;如果必须经过自己的 CDN,请在 CDN 上为该域名配置证书,并把回源地址设为 `sites.butterix.com`。 </details> <details> <summary>提示「This domain is already connected」</summary> 该域名已连接到某个站点(可能是其他组织的站点)。先在原站点中移除它。 </details> --- # 访问控制 > ButterIX 托管站点的访问控制:公开与密码保护两种模式、访客体验、修改密码的影响、对预览部署和自定义域名的作用范围、访问令牌与 MCP 登录,以及搜索引擎与 AI 的可见性。 ## 两种模式 **公开** 任何人都可以访问(默认)。 **密码保护** 访客需要先输入共享密码。 在站点的「设置 → 访问控制」中切换(需要 admin 角色),或调用 [设置访问控制](https://docs.butterix.com/api-reference/sites/update-access.md): ```bash curl -X PUT https://api.butterix.com/v1/sites/acme-payments/access \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"mode":"password","password":"preview-2026"}' ``` > **Note** > > 修改访问控制需要 admin 角色,组织 API Key 以 editor 身份行事,不能调用此接口;请在控制台中操作,或使用管理员的登录会话。 ## 访客体验 1. 未通过验证的访客,用浏览器访问站点的任何页面都会看到一个简洁的密码页(HTTP 401,带 `noindex`,跟随系统深浅模式)。连续输错时需要稍等再试。 2. 输入正确的密码后,平台设置一个 HttpOnly 的访问 Cookie(有效期 30 天,HTTPS 时带 `Secure`),然后跳转到首页。 3. 30 天内再次访问无需输入密码。 密码至少 6 个字符,平台只保存其哈希值。 ## 修改密码与取消保护 - **修改密码**会使所有访客的登录与 MCP 登录立即失效;[访问令牌](#访问令牌)不受影响。 - 已设置过密码时,从「公开」切回「密码保护」可以不填密码,沿用原来的密码。 - 切换回「公开」后立即对所有人开放。 ## 作用范围 密码保护作用于站点的**所有主机**: | 地址 | 是否受保护 | | --------------------------------------- | ----- | | 生产地址 `<子域名>-sites.butterix.com` | 是 | | 预览地址 `<子域名>--<短 id>-sites.butterix.com` | 是 | | 已验证的自定义域名 | 是 | | `.md`、`llms.txt`、`sitemap.xml` 等静态文件 | 是 | | Ask AI、MCP 服务器、试调代理、反馈等动态端点 | 是 | 未通过验证的客户端既看不到页面,也无法通过 MCP 或 Ask AI 检索内容。受保护的站点不提供[网页嵌入](https://docs.butterix.com/guides/features/ask-ai-embed.md),页面菜单里也没有连接 MCP 的选项。 ## AI 工具与程序的访问 不是浏览器打开网页的请求(`.md`、`llms.txt`、规范文件、MCP,或没有声明要 HTML 的请求),未授权时返回 401 与一段 Markdown 说明,`WWW-Authenticate` 头给出登录方式。有两种方式授权: ### 访问令牌 在站点的「设置」里新建访问令牌(需要 admin 角色,令牌只显示一次),每次请求带上它: ```bash curl https://docs.acme.com/guides/quickstart.md \ -H "Authorization: Bearer $DOCS_TOKEN" ``` - 同一个令牌可用于页面、`.md`、`llms.txt` 与 MCP 服务器; - 可以设置有效期(1–3650 天),也可以一直有效; - 每个站点最多 50 个,可以随时吊销,列表显示每个令牌最近的使用时间; - 修改站点密码不影响令牌。 在 Claude Code 中接入受保护的 MCP 服务器: ```bash claude mcp add --transport http acme-docs https://docs.acme.com/_mcp/server \ --header "Authorization: Bearer $DOCS_TOKEN" ``` 对应的 API 见[访问令牌](https://docs.butterix.com/api-reference/sites/create-access-token.md)。 ### MCP 登录 支持 OAuth 的 MCP 客户端不需要令牌:添加 MCP 地址后,客户端会打开浏览器,读者输入站点密码并点击「Allow」即可,30 天内有效。修改站点密码后需要重新登录。 ## 搜索引擎与 AI 受保护的站点对爬虫返回 401,因此不会被搜索引擎收录;没有令牌或登录的 AI 爬虫与 MCP 客户端也无法读取内容。 ## 更细粒度的访问控制 目前只支持站点级的共享密码,暂不支持按用户登录(SSO)或按角色显示内容。 --- # 账户安全 > ButterIX 账户安全设置:开启两步验证(TOTP 验证器应用)、保存与重新生成恢复码、绑定多个 Passkey 并用 Passkey 免密码登录、查看会话列表与注销其他会话,以及丢失验证器时的处理办法。 所有账户安全设置都在组织控制台(`https://console.butterix.com`)中:点击左下角的账户,选择「安全」。这些设置属于你的个人账户,在你加入的所有组织中通用,平台管理员登录系统控制台时也使用同一套设置。 **两步验证** 登录时除了密码,还要输入验证器应用里的 6 位验证码。 **Passkey** 用指纹、面容或设备 PIN 登录,免输入邮箱和密码。 **会话** 查看哪些设备登录了你的账户,一键注销其他设备。 ## 两步验证 两步验证使用基于时间的一次性验证码(TOTP),支持任意标准验证器应用,例如 Google Authenticator、Microsoft Authenticator、1Password、Authy。 ### 开始设置 在「安全」页的「两步验证」中点击「开启」。页面会显示一个二维码和一串密钥。 ### 添加到验证器应用 用验证器应用扫描二维码;无法扫码时,手动输入二维码下方的密钥。应用中会出现一个每 30 秒刷新一次的 6 位验证码。 ### 输入验证码确认 把应用中当前的 6 位验证码填回页面并确认。验证通过后两步验证立即生效。 ### 保存恢复码 开启成功后,页面会显示 **10 个恢复码**。请立即下载或抄写下来,保存在密码管理器等安全的地方——它们只显示这一次。 开启后,用邮箱和密码登录时会多出一步:输入验证器应用中的验证码。如果你绑定了 Passkey,这一步也可以改用 Passkey 完成。 ### 恢复码 恢复码用于在手机丢失、验证器应用被删除等情况下登录: - 在输入验证码的那一步改为输入任意一个恢复码即可登录。 - 每个恢复码只能使用一次,用过即作废。「安全」页会显示剩余可用的数量。 - 恢复码快用完或怀疑泄露时,点击「重新生成恢复码」(需要输入当前密码)。重新生成后会得到 10 个新的恢复码,旧的全部失效。 ### 关闭两步验证 在「安全」页点击「关闭两步验证」,输入当前密码确认。关闭后,验证器应用中的条目和未使用的恢复码都不再有效;之后重新开启时需要重新扫码。 > **Note** > > 如果平台开启了「要求管理员开启两步验证」,平台管理员的账户不能关闭两步验证。 ## Passkey Passkey 是基于 WebAuthn 的登录凭据,保存在你的设备或密码管理器中(例如 iCloud 钥匙串、Google 密码管理器、1Password,或硬件安全密钥),用指纹、面容或设备 PIN 解锁。Passkey 不会被钓鱼网站骗走,也不需要记忆密码。 ### 添加 Passkey 1. 在「安全」页的「Passkey」中点击「添加 Passkey」。 2. 按浏览器或系统的提示完成验证(指纹、面容、PIN 或插入安全密钥)。 3. 为它起一个便于辨认的名字,例如「工作 MacBook」「iPhone」。 每个账户可以绑定多个 Passkey(最多 20 个)。建议至少在两台设备上各绑定一个,避免其中一台丢失后无法登录。已绑定的 Passkey 可以随时重命名或删除;删除后该 Passkey 立即不能再用于登录。 ### 用 Passkey 登录 - **直接登录**:在登录页点击「使用 Passkey 登录」,选择你的 Passkey 并完成验证即可,无需输入邮箱和密码。 - **作为第二步验证**:开启了两步验证时,输入密码后可以选择用 Passkey 代替 6 位验证码。 组织控制台与系统控制台共用同一批 Passkey,在任一控制台添加的 Passkey 在另一个控制台同样可用。 ## 会话 「安全」页的「会话」列出当前登录了你账户的设备与浏览器,包括登录时间与过期时间,当前使用的会话会单独标出。 - 点击某个会话旁的「注销」,该设备立即退出登录。 - 点击「注销其他会话」,除当前设备外的所有设备都会退出登录。 - 修改密码后,平台会自动注销你的其他所有会话。 如果看到不认识的设备,请立即注销它、修改密码,并开启两步验证。 ## 常见问题 <details> <summary>手机丢了,验证器和恢复码都找不到了怎么办?</summary> 如果你绑定过 Passkey,可以直接用 Passkey 登录,然后在「安全」页关闭再重新开启两步验证。没有可用的 Passkey 和恢复码时,请联系平台管理员:管理员可以在系统控制台为你的账户重置两步验证,之后你用密码登录并重新设置即可。 </details> <details> <summary>验证码总是提示不正确</summary> TOTP 依赖准确的时间。请确认手机开启了自动设置时间;同一个验证码在一个时间窗口内只能使用一次,提示失败时等下一个验证码再试。 </details> <details> <summary>Passkey 能在其他电脑上用吗?</summary> 取决于 Passkey 保存在哪里。保存在 iCloud 钥匙串、Google 密码管理器或 1Password 中的 Passkey 会在同一账号的设备间同步;在没有同步的电脑上,浏览器通常可以让你用手机扫码完成验证。 </details> <details> <summary>组织 API Key 受两步验证影响吗?</summary> 不受影响。API Key 属于组织而不是个人账户,CLI 与 CI 使用 API Key 时不需要两步验证。请妥善保管 API Key,不再使用时在「组织设置 → API Keys」中删除,见 [CLI 部署与 API Key](https://docs.butterix.com/guides/deploy/cli-deploy.md)。 </details> --- # 可视化编辑器 > ButterIX 控制台的可视化编辑器:草稿分支工作流、文件树与导航、实时渲染与诊断、组件属性面板、图片上传、并发冲突处理、预览部署、发布与 AI 翻译,以及适用的站点类型。 ## 工作流 ```mermaid flowchart LR M[(main)] -->|新建草稿| D[draft/…] D -->|保存 = 提交| D D -->|预览| P[预览部署] D -->|发布:合并| M M -->|自动| PROD[生产部署] ``` ### 新建草稿 打开站点的「编辑器」标签页,从生产分支创建一个草稿分支 `draft/<你的 id>-<时间>`。每个人的修改都在自己的草稿里,互不干扰;同一时间可以有多个草稿。 ### 编辑 直接在页面上改:画布与线上完全一致,点哪里改哪里,输入 `/` 插入组件。点侧栏的导航切换页面。右上角的「源码」打开 MDX 源码面板,在画布上的修改立即反映到源码,直接改源码后点「更新」生效。 ### 保存 每次保存都是草稿分支上的一次 Git 提交,提交者是你的账号。 ### 预览 为草稿创建预览部署,得到一个独立地址,可以发给同事审阅(完整站点,含搜索、Ask AI 与 API 试调)。 ### 发布 填写说明后发布:草稿合并到生产分支并触发生产部署。不需要的草稿可以直接丢弃。 - 编辑器左上角显示当前状态:无改动、未提交(修改只在你的浏览器里)、待发布(已提交到草稿分支,还没上线)、发布中、已发布。 - 已提交但没发布时,右上角的「提交」会变成「发布」,随时可以点开继续发布。 - 发布后编辑器回到线上内容;再打开已经发布过的草稿链接,也会打开最新的线上内容。 ## 实时渲染 预览使用与正式构建相同的渲染管线:同样的组件、同样的代码高亮、同样的主题与 `docs.yml` 配置(包括颜色、字体与自定义 CSS)。区别只有两点: - 以安全模式渲染,**不加载** `docs.yml` 中的自定义 `js`,因为预览运行在控制台的域名下; - 图片等资源直接从草稿分支读取,上传后立即可见。 不在导航中的文件也可以编辑,但预览会提示「该文件不在 docs.yml 的导航中,因此不会被发布」。 ## 组件与属性面板 编辑器从平台的组件清单(与 `biti components --json` 相同)读取每个组件的属性、类型、可选值与默认值,用于插入组件和编辑属性。因为 MDX 只允许字面量属性(见[安全子集](https://docs.butterix.com/guides/writing/safe-mdx.md)),编辑器可以无损地读取和改写组件,而不会破坏你手写的其他内容。 - 提示框、折叠面板、更新日志、卡片等组件的**正文直接在画布上编辑**,外观与发布后一样。结构由子组件决定的组件(如标签页、代码组)整块选中,在属性弹层里改。 - 双击组件(行内组件单击)打开属性弹层:按属性类型给出开关、下拉、取色器、数字框等,修改即时预览,取消则全部还原,每个属性单独一步撤销。 - 图标一栏点开是[可搜索的图标选择器](https://docs.butterix.com/components/icon.md#可用的图标)。 - 图片的弹层里可以改图片地址、替代文字、[注释](https://docs.butterix.com/guides/writing/media.md#注释)、宽高,以及是否允许点击放大。 ## 在块之间插入 按住 `⌘`(Windows 为 `Ctrl`)移动鼠标,附近可以插入的位置会出现一条横线,单击就在那里插入: | 鼠标在 | 插入 | | ------------------- | ------- | | 正文、组件的正文、引用里的两块之间 | 一个空段落 | | 列表项之间 | 一个列表项 | | 单元格里内容的上下、图片的上下、换行处 | 单元格里的一行 | | 表格的行边框上(表头上面除外) | 一行表格 | 鼠标在链接上时不出现横线。不按 `⌘` 也可以: - 点两个块之间的空隙:旁边是段落或标题时,光标放进去;两侧是提示框、表格、代码块等时,空出一行。方向键走到那里也一样。 - 点图片下方,或选中图片后按回车,在图片后面空出一行。 空出的段落和单元格里的行,没输入就移开会自动收起,不算修改;按退格也会收起。在空段落里输入 `/` 可以插入组件。 紧挨图片按退格先选中图片,再按一次才删除;图片选中时直接打字,文字写在图片后面。 ## 表格 表格直接在画布上编辑,单元格里可以写粗体、链接、行内代码;`Tab` / `Shift+Tab` 在单元格间移动(最后一格按 `Tab` 新增一行),回车在单元格内换行。 - 每列表头上方的 “…” 打开列菜单:在左 / 右插入列、对齐方式、重置列宽、删除列;每行左侧的 “⋮” 打开行菜单:在上 / 下方插入行、删除行; - 按住 “…” 左右拖动移动这一列,按住 “⋮” 上下拖动移动这一行,落点处有一条线,按 `Esc` 取消;菜单里也有左移 / 右移、上移 / 下移。表头不能移动,也不能把行放到表头上面;合并单元格把几行或几列连在一起时,它们整组移动; - 表格右侧的 “⊕” 竖条在末尾加一列,下方的 “⊕” 虚线条在末尾加一行; - 拖动列与列之间的边框调整列宽,保存为 `<Table widths="…">`; - 拖选多个单元格后点“合并单元格”,光标在合并过的格子里时可“拆分单元格”。保存为 Markdown 的 `>>` / `^^` 合并语法,表头向下合并等无法用该语法表达的情况自动改写为 HTML `<table>`; - 表格右侧的 “⋮” 打开表格菜单:皮肤(悬停时表格先换上看看)、列宽布局、最小宽度、固定表头 / 首列、搜索、分页、删除表格。 - 拖动列边框时,右侧各列按现有比例一起缩放、总宽不变;按住 `Shift` 只调整相邻两列。 这些设置对应 [Table 组件](https://docs.butterix.com/components/table.md)的属性,在源码模式里看到的就是普通的 MDX。 ## 分栏 在 [Columns](https://docs.butterix.com/components/columns.md) 的列与列之间有拖柄:拖动即可调整列宽,右侧各列按比例一起缩放,靠近等宽时自动吸附(按住 `Alt` 不吸附),保存为 `<Columns widths="60 40">`;双击拖柄恢复等宽。 ## 文档设置 右上角的「文档设置」读写 `docs.yml`,分为这些类别:品牌、导航、布局、样式、页头与页脚、页面、API 参考、搜索、Ask AI、社交分享、分析、重定向。修改保留 YAML 中的注释与格式,进入「文件」里的改动,随提交一起保存。 - **颜色**:未设置的颜色字段显示站点实际生效的默认色(与站点使用同一套调色板算法,随强调色与明暗模式变化)。取色器提供饱和度 / 明度面板、色相滑条与 HEX / RGB / HSL 输入,可以一键恢复默认。 - **布局**:页面宽度(写 `full` 即为宽屏模式)、正文宽度、侧栏宽度、页头高度、页头不透明度与背景模糊,见[自定义外观](https://docs.butterix.com/guides/configuration/appearance.md)。 - **页头与页脚**:页头链接、社交链接、公告栏(文字、链接、背景、文字颜色)、页脚链接与版权文字,以及「显示 Powered by ButterIX」开关。平台管理员没有为你的组织开通「允许去掉」时,这个开关为灰色、不能关闭;如果站点使用了[自定义页脚](https://docs.butterix.com/guides/configuration/docs-yml.md#自定义页脚)文件,这里只提示页脚由哪个文件定义。 ## 页面设置 右上角的「页面设置」编辑当前页面的 frontmatter:标题、副标题、地址、图标(点开[搜索选择](https://docs.butterix.com/components/icon.md#可用的图标))、布局(`guide` / `overview` / `reference` / `page` / `custom`)、目录、SEO 等,以及「页面头图」:上传亮色 / 暗色两张图片,即为 frontmatter 的 `background-image`。清空最后一个字段时,整块 frontmatter 会一并去掉。 ## 接口页 由 OpenAPI 生成的接口页可以直接点文字修改,内容写回规范文件;预览切到其他语言时写进译文。见[在编辑器里修改文字](https://docs.butterix.com/guides/api/openapi.md#在编辑器里修改文字)。 ## 更新日志与博客 [更新日志与博客](https://docs.butterix.com/guides/configuration/changelog.md)在左侧导航树里显示为一个分组,列出概览页与按日期排列的条目,草稿和隐藏条目带有标记。 - 导航树的「添加更新日志 / 博客」新建一份更新日志或博客:选择类型、填写导航标题与条目目录,同时创建概览页和第一条条目,并写入 `docs.yml` 的导航。 - 分组菜单里可以「新建条目」(博客为「新建文章」)、「编辑概览页」或设置「布局与作者」。新建条目时选择日期、填写标签,文件名按日期自动生成;也可以在「新建页面」对话框里选择放进哪份更新日志。 - 打开条目后,「页面设置」显示条目专属的设置:日期、标签(输入后回车添加)、草稿、隐藏;博客文章还有作者、缩略图与自定义地址。概览页的设置里可以切换 `timeline` / `classic` / `blog` 布局并维护作者登记表。 ## 多版本与多语言 - 多版本、多产品站点的导航树上方有「查看版本」「查看产品」下拉框,切换后即可查看和编辑该版本的导航,新建页面也会放进当前版本。 - 「文档设置 → 导航」里可以管理版本(启用多版本、添加、改名、地址段、状态、设为默认、排序、隐藏、删除)和语言(启用多语言、添加、显示名称、设为默认、排序、删除),见[多版本](https://docs.butterix.com/guides/features/versions.md#在控制台里管理版本)与[多语言](https://docs.butterix.com/guides/features/i18n.md#在控制台里管理语言)。 ## 查看改动与还原 右上角的「文件」列出本次草稿里已修改的文件,每个文件显示新增与删除的行数(`+增 -删`)。 - 鼠标在文件上停留约 2 秒,弹出这个文件的改动预览; - 点击打开完整 diff:新旧行号、红色删除与绿色新增,未改动的段落折叠,可以展开; - 每处修改旁边都有「还原这处修改」按钮,只撤回这一处,其余修改保留;还原可以撤销。 ## 上传字体 「文档设置 → 品牌 → 字体」里,正文、标题、代码可以各用一种字体:上传 WOFF2、WOFF、TTF 或 OTF 文件(最大 20 MB),或填写 Google Fonts 字体名。可变字体一个文件就有全部字重;否则一次选多个文件,编辑器按文件认出字重与斜体,写进 docs.yml 的 [`typography`](https://docs.butterix.com/guides/configuration/docs-yml.md#字体)。文件保存在 `assets/fonts/`,随变更请求发布。字体较大时会提示,建议用 WOFF2 或只含所需字符的子集。 ## 上传图片与媒体 拖入或选择文件即可上传图片、视频或 PDF(最大 20 MB)。文件以 `assets/<时间戳>-<文件名>` 的形式提交到草稿分支,并返回可以直接写进 Markdown 的地址: ```mdx ![架构图](/assets/mf2x8k-architecture.png) ``` ## 多人协作与冲突 - 你的草稿所基于的文件在分支上又被改过时,画布上方会提示,可以撤销这些草稿、改用最新版本,也可以保留。 - 打开文件时编辑器记录它的版本(sha);保存时如果文件已经被别人在同一草稿上修改,平台拒绝覆盖并返回最新内容,由你合并后再保存。 - 发布时如果草稿与生产分支有无法自动合并的冲突,发布会失败并提示冲突,生产站点不受影响。 ## AI 翻译 站点配置了多种语言时,可以在编辑器中一键翻译整站。平台新建一个 `translate/…` 分支,用站点的 Ask AI 配置增量翻译全部页面与导航标签(复用仓库中的翻译记忆),完成后在编辑器中审阅、修改,再发布。详见[多语言](https://docs.butterix.com/guides/features/i18n.md#在平台上用-ai-翻译)。 ## 调整界面 右上角的按钮打开源码、页面设置、文档设置与 [Agent](https://docs.butterix.com/guides/features/console-agent.md) 面板。拖动画布与右侧栏之间的边框调整宽度,双击恢复默认。 ## 适用的站点 | 站点来源 | 编辑器 | | ------- | --------------------------------------------------------------------------------------------------------------------------------- | | 托管仓库 | 可用。发布即合并到托管仓库的生产分支 | | 已连接 Git | 可用。不能直接编辑生产分支;发布时合并并**推送到远程仓库**(令牌需要写权限) | | CLI 上传 | 可用。`biti deploy` 会把源文件同步到平台;线上发布的改动用 `biti pull` 取回,或在下次部署时[按行合并](https://docs.butterix.com/guides/deploy/cli-deploy.md#与在线编辑器同步) | 需要 editor 及以上角色才能保存、预览与发布;viewer 可以浏览文件与渲染结果。 ## 用 API 驱动编辑器 编辑器的全部能力都通过平台 API 提供,你也可以用脚本或 AI Agent 批量修改文档:读取文件、带 `baseSha` 保存、调用 `editor/check` 校验、创建预览、发布。接口列表见 API 参考的[可视化编辑器](https://docs.butterix.com/api-reference/editor/list-branches.md)分组。 #### Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `branch` | string | yes | | | `path` | string | yes | | | `content` | string | yes | | | `message` | string | no | | | `baseSha` | string | no | | --- # CLI 参考 > biti CLI 参考:init、dev、check、eval、export、login、deploy、pull、translate、components 的参数与示例,退出码与环境变量。 ```bash npm npm install -g bitidocs ``` ```bash pnpm pnpm add -g bitidocs ``` ```bash yarn yarn global add bitidocs ``` ```bash biti --help # 列出命令 biti <命令> --help # 查看某个命令的参数 biti --version ``` 所有接受 `[dir]` 的命令默认作用于当前目录。 ## biti init 创建一个新的文档项目。 ```bash biti init [dir] [--title <title>] [--openapi <file>] [--skill] ``` - `--title` (string): 站点标题,默认由目录名生成。 - `--openapi` (string): 把该 OpenAPI 文件复制为 `openapi.yml`,并生成「Guides」与「API Reference」两个标签页。 - `--from` (string): 已有的 Fern / Mintlify 项目目录,整个复制到新项目里。biti 直接读取其中的 `fern/docs.yml` 或 `docs.json`。见[从 Fern 迁移](https://docs.butterix.com/guides/reference/migrate-from-fern.md)。 - `--skill` (boolean): 把编写技能包写入 `.claude/skills/butterix-docs`,供 Claude Code 等编码 Agent 编辑文档时使用。在已有项目里运行时只添加技能包,已经有时不覆盖。见[让编码 Agent 编辑你的文档](https://docs.butterix.com/guides/features/agents.md#让编码-agent-编辑你的文档)。 生成 `docs.yml`、`pages/introduction.mdx`、`pages/quickstart.mdx`、`assets/logo.svg`、`AGENTS.md` 与 `.gitignore`。目录中已有 `docs.yml` 且没有 `--skill` 时报错退出。 ## biti dev 在本机预览文档,修改后自动刷新。需要先 `biti login`(或设置 `BITI_TOKEN`)。 ```bash biti dev [dir] [-p, --port <port>] ``` - `-p, --port` (number, default: 3000): 端口。 - 页面由 ButterIX 平台渲染:biti 把文档目录的改动增量同步到平台,并在 `http://localhost:<端口>` 提供页面。改动同步后页面自动刷新;只改 CSS 时热替换样式,不整页刷新。 - 只能在本机打开。每页底部注明“此为仅用于开发的预览版,不提供给读者使用”。 - 搜索与 Ask AI 在发布后的站点上可用,开发预览中点击只给出提示。[接口调试](https://docs.butterix.com/guides/api/try-it.md)可以使用,只能请求 OpenAPI 规范中写明的公网服务器。 - 完整检查请用 `biti check`。 ## biti check 校验配置、导航、MDX、链接、API 规范与 [skills](https://docs.butterix.com/guides/features/agents.md#托管-skills),不写出任何文件。检查在平台上进行,需要先 `biti login`;在 CI 中设置 `BITI_TOKEN`。 ```bash biti check [dir] [--json] [--strict] [--review] ``` - `--json` (boolean): 输出机器可读的 JSON:`{ ok, pages, diagnostics: [{ severity, code, message, file, line, column, hint }] }`。适合 CI 与编码 Agent。 - `--strict` (boolean): 把警告也视为错误。 - `--review` (boolean): 同时列出待[复核](https://docs.butterix.com/guides/features/page-review.md)的页面;与 `--json` 一起用时在 `reviews` 里。不影响退出码。 存在错误(或 `--strict` 下存在警告)时退出码为 1。常见的诊断: | 代码 | 级别 | 含义 | | ----------------------- | ------- | ----------------------------------------------------------------------------------------------------------- | | `config/schema` | 错误 | `docs.yml` 字段类型不对,消息中带字段路径 | | `config/tab` | 错误 | 导航引用了未声明的标签页 | | `nav/missing-page` | 错误 | 导航中的页面文件不存在 | | `nav/duplicate-slug` | 错误 | 两个页面得到相同的地址 | | `api/load` | 错误 | OpenAPI 文件不存在或无法解析 | | `mdx/parse` | 错误 | MDX 语法错误(未闭合的标签、未转义的 `{` / `<`) | | `mdx/attribute` | 错误 | 属性值不是字面量 | | `asset/missing` | 错误 | 引用的图片或文件不存在 | | `link/broken` | 警告 | 链接到不存在的源文件 | | `mdx/unknown-component` | 警告 | 未知组件,只渲染其子内容 | | `mdx/required-prop` | 警告 | 组件缺少必填属性 | | `mdx/tag` | 警告 | 不允许的 HTML 标签被移除 | | `md/table-merge` | 警告 | 单元格里的 `>` / `^` 不是[合并单元格](https://docs.butterix.com/guides/writing/markdown.md#合并单元格)的写法,也没有转义 | | `page/review` | 警告 | `owner`、`verified` 或 `review-every` 的写法不对,见[页面核验](https://docs.butterix.com/guides/features/page-review.md) | | `icon/unknown` | 警告 | 没有这个名称的[图标](https://docs.butterix.com/components/icon.md#可用的图标) | | `skill/invalid` | 错误 / 警告 | `.well-known/agent-skills/` 中的 skill 不符合[要求](https://docs.butterix.com/guides/features/agents.md#托管-skills) | | `api/unsupported` | 警告 | 引用的文件不是 OpenAPI 或 Swagger(例如 AsyncAPI、OpenRPC),这一节没有内容 | | `openapi/spec` | 警告 | OpenAPI 规范中的问题(如无法解析的 `$ref`) | ## biti eval 让 AI 只看文档回答 `evals.yml` 里的问题并评分,见[文档考卷](https://docs.butterix.com/guides/features/evals.md)。需要先 `biti login`;作答与评分使用你自己的模型密钥(见[环境变量](#环境变量))。 ```bash biti eval [dir] [--model <id>] [--min <percent>] [--site <slug>] [--report <file>] [--json] biti eval [dir] --import --site <slug> ``` 低于及格线时退出码为 1。 ## biti export 把平台上已发布的文档导出成 Markdown 或 PDF,需要先 `biti login`,见[导出与打印](https://docs.butterix.com/guides/features/export.md#命令行)。 ```bash biti export [dir] [--site <slug>] [--format markdown|pdf] [--out <path>] [--only <name>] [--lang <code>] [--paper a4|letter] biti export [dir] --list ``` ## biti migrate 输出从其他平台迁移的步骤,或对照新旧项目,见[迁移工具](https://docs.butterix.com/guides/reference/migrate.md)。 ```bash biti migrate <source> [--check <dir>] [--report <file>] [--base <path>] [--ignore <glob>] [--json] ``` `<source />` 是旧项目的目录,或旧站的 `https://` 地址。与 `--check` 一起用时,有遗漏则退出码为 1。 ## biti login 保存平台凭据。 ```bash biti login [--api <url>] [--token <token>] ``` - `--api` (string, default: https://console.butterix.com): 平台地址,默认是 ButterIX 托管平台。 - `--token` (string): 组织 API Key;省略时交互式输入。 凭据经 `/api/v1/whoami` 验证后保存到 `~/.config/bitidocs/credentials.json`。 ## biti deploy 打包项目、上传并发布到托管平台。 ```bash biti deploy [dir] [--site <slug>] [--preview] [--message <msg>] ``` - `--site` (string): 站点 slug,默认取 `instances[0].url` 的第一段子域名。 - `--preview` (boolean): 创建预览部署。 - `--message` (string): 部署说明。 详见 [CLI 部署与 API Key](https://docs.butterix.com/guides/deploy/cli-deploy.md)。 ## biti pull 把线上的源文件拉到本地目录。目录不存在时自动新建;已经同步过的目录按行合并,两边的改动都保留。 ```bash biti pull [dir] [--site <slug>] [--clean | --merge] [--force] [--dry-run] ``` - `--site` (string): 站点 slug,默认取 `instances[0].url` 的第一段子域名。拉到新目录时必须写。 - `--clean` (boolean): 目录里是别的内容时,先清空再拉取(保留 `.git`)。下载成功后才清空。 - `--merge` (boolean): 目录里是别的内容时,直接拉进去。同名但内容不同的文件算冲突,其余文件留着,下次部署会一起上传。 - `--force` (boolean): 每个文件都取线上的版本,覆盖本地修改。 - `--dry-run` (boolean): 只列出会改哪些文件,不写入。 目录非空、又不是这个站点的文档时(没有同步过,`docs.yml` 也对不上),会询问清空后拉取、直接拉取还是取消;在 CI 等不能交互的环境里,需要写 `--clean` 或 `--merge`。 合并与冲突的处理见[与在线编辑器同步](https://docs.butterix.com/guides/deploy/cli-deploy.md#与在线编辑器同步)。 ## biti translate 用 AI 把页面增量翻译到 `translations/<lang>/`。 ```bash biti translate [dir] [--to <langs>] [--provider <provider>] [--model <model>] [--only <path>] ``` - `--to` (string): 目标语言,逗号分隔,默认是原文以外的全部语言。 - `--provider` (anthropic | deepseek | openrouter, default: anthropic): 模型提供商。 - `--model` (string): 模型 id,默认使用提供商的默认模型。 - `--only` (string): 只翻译路径中包含该字符串的页面。 详见[多语言](https://docs.butterix.com/guides/features/i18n.md#用-biti-translate-自动翻译)。 ## biti components 列出全部 MDX 组件、别名与属性。 ```bash biti components [--json] ``` ```text title="输出(节选)" <Callout> (<Note> <Info> <Warning> <Success> <Error> <Danger> <Tip> <Check> <Launch>) callout Highlights important information. Aliases set the intent: … intent enum: note | info | warning | success | error | tip | check | launch | danger — Color and default icon. title string — Bold heading above the content. icon icon — Icon spec (Font Awesome / lucide:name / URL / <svg>). icon={false} hides the icon. ``` ## 环境变量 | 变量 | 用于 | 说明 | | -------------------- | --------------------------------------------- | ----------------------------------------------------- | | `BITI_TOKEN` | `dev`、`check`、`eval`、`export`、`deploy`、`pull` | 组织 API Key,优先于已保存的凭据 | | `BITI_API` | `login` 与需要登录的命令 | 平台地址,默认是 ButterIX 托管平台 `https://console.butterix.com` | | `XDG_CONFIG_HOME` | `login` 与需要登录的命令 | 凭据文件所在目录,默认 `~/.config` | | `ANTHROPIC_API_KEY` | `translate`、`eval` | Anthropic 密钥 | | `DEEPSEEK_API_KEY` | `translate`、`eval` | DeepSeek 密钥 | | `OPENROUTER_API_KEY` | `translate`、`eval` | OpenRouter 密钥 | | `BITI_AI_PROVIDER` | `eval` | 作答与评分使用的提供商,默认取设置了密钥的那个 | | `BITI_AI_MODEL` | `eval` | 作答使用的模型 | --- # 迁移工具 > biti migrate 的用法:识别 Mintlify、Fern、Docusaurus、GitBook、ReadMe、Starlight、VitePress、Nextra、Fumadocs、MkDocs 项目,输出给编程 Agent 的迁移步骤,并对照新旧项目的页面、正文、代码、图片、地址、重定向与接口。 迁移文档最怕漏:少了一页、丢了代码、旧链接打不开。`biti migrate` 分两步:先给编程 Agent 一份迁移步骤,由它来改写;再对照新旧项目,逐项列出没带过来的内容。命令只读旧项目,不会改动它,也不会把内容发到任何地方。 ## 迁移步骤 ### 生成步骤 ```bash biti migrate ../old-docs > migrate.md ``` 识别旧项目用的平台,列出页面、重定向与接口的数量,以及需要转换的写法。 ### 交给编程 Agent 把 `migrate.md` 交给 Claude Code、Cursor、Codex 等工具,在新目录里完成改写。 ### 对照 ```bash biti check docs biti migrate ../old-docs --check docs --report migration.md ``` 有遗漏时退出码为 1。把报告交给 Agent 继续处理,直到没有遗漏。 ### 核对线上地址 旧站还在线时,用它的站点地图确认每个地址都有着落: ```bash biti migrate https://docs.example.com --check docs ``` ### 审阅并发布 看一遍预览,再 [`biti deploy`](https://docs.butterix.com/guides/reference/cli.md#biti-deploy)。 ## 支持的来源 | 来源 | 识别依据 | 说明 | | ------------------------------------------ | ---------------------------- | -------------------------------------------------------------------------------------------- | | Mintlify | `docs.json`、`mint.json` | 可以直接导入,见[从 Mintlify 迁移](https://docs.butterix.com/guides/reference/migrate-from-mintlify.md) | | Fern | `fern/docs.yml` | 可以直接导入,见[从 Fern 迁移](https://docs.butterix.com/guides/reference/migrate-from-fern.md) | | Docusaurus | `docusaurus.config.*` | 侧栏与配置是代码,不会被执行,由 Agent 阅读 | | GitBook | `.gitbook.yaml`、`SUMMARY.md` | 导出到 Git 仓库的内容 | | ReadMe | `_order.yaml` | 导出的项目 | | Starlight、VitePress、Nextra、Fumadocs、MkDocs | 各自的配置文件 | | | 其他 | 目录里的 `.md`、`.mdx` | 只给通用步骤 | | 任意网站 | `https://` 地址 | 只核对站点地图里的地址 | ## 对照什么 | 项目 | 判断方法 | | ----- | --------------------------------------------- | | 页面与正文 | 旧正文能在新项目里找到多少。页面可以拆开、合并、改名,写法可以不同;各页都有的套话权重更低 | | 代码块 | 每一段是否还在,忽略空白 | | 标题 | 正文不完整的页面列出找不到的标题 | | 图片与文件 | 按内容比较,改名、移动不影响 | | 导航 | 有内容但没有进导航的文件 | | 地址 | 旧地址在新站有页面或重定向。按各平台的规则从文件推出,推不出的不核对 | | 重定向 | 旧的每一条是否仍然有效 | | 接口 | OpenAPI 里的每个操作 | 对照的是内容是否还在,不判断排版与语气;发布前仍要人看一遍。 ## 选项 - `--check` (string): 新项目所在目录,与旧项目对照。 - `--report` (string): 把报告写成 Markdown 文件。 - `--base` (string): 旧站挂在子路径下时的前缀,例如 `/docs`。 - `--ignore` (string): 有意不要的旧页面,支持 `*` 与 `**`,可以写多次。 - `--json` (boolean): 输出机器可读的 JSON。不加 `--check` 时是旧项目的清单。 --- # 从 Fern 迁移 > 把 Fern 文档迁移到 ButterIX:直接读取 fern/docs.yml、配置字段对照、API 分区需要的 openapi 路径、支持的 x-fern 扩展、组件兼容性、需要调整的写法(行号属性、自定义组件、片段变量)与迁移检查清单。 ## 直接使用 fern/docs.yml biti 按 `docs.yml` → `docs.yaml` → `fern/docs.yml` → `biti/docs.yml` → `docs.json` → `mint.json` 的顺序查找配置。登录(`biti login`)后,在 Fern 仓库的根目录运行: ```bash biti check # 找出需要调整的地方 biti dev # 本地预览 ``` 配置文件所在的 `fern/` 目录就是项目根,`docs.yml` 中的路径(`pages/…`、`assets/…`)继续相对于它解析,无需移动任何文件。 ## 配置字段对照 以下 Fern 字段可以原样使用: | 类别 | 字段 | | --- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | 站点 | `title`、`instances`(`url`、`custom-domain`)、`logo`(`light`、`dark`、`height`、`href`、`right-text`)、`favicon` | | 主题 | `colors`(`accent-primary`、`background`、`border`、`sidebar-background`、`header-background`、`card-background`,也接受 `accentPrimary`)、`typography`、`layout`、`css`、`js` | | 导航 | `tabs`、`navigation`(`section`、`page`、`link`、`api`、`changelog`(及别名 `blog`)、`folder`)、`navbar-links`、`landing-page` | | 多维度 | `versions`、`products`、`languages` / `translations`,以及 `translations/<lang>/` 下的各语言 `docs.yml` 与导航文件(见[按语言覆盖导航文件](https://docs.butterix.com/guides/features/i18n.md#按语言覆盖导航文件)) | | 其他 | `redirects`、`announcement`、`analytics`、`footer` | 导航节点上的 `slug`、`skip-slug`、`icon`、`hidden`、`collapsed`、`availability`、`noindex` 含义与 Fern 相同。字段的完整说明见 [docs.yml 参考](https://docs.butterix.com/guides/configuration/docs-yml.md)。 另外几处可以原样保留的写法: - 顶层的 `footer-links`(平台 → 地址)在加载时并入 `footer.socials`,两处有同名平台时以 `footer.socials` 为准;在控制台修改社交链接时会一并写到 `footer.socials` 下。 - `translations/<lang>/fern/<文件>` 也会读取,各语言的配置文件不用挪位置。 - 更新日志:`changelog` 节点与 `blog:` 别名、三种日期格式的文件名、`overview.mdx`、`##` 小节与 `<ChangelogTags>`、`tags`、`draft` / `hidden`、多产品站点的顶层 `changelog`、`timeline` / `classic` / `blog` 布局(含 `blog-layout`、`authors` 与文章的 `author`、`thumbnail`、`slug`、`description` / `subtitle` / `excerpt`)、`.rss` / `.atom` / `.json` 订阅地址,以及 `/changelog.md` 与 `/changelog/llms.txt` 都与 Fern 一致,见[更新日志](https://docs.butterix.com/guides/configuration/changelog.md)。 > **Note** > > 个别 Fern 字段已被接受但暂未生效(例如 `background-image`、`layout.disable-header`),列表见 [docs.yml 参考 › 兼容但暂未生效的字段](https://docs.butterix.com/guides/configuration/docs-yml.md#兼容但暂未生效的字段)。 ## API 分区:补上 openapi 路径 Fern 的 `- api: API Reference` 通常通过 `api-name` 引用 `fern/apis/<name>/` 下由 generators.yml 描述的定义。ButterIX 不读取 Fern Definition 与 generators.yml,**需要在 api 节点上直接写出 OpenAPI 文件路径**: ```yaml title="fern/docs.yml" {4} navigation: - api: API Reference api-name: plants openapi: apis/plants/openapi/openapi.yml ``` 如果你的 API 是用 Fern Definition(`definition/*.yml`)而不是 OpenAPI 编写的,需要先导出为 OpenAPI。 ### 支持的 x-fern 扩展 | 扩展 | 作用 | | ------------------------ | ---------------------- | | `x-fern-display-name` | 端点标题 | | `x-fern-sdk-method-name` | 端点 URL 段 | | `x-fern-availability` | 状态标签(beta、deprecated…) | | `x-fern-ignore` | 不生成页面 | | `x-fern-streaming` | 标记为流式响应 | | `x-fern-enum` | 枚举值的说明 | Redocly 风格的 `x-codeSamples`、`x-displayName`、`x-hidden`、`x-internal` 同样支持。见[导入 OpenAPI](https://docs.butterix.com/guides/api/openapi.md)。 ## 组件兼容性 Fern 的 MDX 组件都有同名实现,属性保持一致: - `Callout` 与 `Note` / `Info` / `Warning` / `Success` / `Error` / `Tip` / `Check` / `Launch` - `Card`、`CardGroup`、`Tile` - `Tabs` / `Tab`(含 `language` 同步) - `Steps` / `Step` - `Accordion`、`AccordionGroup` - `CodeBlock`、`CodeBlocks`、`Code` - `Frame`、`Icon`、`Badge`、`Button` - `Tooltip`、`Indent`、`Anchor`、`Aside` - `ParamField`、`ResponseField` - `EndpointRequestSnippet`、`EndpointResponseSnippet`、`EndpointSchemaSnippet`、`WebhookPayloadSnippet`、`Schema`、`RunnableEndpoint` - `Files` / `Folder` / `File` - `Prompt`、`ScrollWalkthrough`、`Update`、`ChangelogTags`(更新日志小节标签) - `Versions` / `Version`、`If` - `Markdown`(片段)、`Color`、`Copy`、`Download` - `GitHub.Repo`、`StickyTable` 代码围栏的 meta 语法(标题、`{1-3}`、`focus`、`startLine`、`maxLines`、`wordWrap`、`for`)也与 Fern 一致,见[代码块](https://docs.butterix.com/guides/writing/code-blocks.md)。 ## 需要调整的写法 <details open> <summary>行号属性写成字符串</summary> Fern 文档中的 `lines={[1-3]}`、`highlight={[1-3, 5]}` 里的 `1-3` 是减法表达式,ButterIX 的[安全子集](https://docs.butterix.com/guides/writing/safe-mdx.md)只允许字面量,会报 `mdx/attribute` 错误。改为: ```mdx <Code src="snippets/example.ts" lines="1-3" /> <EndpointRequestSnippet endpoint="POST /plants" highlight="1-3, 5" /> ``` </details> <details> <summary>React 组件写的页脚</summary> 平台不执行作者提供的组件代码,`.tsx` / `.jsx` 页脚会在构建时给出提示并显示默认页脚。把页脚改写成 MDX 即可,见[自定义页脚](https://docs.butterix.com/guides/configuration/docs-yml.md#自定义页脚)。 </details> <details> <summary>自定义 React 组件</summary> ButterIX 不执行 MDX 中的 JavaScript,`import` 只能导入 `.md` / `.mdx` 片段。把自定义组件替换为最接近的内置组件,或把内容改写为片段。`biti check` 会对每个未知组件给出 `mdx/unknown-component` 警告。 </details> <details> <summary>片段中的变量占位符</summary> 片段正文中的 `{name}` 会被 MDX 当作表达式,请写成 `\{name\}`,见[可复用片段与变量](https://docs.butterix.com/guides/writing/snippets.md#带参数的片段)。 </details> <details> <summary>基于角色的内容</summary> `<If roles>` 被接受,但静态站点没有登录用户,条件永远不成立。需要按用户控制访问时,见[访问控制](https://docs.butterix.com/guides/deploy/access-control.md)。 </details> ## 迁移检查清单 ### 补全 api 节点的 openapi 路径 运行 `biti check`,处理所有 `api/load` 与 `nav/api` 错误。 ### 修复 MDX 诊断 处理 `mdx/attribute`、`mdx/import`、`mdx/unknown-component`。 ### 核对 URL ButterIX 的 slug 规则与 Fern 一致(标签页、分区、页面逐段拼接,支持 `slug` 与 `skip-slug`)。用 [`biti migrate https://旧站地址 --check .`](https://docs.butterix.com/guides/reference/migrate.md#迁移步骤) 对照旧站点地图检查地址,必要时添加 `redirects`。 ### 部署 用 `biti deploy`,或在控制台连接仓库实现推送自动部署。 --- # 从 Mintlify 迁移 > 把 Mintlify 文档迁移到 ButterIX:docs.json / mint.json 的自动转换范围、页面地址的变化、改写为 docs.yml 的对照、Mintlify 组件与属性兼容性,以及片段和 OpenAPI 的迁移。 ## 第一步:直接预览 登录(`biti login`)后,在 Mintlify 项目根目录(没有 `docs.yml` 时)运行: ```bash biti dev ``` biti 会读取 `docs.json`(或旧版的 `mint.json`),在加载时转换成 ButterIX 的配置。页面、图片、片段都留在原处。 ## 自动转换的范围 | Mintlify | ButterIX | | --------------------------------------------------------- | ------------------------------------------------------- | | `name` | `title` | | `logo`(字符串或 `{ light, dark }`) | `logo` | | `favicon` | `favicon` | | `colors.primary` / `colors.light` | `colors.accent-primary` 的浅色 / 深色值 | | `navigation.groups` 或 `navigation` 数组中的 `group` / `pages` | 分区(`section`)与页面,`icon` 保留 | | `navigation.tabs` | 标签页(`tab0`、`tab1`…)及其分组 | | 页面字符串 `"guides/quickstart"` | `{ page: "Quickstart", path: "guides/quickstart.mdx" }` | 自动转换是「尽力而为」:OpenAPI、版本、语言、锚点(`navigation.global.anchors` 会转成 [`sidebar-links`](https://docs.butterix.com/guides/configuration/docs-yml.md#侧栏链接),其余不转换)、重定向、页脚、页头链接等**不会**被转换。正式迁移时请改写为 `docs.yml`。 > **Warning** > > 地址会发生变化:ButterIX 的分区默认贡献一段 URL,页面段由标题生成。Mintlify 中 `/quickstart` 这样的页面,转换后可能变成 `/get-started/quickstart`。改写 `docs.yml` 时用 `skip-slug: true` 与 `slug` 保持原有地址,或添加 `redirects`。 ## 第二步:改写为 docs.yml ```json docs.json(Mintlify) { "name": "Acme", "logo": { "light": "/logo/light.svg", "dark": "/logo/dark.svg" }, "colors": { "primary": "#7C5CFF", "light": "#9E8AFF" }, "navigation": { "tabs": [ { "tab": "Guides", "groups": [ { "group": "Get started", "pages": ["index", "quickstart"] } ] }, { "tab": "API reference", "openapi": "openapi.json" } ] }, "redirects": [{ "source": "/old", "destination": "/quickstart" }] } ``` ```yaml docs.yml(ButterIX) title: Acme logo: light: logo/light.svg dark: logo/dark.svg colors: accent-primary: light: "#7C5CFF" dark: "#9E8AFF" tabs: guides: display-name: Guides skip-slug: true api: display-name: API reference slug: api-reference navigation: - tab: guides layout: - section: Get started skip-slug: true # 保持 Mintlify 的扁平地址 contents: - page: Introduction path: index.mdx slug: index - page: Quickstart path: quickstart.mdx slug: quickstart - tab: api layout: - api: API reference openapi: openapi.json redirects: - source: /old destination: /quickstart ``` `docs.yml` 存在时优先于 `docs.json`。确认无误后可以删除 `docs.json`。 ## 组件兼容性 Mintlify 的组件与属性都有对应实现: | Mintlify | 说明 | | ----------------------------------------------------------- | -------------------------------------------------------------------- | | `<Note>` `<Info>` `<Warning>` `<Tip>` `<Check>` `<Danger>` | 提示框;`<Callout icon color iconType>` 中的 `color` 映射到最接近的样式 | | `<Card>` `<CardGroup>` `<Columns>` | 支持 `img`、`horizontal`、`cta`、`arrow`、`iconType`、`color` | | `<Accordion>` `<AccordionGroup>` `<Expandable>` | 支持 `description`、`icon`、`defaultOpen` | | `<Tabs>` `<Tab>` | 支持 `icon` 与 `sync` | | `<Steps>` `<Step>` | 支持 `stepNumber`、`titleSize`、`icon` | | `<CodeGroup>` | 同名 | | `<ParamField>` | 支持 `query` / `path` / `body` / `header="name"` 写法,`placeholder` 被忽略 | | `<ResponseField>` | 支持 `pre`、`post` | | `<Frame>` | 支持 `caption`、`hint` | | `<Tooltip>` | 支持 `headline`、`cta`、`href` | | `<Badge>` | 支持 `color`、`size`、`shape`、`stroke`(映射为 `outlined`)、`icon`、`disabled` | | `<Tree>` `<Tree.Folder>` `<Tree.File>` | 映射为文件树 | | `<Panel>` `<Banner>` `<Update>` `<Icon>` `<Tile>` `<Color>` | 同名 | 全部组件见[组件总览](https://docs.butterix.com/components/overview.md)。 ## 片段 `import Snippet from "/snippets/x.mdx"` 后以 `<Snippet />` 使用的写法完全支持。**不支持**在片段中用 `export const X = () => …` 定义 JSX 组件或函数——ButterIX 不执行 MDX 中的 JavaScript。把这类组件改写为普通片段,或换成内置组件,见[安全子集](https://docs.butterix.com/guides/writing/safe-mdx.md)。 ## OpenAPI Mintlify 在 `docs.json` 中引用的 OpenAPI 文件可以原样使用,在 `docs.yml` 的 `api` 节点里写出路径即可。Mintlify 为每个端点单独写的 `.mdx` 页面(frontmatter 中的 `openapi: "POST /users"`)不再需要,ButterIX 会自动为每个端点生成页面;需要在指南中引用某个端点时,使用 `<EndpointRequestSnippet endpoint="POST /users" />`。 ## 检查清单 ### biti check 处理所有错误,特别是 `mdx/import`(导入了非 MDX 模块)与 `mdx/esm`(导出了函数)。 ### 改写 docs.yml 补上 OpenAPI、重定向、页头链接、页脚等未自动转换的配置。 ### 核对地址 对照旧站点地图,用 `slug` / `skip-slug` 或 `redirects` 保持原有地址。 ### 发布 `biti deploy`,或在控制台连接 Git 仓库。 --- # 常见问题 > ButterIX 常见问题:与其他文档平台的关系、组件不渲染、中文 URL、隐藏页面、站内搜索、OpenAPI 版本、开发预览中的搜索与 Ask AI、AI 索引更新、分析、RTL 与资源路径。 <details open> <summary>ButterIX 和 Fern、Mintlify 是什么关系?</summary> ButterIX 是一个独立实现的文档平台,与 Fern、Postman、Mintlify 没有关联。为了降低迁移成本,`docs.yml` 的字段与 Fern 保持一致,组件同时兼容 Fern 与 Mintlify 的写法,`fern/docs.yml` 与 `docs.json` 都可以被直接读取。见[从 Fern 迁移](https://docs.butterix.com/guides/reference/migrate-from-fern.md)与[从 Mintlify 迁移](https://docs.butterix.com/guides/reference/migrate-from-mintlify.md)。 </details> <details> <summary>我写的组件没有渲染出来</summary> 运行 `biti check`: - `mdx/unknown-component`:组件名拼错,或使用了 ButterIX 没有的组件(包括自定义 React 组件)。`biti components` 列出全部可用组件。 - `mdx/attribute`:属性值不是字面量,例如 `lines={[1-3]}` 或箭头函数。 - `mdx/parse`:MDX 语法错误,常见于未闭合的标签和正文中未转义的 `{`、`<`。 原因见[安全子集](https://docs.butterix.com/guides/writing/safe-mdx.md)。 </details> <details> <summary>为什么我的页面地址里有中文?</summary> 页面与分区的 URL 段默认由导航中的标题生成,中文字符会被保留。请在导航中为每个页面和分区写上 `slug`,见[导航 › slug 规则](https://docs.butterix.com/guides/configuration/navigation.md#slug-规则)。OpenAPI 端点用 `x-fern-sdk-method-name` 指定英文 URL。 </details> <details> <summary>如何让页面可以访问,但不出现在侧栏?</summary> 在导航中给页面加 `hidden: true`。页面照常构建,可以通过地址访问,但不出现在侧栏、上一页 / 下一页与 `llms.txt` 中。若还不希望被搜索引擎收录,再加 `noindex: true`。 </details> <details> <summary>站内搜索需要服务器吗?</summary> 不需要。搜索索引由 Pagefind 在构建时生成(`/_biti/pagefind/`),在浏览器中按需加载分片。按 / 或 Ctrl + K 打开搜索。 </details> <details> <summary>支持哪些 OpenAPI 版本?</summary> OpenAPI 3.1、3.0 与 Swagger 2.0,YAML 或 JSON。加载时统一升级到 3.1 并解引用 `$ref`。OpenAPI 3.1 的 `webhooks` 会生成 Webhook 页面,`text/event-stream` 响应会按事件流展示。 </details> <details> <summary>biti dev 预览中搜索与 Ask AI 用不了</summary> `biti dev` 是仅用于开发的预览,点击搜索或 Ask AI 只给出提示;两者在发布后的站点上可用。发布前想试 Ask AI,可以在控制台的站点设置里[测试提问](https://docs.butterix.com/guides/features/ask-ai.md#在控制台中配置)。 </details> <details> <summary>改了文档以后,Ask AI 和 MCP 什么时候能看到新内容?</summary> 检索索引在每次构建时生成,随部署一起发布。新的生产部署上线后立即生效。注意只有默认版本的页面会被收录。 </details> <details> <summary>如何接入 Google Analytics?</summary> 在 `docs.yml` 中设置 `analytics.ga4.measurement-id`。也支持 Google Tag Manager、Plausible、PostHog 与 Segment。托管平台另有区分人类与 AI 流量的服务器端分析,见[分析](https://docs.butterix.com/guides/features/analytics.md)。 </details> <details> <summary>支持阿拉伯语等从右到左的语言吗?</summary> 支持。`languages` 中的 `ar`、`he`、`fa` 等语言会自动在页面上输出 `dir="rtl"`,按从右到左的方向排版。 </details> <details> <summary>英文译文里的图片不显示</summary> 译文位于 `translations/en/pages/…`,相对路径会指向不存在的位置。请改用以 `/` 开头的项目根路径,例如 `/assets/diagram.svg`。见[图片与媒体](https://docs.butterix.com/guides/writing/media.md#资源路径)。 </details> <details> <summary>旧版本的页面会和新版本争夺搜索排名吗?</summary> 不会。旧版本页面的 canonical 自动指向默认版本中的同一页面,见[多版本](https://docs.butterix.com/guides/features/versions.md)。 </details> <details> <summary>biti deploy 提示 Not logged in</summary> 先运行 `biti login`,或在 CI 中设置 `BITI_TOKEN`(自托管平台时再设置 `BITI_API` 为你的平台地址)。见 [CLI 部署与 API Key](https://docs.butterix.com/guides/deploy/cli-deploy.md)。 </details> 还有其他问题?在任意页面点击 **Ask AI** 提问,或者把本站的 [MCP 服务器](https://docs.butterix.com/guides/features/agents.md#站点-mcp-服务器)接入你的编辑器。 --- # 组件总览 > ButterIX 全部 MDX 组件的分类索引:提示与标记、布局、标签页与折叠、内容、按钮与链接、代码、API 与工具组件,每个组件一页,以及组件的通用约定。 组件直接写在 MDX 中,**不需要 `import`**。所有组件都在构建时渲染为静态 HTML,交互(切换标签、复制、折叠……)由 ButterIX 的浏览器脚本统一提供。 ```mdx <Note>这是一条提示。</Note> <CardGroup cols={2}> <Card title="快速开始" icon="lucide:rocket" href="/guides/get-started/quickstart">五分钟上手</Card> <Card title="API 参考" icon="lucide:code" href="/api-reference">全部接口</Card> </CardGroup> ``` > **Note** > > 这是一条提示。 [**快速开始**](https://docs.butterix.com/guides/get-started/quickstart.md) 五分钟上手 [**API 参考**](https://docs.butterix.com/api-reference.md) 全部接口 ## 分类索引 ### 提示与标记 [**提示框**](https://docs.butterix.com/components/callout.md) `<Callout>` [**横幅**](https://docs.butterix.com/components/banner.md) `<Banner>` [**徽章**](https://docs.butterix.com/components/badge.md) `<Badge>` [**工具提示**](https://docs.butterix.com/components/tooltip.md) `<Tooltip>` ### 布局 [**卡片**](https://docs.butterix.com/components/card.md) `<Card>` [**磁贴**](https://docs.butterix.com/components/tile.md) `<Tile>` [**分栏**](https://docs.butterix.com/components/columns.md) `<Columns>` [**侧栏**](https://docs.butterix.com/components/aside.md) `<Aside>` [**缩进**](https://docs.butterix.com/components/indent.md) `<Indent>` [**框架**](https://docs.butterix.com/components/frame.md) `<Frame>` ### 标签页与折叠 [**标签页**](https://docs.butterix.com/components/tabs.md) `<Tabs>` [**步骤**](https://docs.butterix.com/components/steps.md) `<Steps>` [**折叠面板**](https://docs.butterix.com/components/accordion.md) `<Accordion>` [**可展开内容**](https://docs.butterix.com/components/expandable.md) `<Expandable>` [**版本**](https://docs.butterix.com/components/versions.md) `<Versions>` [**滚动讲解**](https://docs.butterix.com/components/scroll-walkthrough.md) `<ScrollWalkthrough>` ### 内容 [**表格**](https://docs.butterix.com/components/table.md) `<Table>` [**文件树**](https://docs.butterix.com/components/files.md) `<Files>` [**提示词**](https://docs.butterix.com/components/prompt.md) `<Prompt>` [**更新条目**](https://docs.butterix.com/components/update.md) `<Update>` [**色板**](https://docs.butterix.com/components/color.md) `<Color>` [**图标**](https://docs.butterix.com/components/icon.md) `<Icon>` [**视频**](https://docs.butterix.com/components/video.md) `<Video>` [**实况照片**](https://docs.butterix.com/components/live-photo.md) `<LivePhoto>` [**图片对比**](https://docs.butterix.com/components/image-compare.md) `<ImageCompare>` [**嵌入**](https://docs.butterix.com/components/embed.md) `<Embed>` ### 按钮与链接 [**按钮**](https://docs.butterix.com/components/button.md) `<Button>` [**GitHub 仓库**](https://docs.butterix.com/components/github-repo.md) `<GitHub.Repo>` [**复制**](https://docs.butterix.com/components/copy.md) `<Copy>` [**下载**](https://docs.butterix.com/components/download.md) `<Download>` [**锚点**](https://docs.butterix.com/components/anchor.md) `<Anchor>` ### 代码 [**代码组**](https://docs.butterix.com/components/code-group.md) `<CodeGroup>` [**代码块**](https://docs.butterix.com/components/code-block.md) `<CodeBlock>` [**引用文件代码**](https://docs.butterix.com/components/code.md) `<Code>` ### API [**参数字段**](https://docs.butterix.com/components/param-field.md) `<ParamField>` [**响应字段**](https://docs.butterix.com/components/response-field.md) `<ResponseField>` [**端点请求片段**](https://docs.butterix.com/components/endpoint-request-snippet.md) `<EndpointRequestSnippet>` [**端点响应片段**](https://docs.butterix.com/components/endpoint-response-snippet.md) `<EndpointResponseSnippet>` [**端点 Schema 片段**](https://docs.butterix.com/components/endpoint-schema-snippet.md) `<EndpointSchemaSnippet>` [**Webhook 负载片段**](https://docs.butterix.com/components/webhook-payload-snippet.md) `<WebhookPayloadSnippet>` [**Schema**](https://docs.butterix.com/components/schema.md) `<Schema>` [**可运行端点**](https://docs.butterix.com/components/runnable-endpoint.md) `<RunnableEndpoint>` ### 工具 [**Markdown 片段**](https://docs.butterix.com/components/markdown.md) `<Markdown>` [**条件渲染**](https://docs.butterix.com/components/if.md) `<If>` ## 通用约定 <details open> <summary>属性只能是字面量</summary> 字符串写在引号里(`title="快速开始"`),其他值写在花括号里(`cols={2}`、`defaultOpen`、`tags={["AI"]}`)。不能写函数、变量运算(`+` 拼接与 `export const` 声明的常量除外)。见[安全子集](https://docs.butterix.com/guides/writing/safe-mdx.md)。 </details> <details> <summary>常见的别名都可用</summary> 每个组件都注册了常见的别名,例如 `<CodeGroup>` / `<CodeBlocks>` / `<CodeTabs>`、`<Files>` / `<Tree>`、`<Accordion>` / `<Collapse>`。属性也接受常见的别名,例如 `<Card src>` 与 `<Card img>`。 </details> <details> <summary>图标写法</summary> 所有 `icon` 属性接受 Font Awesome 名称(`rocket`、`fa-solid fa-bolt`、`fa-brands fa-github`)、`lucide:<名称>`、图片地址或内联 `<svg>`,见[可用的图标](https://docs.butterix.com/components/icon.md#可用的图标)。图标在构建时打包进页面级 sprite。 </details> <details> <summary>className</summary> 大多数组件接受 `className`,配合 `docs.yml` 的 `css` 自定义样式。 </details> <details> <summary>Markdown 版本</summary> 每个组件都定义了到 Markdown 的转换(例如提示框变为引用块、标签页展开为小节),页面的 `.md` 版本与 `llms-full.txt` 因此保持可读。 </details> ## 在终端查看 ```bash biti components # 按类别列出组件、别名与属性 biti components --json # 机器可读,适合编码 Agent ``` 控制台的可视化编辑器使用同一份清单生成属性面板,API 为 [`GET /components`](https://docs.butterix.com/api-reference/editor/list-components.md)。 --- # 提示框 > <Callout> 及其别名 <Note>、<Info>、<Warning>、<Tip>……用颜色和图标突出重要信息。 用颜色和图标突出重要信息。最常用的写法是直接使用别名: ```mdx <Note>Note:补充说明。</Note> <Info>Info:一般信息。</Info> <Tip>Tip:实用技巧。</Tip> <Check>Check:已完成或推荐的做法。</Check> <Success>Success:操作成功。</Success> <Warning>Warning:需要注意的风险。</Warning> <Error>Error:错误或破坏性操作。</Error> <Launch>Launch:新功能发布。</Launch> ``` > **Note** > > Note:补充说明。 > **Info** > > Info:一般信息。 > **Tip** > > Tip:实用技巧。 > **Check** > > Check:已完成或推荐的做法。 > **Success** > > Success:操作成功。 > **Warning** > > Warning:需要注意的风险。 > **Error** > > Error:错误或破坏性操作。 > **Launch** > > Launch:新功能发布。 ## 标题、图标与富内容 提示框内可以写任何 Markdown 与组件: ````mdx <Callout intent="warning" title="删除站点无法撤销" icon="lucide:trash-2"> 删除后,所有部署、域名映射与分析数据都会被永久清除。 ```bash curl -X DELETE https://api.butterix.com/v1/sites/acme-payments -H "Authorization: Bearer $TOKEN" ``` </Callout> ```` > **删除站点无法撤销** > > 删除后,所有部署、域名映射与分析数据都会被永久清除。 > > ```bash > curl -X DELETE https://api.butterix.com/v1/sites/acme-payments -H "Authorization: Bearer $TOKEN" > ``` 不需要图标时写 `icon={false}`: ```mdx <Info icon={false}>没有图标的提示框。</Info> ``` > **Info** > > 没有图标的提示框。 ## 属性 - `intent` (note | info | warning | success | error | tip | check | launch | danger, default: info): 颜色与默认图标。也接受 `type`、`variant` 作为属性名。`danger` 等同于 `error`。使用别名时自动设置。 - `title` (string): 内容上方的粗体标题。 - `icon` (icon): 自定义图标;`icon={false}` 隐藏图标。默认按 `intent` 选择。 - `iconType` (solid | regular | brands, default: solid): `icon` 只写图标名称时使用的 Font Awesome 样式:`solid` 实心、`regular` 线框、`brands` 品牌;`light`、`thin`、`duotone` 按线框显示。`icon` 写了完整类名(如 `fa-regular fa-bell`)或 `lucide:` 图标时不起作用。 - `color` (color): 自定义颜色(`#hex`),会映射到最接近的 `intent`。 - `className` (string): 额外的 CSS 类。 ## 别名对照 | 写法 | 等价于 | | ----------- | ------------------------------------ | | `<Note>` | `<Callout intent="note">` | | `<Info>` | `<Callout intent="info">` | | `<Warning>` | `<Callout intent="warning">` | | `<Tip>` | `<Callout intent="tip">` | | `<Check>` | `<Callout intent="check">` | | `<Success>` | `<Callout intent="success">` | | `<Error>` | `<Callout intent="error">` | | `<Danger>` | `<Callout intent="danger">`(同 error) | | `<Launch>` | `<Callout intent="launch">` | 在页面的 Markdown 版本中,提示框被转换为带标题的引用块。 --- # 横幅 > <Banner> 页面内的通知条,适合提示弃用或迁移。 页面内的通知条,适合放在页面顶部提示弃用或迁移。站点级的公告请使用 `docs.yml` 的 [`announcement`](https://docs.butterix.com/guides/configuration/docs-yml.md#公告栏)。 ```mdx <Banner dismissible variant="subtle"> 这是一个可以关闭的页面内通知条,关闭后刷新页面也不会再出现。 </Banner> ``` > 这是一个可以关闭的页面内通知条,关闭后刷新页面也不会再出现。 - `dismissible` (boolean, default: false): 显示关闭按钮;关闭状态保存在浏览器中。 - `variant` (solid | subtle, default: solid): `subtle` 为浅色背景。 - `id` (string): 记忆关闭状态的键,默认取内容的哈希(修改内容后会重新显示)。 --- # 徽章 > <Badge>(别名 <Pill>)行内的小标签,用来标注状态、版本或方法。 行内的小标签(别名 `<Pill>`): ```mdx <Badge intent="success">稳定</Badge> <Badge intent="warning" minimal>Beta</Badge> <Badge intent="error" outlined>已弃用</Badge> <Badge intent="violet" icon="lucide:sparkles">AI</Badge> <Badge color="blue" shape="pill" size="sm">胶囊</Badge> <Badge mono>v1.2.0</Badge> ``` `稳定` `Beta` `已弃用` `AI` `胶囊` `v1.2.0` - `intent` (success | note | tip | warning | error | info | launch | check | violet | orange, default: info): 颜色。 - `color` (blue | green | yellow | orange | red | purple | gray | white | surface | …): 颜色名,映射到最接近的 `intent`(blue→note、green→success、yellow→warning、red→error、purple→violet,gray / white / surface→info)。 - `minimal` (boolean, default: false): 浅色背景。 - `outlined` (boolean, default: false): 描边样式(也接受 `stroke`)。 - `size` (xs | sm | md | lg, default: md): 尺寸。 - `shape` (rounded | pill, default: rounded): 形状:`rounded` 圆角,`pill` 胶囊。 - `icon` (icon): 前置图标。 - `mono` (boolean, default: false): 等宽字体,适合版本号。 - `disabled` (boolean, default: false): 变暗显示。 --- # 工具提示 > <Tooltip> 鼠标悬停或键盘聚焦时显示的补充说明。 鼠标悬停或键盘聚焦时显示提示,触屏上点按显示: ```mdx 部署是<Tooltip tip="生成后不会再被修改的静态产物目录">不可变的</Tooltip>, 回滚只需切换<Tooltip tip="站点地址指向的部署" headline="生产指针" cta="了解更多" href="/guides/deploy/previews-and-rollbacks">生产指针</Tooltip>。 ``` 部署是不可变的 (生成后不会再被修改的静态产物目录),回滚只需切换生产指针 (站点地址指向的部署)。 - `tip` (string | JSX, required): 提示内容(也接受 `content`、`text`)。 - `side` (top | right | bottom | left, default: top): 优先显示的方向,靠近视口边缘时自动翻转。 - `sideOffset` (number, default: 6): 与触发文字的距离(像素)。 - `headline` (string): 粗体首行。 - `cta` (string): 提示中的链接文字。 - `href` (url): `cta` 的链接地址。 --- # 卡片 > <Card> 与 <CardGroup> 用于导航和概览,可带图标、图片与链接。 卡片用于导航和概览。设置 `href` 后整张卡片可点击;`<CardGroup>`(别名 `<Cards>`)把卡片排成 1–4 列的网格,窄屏时自动折叠为单列。 ```mdx <CardGroup cols={3}> <Card title="快速开始" icon="lucide:rocket" href="/guides/get-started/quickstart"> 五分钟发布第一个站点。 </Card> <Card title="组件" icon="lucide:blocks" iconPosition="left"> 图标在左侧。 </Card> <Card title="品牌色" icon="lucide:palette" color="#7C5CFF"> 自定义图标颜色。 </Card> </CardGroup> ``` [**快速开始**](https://docs.butterix.com/guides/get-started/quickstart.md) 五分钟发布第一个站点。 **组件** 图标在左侧。 **品牌色** 自定义图标颜色。 ## 带图片与横向卡片 ```mdx <CardGroup cols={2}> <Card title="构建管线" src="/assets/pipeline.svg" href="/guides/get-started/concepts"> 从源文件到静态产物。 </Card> <Card title="横向卡片" icon="lucide:terminal" horizontal arrow href="/guides/reference/cli" cta="查看 CLI"> horizontal、arrow 与 cta。 </Card> </CardGroup> ``` [**构建管线**](https://docs.butterix.com/guides/get-started/concepts.md) 从源文件到静态产物。 [**横向卡片**](https://docs.butterix.com/guides/reference/cli.md) horizontal、arrow 与 cta。 ## Card 属性 - `title` (string): 卡片标题。 - `icon` (icon): 图标,也可以是 JSX(如 `<img />`)。 - `href` (url): 让整张卡片成为链接。推荐写源文件路径(`./quickstart.mdx`)。 - `target` (string): 链接目标,外部链接默认 `_blank`。 - `iconPosition` (top | left, default: top): 图标位置。 - `iconSize` (number, default: 8): 图标大小,以 4px 为单位(默认 8 = 32px)。 - `color` (color): 图标颜色(深浅模式通用)。 - `lightModeColor / darkModeColor` (color): 分别指定浅色 / 深色模式下的图标颜色。 - `src` (url): 卡片图片(也接受 `img`、`image`)。 - `imagePosition` (top | left | right | bottom, default: top): 图片位置。 - `imageWidth / imageHeight` (string): 图片尺寸,例如 `200px`、`50%`。 - `horizontal` (boolean, default: false): 紧凑的横向布局:图标与标题排在一行。 - `cta` (string): 卡片底部的行动文字,例如「查看文档」。 - `arrow` (boolean): 右上角显示箭头。 - `iconType` (solid | regular | brands, default: solid): `icon` 只写图标名称时使用的 Font Awesome 样式:`solid` 实心、`regular` 线框、`brands` 品牌;`light`、`thin`、`duotone` 按线框显示。`icon` 写了完整类名(如 `fa-regular fa-bell`)或 `lucide:` 图标时不起作用。 ## CardGroup 属性 - `cols` (number, default: 2): 列数,1–4(也接受 `columns`)。 --- # 磁贴 > <Tile> 带预览区的链接卡片,适合展示示例、模板或集成。 带预览区的链接卡片,适合展示示例、模板或集成: ```mdx <Columns cols={2}> <Tile href="/guides/features/agents" title="Agent 友好" description=".md、llms.txt 与 MCP"> ![](/assets/favicon.svg) </Tile> <Tile href="/api-reference" title="平台 API" img="/assets/pipeline.svg" description="从 OpenAPI 生成" /> </Columns> ``` [**Agent 友好**](https://docs.butterix.com/guides/features/agents.md) — .md、llms.txt 与 MCP [**平台 API**](https://docs.butterix.com/api-reference.md) — 从 OpenAPI 生成 - `href` (url, required): 链接目标。 - `title` (string): 预览下方的标题。 - `description` (string): 说明文字。 - `img` (url): 预览图片(也接受 `src`、`image`)。不设置时,子内容作为预览区。 --- # 分栏 > <Columns>(别名 <Grid>)与 <Column> 通用的 1–4 列布局,窄屏时自动折叠。 通用的多列布局(别名 `<Grid>`),1–4 列,窄屏折叠: ```mdx <Columns cols={2}> <Column> **左栏**:任意 Markdown 与组件。 </Column> <Column> **右栏**:可以放代码块、图片…… </Column> </Columns> ``` **左栏**:任意 Markdown 与组件。 **右栏**:可以放代码块、图片…… - `cols` (number, default: 2): 列数,1–4(也接受 `columns`)。 - `widths` (string): 各列宽度,空格分隔:数字是比例(`2 1` 为三分之二 / 三分之一),`*` 为等分,也可以写 `40%`、`320px`。768px 以上生效,更窄时照常折叠。在可视化编辑器里拖动列之间的空隙即可调整,右侧各列按比例一起缩放,双击恢复等宽。 ## 自定义列宽 ```mdx <Columns widths="2 1"> <Column>**三分之二**:正文、代码示例……</Column> <Column>**三分之一**:补充说明</Column> </Columns> ``` **三分之二**:正文、代码示例…… **三分之一**:补充说明 --- # 侧栏 > <Aside> 与 <Panel> 宽屏时把内容放到正文右侧并在滚动时保持可见。 `<Aside>`(别名 `<Panel>`、`<RightPanel>`)把内容放到正文右侧并在滚动时保持可见(宽屏),窄屏时显示在原位置。适合放与正文对照的代码或说明。 ````mdx <Aside> ```bash biti deploy --preview ``` </Aside> ```` --- # 缩进 > <Indent> 缩进一段内容,可显示引导线。 把内容缩进 16px,`line` 显示一条引导线: ```mdx <Indent line> 缩进的内容,常用于表示从属关系。 </Indent> ``` 缩进的内容,常用于表示从属关系。 - `line` (boolean, default: false): 显示左侧引导线。 --- # 框架 > <Frame>(别名 <Figure>)给图片、视频或内嵌内容加边框与说明。 更多关于图片路径、尺寸与资源复制的说明见[图片与媒体](https://docs.butterix.com/guides/writing/media.md)。 给图片、视频或内嵌内容加边框与说明(别名 `<Figure>`): ```mdx <Frame caption="ButterIX 构建管线" hint="点击图片可以放大"> ![构建管线](/assets/pipeline.svg) </Frame> ``` > 点击图片可以放大 ![构建管线](https://docs.butterix.com/_biti/files/assets/pipeline.svg) _ButterIX 构建管线_ - `caption` (string): 媒体下方的说明文字。 - `background` (default | subtle, default: default): `subtle` 为柔和的背景色。 - `hint` (string): 框架上方的提示。 --- # 标签页 > <Tabs>(别名 <TabGroup>)与 <Tab> 把平行内容放进标签页,可跨页面同步所选标签。 把平行的内容放进标签页(别名 `<TabGroup>`)。没有 JavaScript 时也能切换。 ````mdx <Tabs> <Tab title="macOS" icon="fa-brands fa-apple"> ```bash brew install node ``` </Tab> <Tab title="Windows" icon="fa-brands fa-windows"> 从 nodejs.org 下载安装包。 </Tab> <Tab title="Linux" icon="fa-brands fa-linux"> 使用发行版的包管理器,或 nvm。 </Tab> </Tabs> ```` **macOS** ```bash brew install node ``` **Windows** 从 nodejs.org 下载安装包。 **Linux** 使用发行版的包管理器,或 nvm。 ## 跨页面同步 三种同步方式,选择会保存在浏览器中,访问其他页面时依然生效: | 写法 | 同步范围 | | ------------------------- | ------------------------- | | `<Tab language="python">` | 与全站所有同语言的代码组、API 示例和标签页同步 | | `<Tabs group="os">` | 与全站 `group` 相同、标题相同的标签页同步 | | `<Tabs sync>` | 与所有设置了 `sync` 的标签页按标题同步 | 下面两组标签页设置了相同的 `group="os"`,切换其中一组,另一组会跟着切换: **macOS** 第一组:macOS **Linux** 第一组:Linux **macOS** 第二组:macOS **Linux** 第二组:Linux ## Tabs 属性 - `group` (string): 同步分组(也接受 `syncKey`、`groupId`)。 - `sync` (boolean, default: false): 与所有设置了 `sync` 的标签页按标题同步。 - `defaultTabIndex` (number, default: 0): 初始选中的标签(从 0 开始,也接受 `defaultIndex`)。 ## Tab 属性 - `title` (string, required): 标签文字。 - `language` (string): 与全站同语言的代码块共享同步键。 - `icon` (icon): 标签前的图标。 - `id` (string): 面板 id,访问 `#id` 时自动选中该标签。 --- # 步骤 > <Steps> 与 <Step> 带编号的操作步骤,可加入目录。 带编号的操作步骤: ````mdx <Steps> <Step title="安装"> ```bash npm install -g bitidocs ``` </Step> <Step title="创建项目"> 运行 `biti init my-docs`。 </Step> <Step title="发布" icon="lucide:rocket"> 运行 `biti deploy`。图标代替了编号。 </Step> </Steps> ```` ### 安装 ```bash npm install -g bitidocs ``` ### 创建项目 运行 `biti init my-docs`。 ### 发布 运行 `biti deploy`。图标代替了编号。 ## 用标题生成步骤 `<Steps>` 内直接写 Markdown 标题时,每个标题开始一个新步骤,而且这些步骤会出现在右侧目录中: ```mdx <Steps> ### 准备环境 安装 Node.js 22.13 或更高版本。 ### 初始化 运行 `biti init`。 </Steps> ``` ### 准备环境 安装 Node.js 22.13 或更高版本。 ### 初始化 运行 `biti init`。 ## Steps 属性 - `titleSize` (p | h2 | h3): 步骤标题的大小,默认 `p`(与正文同大)。 - `toc` (boolean, default: false): 把 `<Step title>` 形式的步骤也列入目录。基于标题的步骤总是出现在目录中。 - `tocDepth` (number): 步骤在目录中的层级,1–3。 ## Step 属性 - `title` (string): 步骤标题。 - `id` (string): 锚点 id,默认由标题生成。 - `icon` (icon): 用图标代替编号。 - `stepNumber` (number): 显式指定编号。 - `titleSize` (p | h2 | h3): 该步骤标题的大小。 --- # 折叠面板 > <Accordion> 与 <AccordionGroup> 默认收起的内容区块。 可折叠的内容,基于原生 `<details>`,没有 JavaScript 也能用。`<AccordionGroup>` 把多个折叠项合并成一个带边框的组。 ```mdx <AccordionGroup> <Accordion title="支持哪些包管理器?" icon="lucide:package" defaultOpen> npm、pnpm、yarn 都可以全局安装 `bitidocs`。 </Accordion> <Accordion title="需要什么版本的 Node.js?" description="标题下方的一行说明"> 22.13 或更高版本。 </Accordion> <Accordion title="可以只展开一个吗?" name="faq"> 给同组的折叠项设置相同的 `name`,打开一个时会自动关闭其他的。 </Accordion> </AccordionGroup> ``` <details open> <summary>支持哪些包管理器?</summary> npm、pnpm、yarn 都可以全局安装 `bitidocs`。 </details> <details> <summary>需要什么版本的 Node.js?</summary> 22.13 或更高版本。 </details> <details> <summary>可以只展开一个吗?</summary> 给同组的折叠项设置相同的 `name`,打开一个时会自动关闭其他的。 </details> ## Accordion 属性 - `title` (string, required): 标题。 - `description` (string): 标题下方的副标题。 - `defaultOpen` (boolean, default: false): 默认展开(也接受 `open`)。 - `icon` (icon): 标题前的图标。 - `id` (string): 锚点 id,默认由标题生成;访问 `#id` 时自动展开。 - `name` (string): 互斥分组名:同名的折叠项同一时间只展开一个。 别名:`<Collapse>`。 --- # 可展开内容 > <Expandable> 折叠嵌套字段或次要内容。 用于折叠嵌套字段的列表,通常放在 `<ParamField>` 或 `<ResponseField>` 内部: ```mdx <ResponseField name="domain" type="object"> 域名对象。 <Expandable title="属性"> <ResponseField name="domain" type="string">完整域名。</ResponseField> <ResponseField name="verified" type="boolean">是否已验证。</ResponseField> </Expandable> </ResponseField> ``` - `domain` (object): 域名对象。 - `domain` (string): 完整域名。 - `verified` (boolean): 是否已验证。 - `title` (string): 按钮文字,默认「显示 N 个属性」。 - `defaultOpen` (boolean, default: false): 默认展开(也接受 `open`)。 --- # 版本 > <Versions> 与 <Version> 页面内的版本切换器。 页面内的版本切换器,所选版本保存在 `?v=` 参数中。示例与说明见[多版本 › 页内版本](https://docs.butterix.com/guides/features/versions.md#页内版本versions-组件)。 - `Versions › paramName` (string, default: v): 保存选择的查询参数名。 - `Version › version` (string, required): 唯一 id,出现在地址中。 - `Version › title` (string): 下拉菜单中的名称,默认同 `version`。 - `Version › default` (boolean, default: false): 地址中没有版本参数时显示。 --- # 滚动讲解 > <ScrollWalkthrough>(别名 <Walkthrough>)边滚动边讲解代码,代码面板跟随当前步骤高亮。 滚动驱动的讲解(别名 `<Walkthrough>`):左侧是步骤,右侧是跟随当前步骤高亮的代码面板。每个围栏代码块是面板中的一个文件(语言后的文字是文件名)。 ````mdx <ScrollWalkthrough> <Step title="创建客户端" file="deploy.ts" focus="1-3"> 读取 API Key 与平台地址。 </Step> <Step title="上传" focus="5-10"> 以 gzip tar 包上传源码,得到部署 id。 </Step> <Step title="等待完成" focus="12-17"> 每秒查询一次状态,直到 ready 或 failed。 </Step> ```ts deploy.ts const api = process.env.BITI_API ?? "https://console.butterix.com"; … ``` </ScrollWalkthrough> ```` ### 创建客户端 读取 API Key 与平台地址。 ### 上传 以 gzip tar 包上传源码,得到部署 id。 ### 等待完成 每秒查询一次状态,直到 ready 或 failed。 ```ts deploy.ts const api = process.env.BITI_API ?? "https://console.butterix.com"; const token = process.env.BITI_TOKEN!; const headers = { authorization: `Bearer ${token}` }; const res = await fetch(`${api}/api/v1/sites/acme-payments/deployments`, { method: "POST", headers: { ...headers, "content-type": "application/gzip", "x-biti-preview": "1" }, body: await readFile("site.tgz"), }); const { id } = await res.json(); for (;;) { await new Promise((r) => setTimeout(r, 1000)); const d = await (await fetch(`${api}/api/v1/deployments/${id}`, { headers })).json(); if (d.status === "ready") { console.log(d.url); break; } if (d.status === "failed") throw new Error(d.error); } ``` - `layout` (default | wide, default: default): `wide` 让代码面板更宽。 - `panelHeight` (string): 代码面板高度,例如 `32rem`。 - `stickyHeaders` (boolean, default: true): 子步骤滚动时固定步骤标题。 - `dim` (boolean, default: true): 淡化非当前步骤。 - `substepStyle` (step | bullet, default: step): 子步骤用编号还是圆点。 `<Step>` 在这里额外支持 `file`(文件名或从 0 开始的序号)、`focus`、`highlight`、`startLine`;步骤内可以再放 `<Substep title file focus highlight startLine id>`(别名 `<SubStep>`)细分。 --- # 表格 > <Table> 与 Markdown 表格:列宽、横向滚动、固定表头与首列、搜索与分页。 包住一个 Markdown 表格(或 HTML 表格),控制列宽、最小宽度与固定表头 / 首列。不包也能用:Markdown 表格默认按内容估算列宽,放不下时横向滚动。 ## 列宽 `widths` 按列依次写宽度,空格分隔:数字为 px,也可写 `12rem`、`30%`、`auto`;`*` 表示该列不指定。没写到的列平分剩余宽度。`layout="equal"` 让各列等宽,`layout="content"` 交给浏览器按内容分配。 ```mdx <Table widths="160px * 80px 80px"> | 状态 | 含义 | 可取消 | 可设为生产 | |---|---|---|---| | queued | 排队中 | 是 | 否 | | building | 构建中 | 否 | 否 | | ready | 成功 | 否 | 是 | | failed | 失败 | 否 | 否 | | canceled | 已取消 | 否 | 否 | </Table> ``` | 状态 | 含义 | 可取消 | 可设为生产 | | -------- | --- | --- | ----- | | queued | 排队中 | 是 | 否 | | building | 构建中 | 否 | 否 | | ready | 成功 | 否 | 是 | | failed | 失败 | 否 | 否 | | canceled | 已取消 | 否 | 否 | ## 皮肤 `skin` 给表格换一套外观,亮色、暗色模式都已适配。不写时是素净样式:没有外框和底色,只有行线。可视化编辑器的表格设置里同样可以选,悬停时页面里的表格会先换上看看。 ```mdx <Table skin="framed"> | 参数 | 类型 | 默认值 | |---|---|---| | `region` | string | `ap-sh` | </Table> ``` **边框** | 参数 | 类型 | 默认值 | | --------- | ------ | ------- | | `region` | string | `ap-sh` | | `timeout` | number | `30` | | `retries` | number | `3` | **斑马纹** | 参数 | 类型 | 默认值 | | --------- | ------ | ------- | | `region` | string | `ap-sh` | | `timeout` | number | `30` | | `retries` | number | `3` | **网格** | 参数 | 类型 | 默认值 | | --------- | ------ | ------- | | `region` | string | `ap-sh` | | `timeout` | number | `30` | | `retries` | number | `3` | **卡片** | 参数 | 类型 | 默认值 | | --------- | ------ | ------- | | `region` | string | `ap-sh` | | `timeout` | number | `30` | | `retries` | number | `3` | **简洁** | 参数 | 类型 | 默认值 | | --------- | ------ | ------- | | `region` | string | `ap-sh` | | `timeout` | number | `30` | | `retries` | number | `3` | **三线** | 参数 | 类型 | 默认值 | | --------- | ------ | ------- | | `region` | string | `ap-sh` | | `timeout` | number | `30` | | `retries` | number | `3` | **强调** | 参数 | 类型 | 默认值 | | --------- | ------ | ------- | | `region` | string | `ap-sh` | | `timeout` | number | `30` | | `retries` | number | `3` | **反色表头** | 参数 | 类型 | 默认值 | | --------- | ------ | ------- | | `region` | string | `ap-sh` | | `timeout` | number | `30` | | `retries` | number | `3` | **柔和** | 参数 | 类型 | 默认值 | | --------- | ------ | ------- | | `region` | string | `ap-sh` | | `timeout` | number | `30` | | `retries` | number | `3` | ## 宽于正文的表格 `minWidth` 让表格比正文更宽,横向滚动浏览;还能滑动的一侧会出现阴影。 ```mdx <Table minWidth="960px"> | 参数 | 类型 | 必填 | 默认值 | 取值范围 | 自 | 说明 | |---|---|:---:|---|---|---|---| | `timeout` | number | 否 | `30` | 1–600 | v1.2 | 单次请求的超时秒数,超时后自动重试 | | `region` | string | 是 | – | `cn` / `us` / `eu` | v1.0 | 数据所在区域,创建后不可修改 | | `retries` | number | 否 | `3` | 0–10 | v1.4 | 失败后的最大重试次数,按指数退避 | </Table> ``` | 参数 | 类型 | 必填 | 默认值 | 取值范围 | 自 | 说明 | | --------- | ------ | :-: | ---- | ------------------ | ---- | ----------------- | | `timeout` | number | 否 | `30` | 1–600 | v1.2 | 单次请求的超时秒数,超时后自动重试 | | `region` | string | 是 | – | `cn` / `us` / `eu` | v1.0 | 数据所在区域,创建后不可修改 | | `retries` | number | 否 | `3` | 0–10 | v1.4 | 失败后的最大重试次数,按指数退避 | ## 固定表头与首列 ```mdx <Table stickyHeader stickyFirstColumn maxHeight="240px"> | 状态 | 含义 | 可取消 | 可设为生产 | |---|---|---|---| | queued | 排队中 | 是 | 否 | | building | 构建中 | 否 | 否 | | ready | 成功 | 否 | 是 | | failed | 失败 | 否 | 否 | | canceled | 已取消 | 否 | 否 | </Table> ``` | 状态 | 含义 | 可取消 | 可设为生产 | | -------- | --- | --- | ----- | | queued | 排队中 | 是 | 否 | | building | 构建中 | 否 | 否 | | ready | 成功 | 否 | 是 | | failed | 失败 | 否 | 否 | | canceled | 已取消 | 否 | 否 | ## 搜索与分页 `searchable` 在表格上方加搜索框,按输入实时筛选行(不区分大小写);`paginate` 把行分页,`pageSize` 是每页行数,`expandable` 把翻页换成“显示全部 / 收起”。先筛选再分页。 ```mdx <Table searchable paginate pageSize={4} placeholder="搜索区域"> | 区域 | 位置 | |---|---| | cn-north | 华北 | | cn-east | 华东 | | cn-south | 华南 | | ap-hk | 香港 | | ap-sg | 新加坡 | | us-west | 美西 | | us-east | 美东 | | eu-central | 法兰克福 | </Table> ``` | 区域 | 位置 | | ---------- | ---- | | cn-north | 华北 | | cn-east | 华东 | | cn-south | 华南 | | ap-hk | 香港 | | ap-sg | 新加坡 | | us-west | 美西 | | us-east | 美东 | | eu-central | 法兰克福 | - `widths` (string): 各列宽度,空格分隔,如 `160px 30% auto *`。数字为 px,`*` 表示不指定;指定后未列出的列平分剩余宽度。 - `layout` (smart | equal | content, default: smart): `smart` 按内容估算(同样内容等宽);`equal` 各列等宽;`content` 浏览器自动布局。 - `minWidth` (string): 表格最小宽度,如 `960px`。超过正文宽度时横向滚动(也接受 `min-width`)。 - `stickyHeader` (boolean, default: false): 纵向滚动时表头固定(也接受 `sticky`)。 - `stickyFirstColumn` (boolean, default: false): 横向滚动时保持首列可见(也接受 `sticky-first`)。 - `maxHeight` (string): 固定表头时滚动区域的高度,默认 `min(70vh, 600px)`。 - `searchable` (boolean, default: false): 表格上方显示搜索框,按输入筛选行。 - `placeholder` (string, default: 搜索…): 搜索框的提示文字。 - `paginate` (boolean, default: false): 分页显示,底部有上一页 / 下一页。 - `pageSize` (number, default: 10): 每页行数。 - `expandable` (boolean, default: false): 配合 `paginate`:用“显示全部 / 收起”代替翻页。 - `skin` (default | framed | striped | bordered | card | minimal | academic | accent | contrast | soft, default: default): 皮肤:`framed` 边框与浅底表头、`striped` 斑马纹、`bordered` 网格、`card` 卡片、`minimal` 简洁、`academic` 三线、`accent` 主题色表头、`contrast` 反色表头、`soft` 圆角行。 > **Note** > > `<StickyTable>`、`<SearchableTable>`、`<StickySearchableTable>`、`<PaginatedTable>`、`<PaginatedSearchableTable>` 都可直接使用,分别等同于打开对应开关的 `<Table>`;HTML 写法 `<table sticky searchable paginate pageSize={6} expandable>` 同样支持。合并单元格的写法见 [Markdown 语法 › 合并单元格](https://docs.butterix.com/guides/writing/markdown.md#合并单元格)。 --- # 文件树 > <Files>(别名 <Tree>)可折叠的文件树。 可折叠的文件树(别名 `<Tree>`、`<FileTree>`;`<Tree.Folder>`、`<Tree.File>` 同样可用): ```mdx <Files> <Folder name="my-docs" defaultOpen> <File name="docs.yml" highlighted comment="站点配置" /> <Folder name="pages" defaultOpen> <File name="introduction.mdx" href="/guides/get-started/introduction" /> </Folder> <Folder name="assets"> <File name="logo.svg" /> </Folder> </Folder> </Files> ``` ``` my-docs/ docs.yml pages/ introduction.mdx assets/ logo.svg ``` `<Folder>` 与 `<File>` 共有的属性: - `name` (string, required): 显示的名称。 - `href` (url): 让名称成为链接。 - `highlighted` (boolean, default: false): 强调色背景。 - `comment` (string): 名称后的等宽注释(以 `#` 开头显示)。 - `icon` (icon): 自定义图标。 - `defaultOpen` (boolean, default: false): 仅 `<Folder>`:默认展开(也接受 `open`)。 --- # 提示词 > <Prompt> 可复制、可在 AI 工具中打开的提示词块。 一段可以复制、或一键在 AI 工具中打开的提示词: ```mdx <Prompt title="让 AI 帮你写 docs.yml" actions={["claude", "chatgpt", "cursor"]}> 阅读 https://docs.butterix.com/llms.txt,为我的 Express API 项目生成一个包含「指南」和「API 参考」两个标签页的 ButterIX docs.yml。 </Prompt> ``` **让 AI 帮你写 docs.yml** ```text 阅读 <https://docs.butterix.com/llms.txt,为我的> Express API 项目生成一个包含「指南」和「API 参考」两个标签页的 ButterIX docs.yml。 ``` - `title` (string): 标题行;设置后操作按钮移到标题行中。 - `icon` (icon): 提示词左侧的图标。 - `actions` (array): 内置的 `"claude"`、`"chatgpt"`、`"cursor"`,或 `{ label, url, icon }`(`url` 中可以用 `{prompt}` 占位)。第一个为主按钮,其余进入下拉菜单;复制按钮始终存在。 - `hidePrompt` (boolean, default: false): 只显示标题行(需要 `title`)。 - `singleLine` (boolean, default: false): 正文截断为一行。 --- # 更新条目 > <Update> 单条更新记录,左侧是固定的标签列。 单条更新记录,左侧是固定的标签列。适合在普通页面中写版本历史;完整的更新日志(时间线、标签筛选、RSS)请使用[更新日志](https://docs.butterix.com/guides/configuration/changelog.md)。 ```mdx <Update label="2026-11-20" description="v1.0" tags={["AI", "MCP"]}> 每个站点自带 MCP 服务器。 </Update> <Update label="2026-10-15" description="v0.9" tags={["i18n"]}> 新增 `biti translate` 增量翻译。 </Update> ``` ## 2026-11-20 _v1.0_ 每个站点自带 MCP 服务器。 ## 2026-10-15 _v0.9_ 新增 `biti translate` 增量翻译。 - `label` (string, required): 日期或版本,也是默认锚点。 - `description` (string): 标签下方的说明。 - `tags` (string[]): 以徽标显示的标签。 - `id` (string): 自定义锚点。 - `rss` (object): 可以写,但不起作用。 --- # 色板 > <Color>(别名 <Colors>)色板,点击色值即可复制。 色板,点击色值复制(别名 `<Colors>`): ```mdx <Color> <Color.Item name="品牌紫" value="#7C5CFF" /> <Color.Item name="深色模式" value="#9E8AFF" /> <Color.Item name="自适应" value={{ light: "#16131F", dark: "#EDEDF0" }} /> </Color> ``` - **品牌紫**: `#7C5CFF` - **深色模式**: `#9E8AFF` - **自适应**: `#16131F` / `#EDEDF0` `variant="table"` 时用带标题的行组织: ```mdx <Color variant="table"> <Color.Row title="强调色"> <Color.Item name="浅色" value="#7C5CFF" /> <Color.Item name="深色" value="#9E8AFF" /> </Color.Row> </Color> ``` **强调色** - **浅色**: `#7C5CFF` - **深色**: `#9E8AFF` - `Color › variant` (compact | table, default: compact): 网格或带标题的行。 - `Color.Row › title` (string): 行标题。 - `Color.Item › value` (string | { light, dark }, required): CSS 颜色,或分别指定深浅模式。 - `Color.Item › name` (string): 色块下方的名称。 --- # 图标 > <Icon> 随文字缩放的行内图标,支持 Font Awesome、Lucide、图片与 SVG。 随文字缩放的行内图标: ```mdx <Icon icon="lucide:rocket" /> <Icon icon="fa-solid fa-bolt" color="#F5A524" /> <Icon icon="lucide:heart" size={6} lightModeColor="#E5484D" darkModeColor="#FF6369" /> <Icon icon="fa-brands fa-github" size={32} /> ``` ## 可用的图标 所有 `icon` 属性,以及导航、页面的 `icon`,都用同一套写法: | 来源 | 写法 | 数量 | | -------------------------------------------------------------- | ------------------------------------- | ------ | | [Lucide](https://lucide.dev/icons) | `lucide:rocket` | 约 2100 | | [Font Awesome Free](https://fontawesome.com/search?ic=free) 实心 | `fa-solid fa-rocket`,或只写 `rocket` | 约 1400 | | Font Awesome Free 线框 | `fa-regular fa-bell` | 约 170 | | Font Awesome Free 品牌 | `fa-brands fa-github` | 约 570 | | 图片 | `https://…` 或仓库里的 `./assets/icon.svg` | — | | SVG | `<svg …>…</svg>` | — | 只写名称时,依次在实心、线框、品牌和 Lucide 里找。导航里的图标还可以放进带边框的小方块,见[图标样式](https://docs.butterix.com/guides/configuration/navigation.md#图标样式)。在可视化编辑器里不用记名称:点图标一栏,直接搜索(英文和常用中文词都可以)、按来源筛选后选中,也可以粘贴图片地址或 SVG。 ## 属性 - `icon` (icon, required): Font Awesome 名称、`lucide:<名称>`、图片地址或 `<svg>`。 - `size` (number | string): 不大于 12 时以 4px 为单位(`4` = 16px),大于 12 时按像素,CSS 长度原样使用。 - `color` (color): 颜色(深浅模式通用)。 - `lightModeColor / darkModeColor` (color): 分别指定浅色 / 深色模式的颜色。 - `iconType` (solid | regular | brands, default: solid): `icon` 只写图标名称时使用的 Font Awesome 样式:`solid` 实心、`regular` 线框、`brands` 品牌;`light`、`thin`、`duotone` 按线框显示。`icon` 写了完整类名(如 `fa-regular fa-bell`)或 `lucide:` 图标时不起作用。 --- # 视频 > <Video> 嵌入本地视频或 YouTube、Vimeo、Loom 等在线视频。 更多关于图片路径、尺寸与资源复制的说明见[图片与媒体](https://docs.butterix.com/guides/writing/media.md)。 视频文件使用原生播放器;YouTube、Vimeo、Loom 链接自动转换为内嵌播放器: ```mdx <Video src="/assets/demo.mp4" poster="/assets/poster.png" /> <Video src="https://www.youtube.com/watch?v=VIDEO_ID" title="产品演示" ratio="16/9" /> <Video src="/assets/loop.mp4" autoplay loop controls={false} /> ``` - `src` (url, required): 视频文件或 YouTube / Vimeo / Loom 地址。 - `poster` (url): 封面图。 - `title` (string): 无障碍标题。 - `controls` (boolean, default: true): 显示控制条。 - `autoplay` (boolean, default: false): 自动播放(会自动静音;也接受 `autoPlay`)。 - `loop` (boolean, default: false): 循环播放。 - `muted` (boolean, default: false): 静音。 - `ratio` (string): 内嵌播放器的宽高比,例如 `16/9`。 --- # 实况照片 > <LivePhoto> 像 iPhone 的实况照片一样:平时显示照片,按住或点左上角的徽标播放视频。 给一张照片配上一段短视频(通常 3 秒左右)。平时显示照片,左上角有实况徽标: - **按住照片**:视频从头播放,松手即停,画面淡回照片。 - **点徽标**:完整播放一遍,再点一次停止;也可以用键盘聚焦徽标后按回车或空格。 ```mdx <LivePhoto src="/assets/media/live.jpg" video="/assets/media/live.mp4" alt="分形图案缓缓放大" /> ``` ![分形图案缓缓放大](/assets/media/live.jpg) [Live Photo video](/assets/media/live.mp4) 照片最好取自视频中间的一帧,播放结束淡回照片时更自然。视频在组件快滚动到时预先加载,按下去就能立即播放。浏览器不允许带声音播放时会自动改为静音播放。 - `src` (url, required): 照片(也接受 `photo`、`image`)。 - `video` (url, required): 视频文件,建议 MP4(H.264),几秒即可。 - `alt` (string): 照片的替代文字。 - `width` (string): 显示宽度,数字按像素,也可以写 CSS 长度;默认占满正文宽度。 - `muted` (boolean, default: false): 静音播放。 --- # 图片对比 > <ImageCompare> 把两张图叠在一起,左右拖动中间的拉杆对比差异。 两张图叠放,分隔线左边是 `before`,右边是 `after`。拖动拉杆或点图片上的任意位置移动分隔线;手机上横向拖动对比,竖向滑动照常滚动页面。 ```mdx <ImageCompare before="/assets/media/compare-before.jpg" after="/assets/media/compare-after.jpg" beforeLabel="低清" afterLabel="高清" alt="同一张图片的低清与高清版本" /> ``` ![低清](/assets/media/compare-before.jpg) ![高清](/assets/media/compare-after.jpg) 两张图的宽高比应当相同;不同时以 `after` 的尺寸为准,`before` 按比例裁切填满。拉杆可以用键盘操作:方向键每次移动 1%,按住 Shift 每次 10%,Home、End 移到两端。打印时两张图并排印出。 - `before` (url, required): 分隔线左边的图片(也接受 `left`)。 - `after` (url, required): 分隔线右边的图片(也接受 `right`)。 - `beforeLabel` (string): 左上角的标签,分隔线靠近时淡出。 - `afterLabel` (string): 右上角的标签,分隔线靠近时淡出。 - `alt` (string): 说明两张图在对比什么,读屏时与标签一起读出。 - `position` (number, default: 50): 分隔线的初始位置,距左边的百分比(0–100)。 - `width` (string): 显示宽度,数字按像素,也可以写 CSS 长度;默认占满正文宽度。 --- # 嵌入 > <Embed>(别名 <IFrame>)响应式 iframe,嵌入在线演示、设计稿或 PDF。 响应式 iframe,适合嵌入在线演示、设计稿或 PDF(别名 `<IFrame>`),默认 16:9: ```mdx <Embed src="https://example.com/demo" title="在线演示" ratio="4/3" /> <Embed src="/assets/whitepaper.pdf" title="白皮书" height="640px" /> ``` - `src` (url, required): 页面、视频或 PDF 地址(也接受 `url`)。 - `title` (string): 无障碍标题。 - `ratio` (string): 宽高比,例如 `16/9`、`4:3`(也接受 `aspectRatio`)。 - `height` (string): 固定高度,代替宽高比。 - `allow` (string): iframe 的 `allow` 权限列表。 --- # 按钮 > <Button> 与 <ButtonGroup> 链接按钮或纯展示按钮。 链接按钮(设置 `href`)或纯展示按钮: ```mdx <ButtonGroup> <Button intent="primary" href="/guides/get-started/quickstart" rightIcon="lucide:arrow-right">快速开始</Button> <Button outlined href="/api-reference" icon="lucide:code">API 参考</Button> <Button minimal href="https://github.com" >GitHub</Button> </ButtonGroup> ``` [快速开始](https://docs.butterix.com/guides/get-started/quickstart.md) [API 参考](https://docs.butterix.com/api-reference.md) [GitHub](https://github.com) 更多样式: ```mdx <Button intent="success" small>成功</Button> <Button intent="warning" rounded>警告</Button> <Button intent="danger" outlined>危险</Button> <Button mono>biti deploy</Button> <Button disabled>不可用</Button> ``` 成功 警告 危险 biti deploy 不可用 - `intent` (none | primary | success | warning | danger): 颜色。不设置时为中性色。 - `href` (url): 设置后渲染为链接按钮。 - `target` (string): 链接目标,外部链接默认 `_blank`。 - `text` (string): 按钮文字(也可以写在子内容中)。 - `icon / rightIcon` (icon): 左侧 / 右侧图标。 - `outlined` (boolean, default: false): 描边样式。 - `minimal` (boolean, default: false): 透明背景。 - `small / large` (boolean, default: false): 尺寸。 - `rounded` (boolean, default: false): 完全圆角。 - `mono` (boolean, default: false): 等宽字体。 - `full` (boolean, default: false): 占满整行。 - `active` (boolean, default: false): 按下态。 - `disabled` (boolean, default: false): 禁用。 `<ButtonGroup>` 把多个按钮排成一行,空间不足时换行。 --- # GitHub 仓库 > <GitHub.Repo> 链接到 GitHub 仓库的卡片,不调用 GitHub API。 链接到 GitHub 仓库的卡片(别名 `<GitHubRepo>`、`<GithubRepo>`)。不调用 GitHub API,构建结果稳定: ```mdx <GitHub.Repo repo="octocat/Hello-World" description="GitHub 的示例仓库" /> ``` [octocat/Hello-World](https://github.com/octocat/Hello-World) - `repo` (string, required): `owner/name` 或完整的 `https://github.com/owner/name`。 - `variant` (inset | flat, default: inset): `flat` 去掉阴影。 - `description` (string): 说明文字。 --- # 复制 > <Copy>(别名 <CopyText>)点击即复制的行内文字。 点击即复制的行内文字(别名 `<CopyText>`): ```mdx 平台 API 地址:<Copy icon>https://api.butterix.com/v1</Copy> 复制命令:<Copy clipboard="npm install -g bitidocs" icon>安装 CLI</Copy> ``` 平台 API 地址:`<https://api.butterix.com/v1>` 复制命令:`npm install -g bitidocs` - `clipboard` (string): 要复制的文字,默认是显示的文字(也接受 `text`、`value`)。 - `icon` (boolean, default: false): 在文字后显示复制图标。 --- # 下载 > <Download> 下载单个文件,或把多个文件打包成 ZIP。 下载单个文件,或在浏览器中把多个文件打包成 ZIP: ```mdx <Download src="/assets/logo.svg" filename="butterix-logo.svg"> <Button icon="lucide:download" outlined>下载 logo(浅色)</Button> </Download> <Download sources={["/assets/logo.svg", "/assets/logo-dark.svg", "/assets/favicon.svg"]} filename="butterix-brand.zip"> <Button icon="lucide:package" outlined>下载品牌资源包</Button> </Download> ``` [下载 logo(浅色)](https://docs.butterix.com/_biti/files/assets/logo.svg) [logo.svg](https://docs.butterix.com/_biti/files/assets/logo.svg), [logo-dark.svg](https://docs.butterix.com/_biti/files/assets/logo-dark.svg), [favicon.svg](https://docs.butterix.com/_biti/files/assets/favicon.svg) - `src` (url): 单个文件,相对于当前页面或绝对地址。与 `sources` 二选一。 - `sources` (string[]): 多个地址(或项目内路径),在浏览器中打包成 ZIP;只有一个时直接下载。 - `filename` (string): 下载的文件名,ZIP 默认 `download.zip`。 --- # 锚点 > <Anchor> 给任意内容加一个可链接的 id,被定位时短暂高亮。 给任意内容加一个可链接的 id,被定位时短暂高亮: ```mdx <Anchor id="api-key-format"> API Key 以 `biti_` 开头,长度固定。 </Anchor> [跳到密钥格式说明](#api-key-format) ``` API Key 以 `biti_` 开头。 [跳到密钥格式说明](#api-key-format) - `id` (string, required): 锚点 id,用 `#id` 链接。 --- # 代码组 > <CodeGroup>(别名 <CodeBlocks>、<CodeTabs>)多个代码块组成的标签组,所选语言全站同步。 多个代码块组成的标签组(别名 `<CodeBlocks>`、`<CodeTabs>`)。每个代码块的标题就是标签名;读者选择的语言会同步到全站并被记住。 ````mdx <CodeGroup> ```bash npm npm install -g bitidocs ``` ```bash pnpm pnpm add -g bitidocs ``` </CodeGroup> ```` ```bash npm npm install -g bitidocs ``` ```bash pnpm pnpm add -g bitidocs ``` `<CodeGroup>` 没有属性。同步键默认取代码块的语言;用围栏 meta 中的 `for="…"` 自定义同步分组。 --- # 代码块 > <CodeBlock> 用属性控制标题、高亮、聚焦、行号与折叠的代码块。 大多数时候直接写围栏代码块即可,meta 语法(标题、行高亮、聚焦、最大行数……)见[代码块](https://docs.butterix.com/guides/writing/code-blocks.md)。 用属性代替围栏 meta,适合属性较多或需要 `links` 的时候: ````mdx <CodeBlock title="client.ts" highlight="2" maxLines={0} links={{ "createClient": "/api-reference", "/get\\w+/": "/api-reference" }}> ```ts import { createClient } from "@acme/sdk"; const client = createClient({ apiKey: process.env.ACME_KEY }); const me = await client.getMe(); ``` </CodeBlock> ```` **client.ts** ```ts import { createClient } from "@acme/sdk"; const client = createClient({ apiKey: process.env.ACME_KEY }); const me = await client.getMe(); ``` - `title` (string): 标题(也接受 `filename`)。 - `language` (string): 语言(也接受 `lang`),默认取围栏的语言。 - `highlight` (string): 高亮的行,例如 `"2-4, 6"`。 - `focus` (string): 聚焦的行,其余行变暗。 - `startLine` (number): 起始行号。 - `maxLines` (number, default: 20): 最大可见行数,`0` 不限制。 - `wordWrap` (boolean): 自动换行。 - `showLineNumbers` (boolean): 显示 / 隐藏行号(也接受 `lineNumbers`)。 - `for` (string): 自定义同步分组。 - `links` (object): 把代码中的文字(或 `/正则/`)映射为链接。 - `collapsible` (boolean): 超出最大行数时用「显示更多」折叠,代替滚动。 --- # 引用文件代码 > <Code> 在构建时读取项目文件或 URL 并高亮显示。 在构建时读取项目中的文件(或一个 URL)并高亮显示,让文档与真实代码保持一致: ```mdx <Code src="/docs.yml" lines="1-6" title="docs.yml(本站,前 6 行)" /> ``` `/docs.yml` - `src` (string, required): 文件路径(以 `/` 开头为项目根,否则相对于项目根或当前页面),或公网上的 `https://` 地址(构建时下载,8 秒超时;不能是本机或内网地址)。 - `lines` (string | array): 只显示这些行,例如 `"1-6"`、`{["1-3", 8]}`。 - `language` (string): 语言,默认由扩展名推断。 此外支持 `CodeBlock` 的全部属性(`title`、`highlight`、`focus`、`startLine`、`maxLines`、`wordWrap`、`showLineNumbers`、`for`、`links`、`collapsible`)。文件不存在时给出 `code/src` 警告。 > **Warning** > > 行号属性请使用字符串或字符串数组。`lines={[1-3]}` 中的 `1-3` 是减法表达式,会被安全子集拒绝(`mdx/attribute` 错误)。 --- # 参数字段 > <ParamField> 记录一个参数或配置项。 记录一个参数或配置项。本站的 docs.yml 参考就是用它写成的。 ```mdx 用 path 写参数名 <ParamField path="slug" type="string" required default="由名称生成"> 站点子域名,5–40 个小写字母、数字或连字符。 </ParamField> ``` ```mdx 用位置写参数名 <ParamField body="slug" type="string" required> 站点子域名。 </ParamField> <ParamField query="limit" type="integer" default="50">返回条数。</ParamField> <ParamField header="Authorization" type="string" required>Bearer 令牌。</ParamField> ``` - `slug` (string, required, default: 由名称生成): 站点子域名,5–40 个小写字母、数字或连字符。 - `limit` (query, integer, default: 50): 返回条数。 - `Authorization` (header, string, required): Bearer 令牌。 - `template` (string, deprecated): 已弃用的参数示例。 ## 属性 - `path` (string): 参数名。和 `query`、`body`、`header` 一起出现时,表示路径参数。 - `query / body / header` (string): 查询参数 / 请求体字段 / 请求头的名称,同时显示位置标签。 - `name` (string): 显式的参数名,配合 `in` 使用。 - `in` (query | body | header | cookie | path): 使用 `name` 时的位置标签。 - `type` (string): 类型标签,例如 `string`、`integer`、`object[]`。 - `required` (boolean, default: false): 显示「必填」。 - `default` (string): 默认值。 - `deprecated` (boolean, default: false): 显示「已弃用」。 - `id` (string): 锚点 id,默认 `param-<名称>`。 - `placeholder` (string): 可以写,但不起作用。 - `toc` (boolean, default: false): 列入目录(暂不支持)。 别名:`<Param>`。 --- # 响应字段 > <ResponseField> 记录响应中的一个字段。 记录一个响应字段,名称中的点号前缀会以浅色显示: ```mdx <ResponseField name="deployment.status" type="string" required pre={["enum"]}> `queued`、`building`、`ready`、`failed` 或 `canceled`。 </ResponseField> <ResponseField name="deployment.url" type="string" post={["只读"]}> 成功后才有的部署地址。 </ResponseField> ``` - `deployment.status` (string, required): `queued`、`building`、`ready`、`failed` 或 `canceled`。 - `deployment.url` (string): 成功后才有的部署地址。 - `name` (string, required): 字段名。 - `type` (string): 类型标签。 - `pre / post` (string[]): 类型前 / 后的额外标签。 - `required / default / deprecated / id`: 同 `ParamField`;锚点默认 `resp-<名称>`。 嵌套字段用 [`<Expandable>`](https://docs.butterix.com/components/expandable.md) 折叠。 --- # 端点请求片段 > <EndpointRequestSnippet> 引用 API 参考中某个端点的请求示例。 这个组件引用 API 参考中的数据,随 OpenAPI 规范自动更新。下面的示例引用的都是本站的[平台 API](https://docs.butterix.com/api-reference.md)。 端点的请求示例卡片,包含多语言代码与「试一试」按钮(别名 `<RequestSnippet>`): ```mdx <EndpointRequestSnippet endpoint="POST /orgs/{org}/api-keys" languages={["curl", "python", "javascript"]} /> ``` ```bash curl -X POST https://api.butterix.com/v1/orgs/acme/api-keys \ -H "Content-Type: application/json" \ -d '{}' ``` ```python import requests url = "https://api.butterix.com/v1/orgs/acme/api-keys" payload = {} headers = { "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```typescript const response = await fetch("https://api.butterix.com/v1/orgs/acme/api-keys", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({}) }); const data = await response.json(); console.log(data); ``` - `endpoint` (string, required): `METHOD /path`,例如 `"POST /orgs/{org}/api-keys"`;多个 API 时写 `api-name::METHOD /path`。 - `example` (string): 选择规范中某个具名示例(按名称或 `summary`)。 - `languages` (string[]): 显示的语言与顺序,可包含 `"payload"`(只显示请求体)。别名如 `typescript`、`ts`、`shell` 同样有效。 - `highlight` (string | array): 高亮的行,例如 `"1-3"`。 - `hideTryItButton` (boolean): 隐藏「试一试」按钮。 在页面的 `.md` 版本里,它是请求示例的代码块:设置了 `languages` 时逐个列出,否则只列站点的第一种语言。 --- # 端点响应片段 > <EndpointResponseSnippet> 引用 API 参考中某个端点的响应示例。 这个组件引用 API 参考中的数据,随 OpenAPI 规范自动更新。下面的示例引用的都是本站的[平台 API](https://docs.butterix.com/api-reference.md)。 端点的响应示例卡片(别名 `<ResponseSnippet>`),多个状态码时可以切换: ```mdx <EndpointResponseSnippet endpoint="POST /orgs/{org}/members" example="invited" /> ``` 201: 已加入或已生成邀请 ```json { "invite": { "url": "https://console.butterix.com/invite/q8Zt3vXc2bN0LmA4pR7sKd1e" } } ``` 属性:`endpoint`(必填)、`example`、`highlight`,含义同上。 在页面的 `.md` 版本里,它是状态码、说明与响应示例的代码块。 --- # 端点 Schema 片段 > <EndpointSchemaSnippet> 引用 API 参考中某个端点的请求或响应结构。 这个组件引用 API 参考中的数据,随 OpenAPI 规范自动更新。下面的示例引用的都是本站的[平台 API](https://docs.butterix.com/api-reference.md)。 端点某一部分的字段表: ```mdx <EndpointSchemaSnippet endpoint="PUT /sites/{site}/access" selector="request.body" /> ``` #### Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `mode` | enum | yes | Allowed: `public`, `password`. | | `password` | string | no | | - `endpoint` (string, required): 同上。 - `selector` (string): 要显示的部分:`request`、`request.path`、`request.query`、`request.header`、`request.cookie`、`request.body`、`response`、`response.body`、`response.errors`(或 `errors`)。默认 `request`。 在页面的 `.md` 版本里,它是字段表,嵌套字段写成 `a.b`、`list[].c`。 --- # Webhook 负载片段 > <WebhookPayloadSnippet> 引用 API 参考中某个 webhook 的负载示例。 这个组件引用 API 参考中的数据,随 OpenAPI 规范自动更新。 Webhook 的负载示例: ```mdx <WebhookPayloadSnippet webhook="payment.succeeded" example="Refunded" /> ``` - `webhook` (string, required): webhook 名称、`operationId` 或 `WEBHOOK <名称>` 形式的键。 - `example` (string): 具名示例。 - `highlight` (string | array): 高亮的行。 在页面的 `.md` 版本里,它是负载示例的 JSON 代码块。 本站的平台 API 没有定义 webhook,因此这里不展示渲染效果,规范写法见 [Webhook 与 SSE](https://docs.butterix.com/guides/api/webhooks-and-sse.md)。 --- # Schema > <Schema> 与 <SchemaSnippet> 展示 OpenAPI 中定义的数据结构。 这个组件引用 API 参考中的数据,随 OpenAPI 规范自动更新。下面的示例引用的都是本站的[平台 API](https://docs.butterix.com/api-reference.md)。 按 `components.schemas` 中的名称展示类型:`<Schema>`(别名 `<SchemaFields>`)显示字段表,`<SchemaSnippet>` 显示 JSON 示例。 ```mdx <Schema type="Deployment" /> <SchemaSnippet type="Deployment" title="Deployment 示例" /> ``` | Field | Type | Required | Description | |---|---|---|---| | `id` | string | no | | | `siteId` | string | no | | | `kind` | enum | no | Allowed: `production`, `preview`. | | `status` | enum | no | Allowed: `queued`, `building`, `ready`, `failed`, `canceled`. | | `source` | string | no | `cli`(上传)、`hosted`(托管仓库)或 `git` | | `branch` | string | no | | | `commitSha` | string | no | | | `message` | string | no | | | `createdBy` | object | no | 触发者;用 API Key 触发时是创建密钥的人 | | `createdBy.id` | string | no | | | `createdBy.name` | string | no | | | `apiKey` | object | no | 用 API Key(CLI / CI)触发时,密钥的名称与首尾 | | `apiKey.name` | string | no | | | `apiKey.prefix` | string | no | 密钥前 10 个字符 | | `apiKey.suffix` | string | no | 密钥末尾 10 个字符 | | `error` | string | no | 失败原因 | | `pageCount` | integer | no | | | `sizeBytes` | integer | no | | | `durationMs` | integer | no | | | `url` | URL | no | 成功后才有。生产部署是站点地址,预览部署是 `<site>--<id 后 8 位>` 子域名 | | `isCurrent` | boolean | no | 是否为当前生产部署 | | `createdAt` | integer | no | | | `finishedAt` | integer | no | | **Deployment 示例** ```json { "id": "dpl_01jd8x2k7q", "siteId": "site_2m4k8p", "kind": "production", "status": "queued", "source": "git", "branch": "main", "commitSha": "9fceb02d0ae598e95dc970b74767f19372d61af8", "message": "docs: 更新快速开始", "createdBy": { "id": "string", "name": "string" }, "apiKey": { "name": "GitHub Actions", "prefix": "biti_a1B2c", "suffix": "Kd82mQx0Zt" }, "error": "string", "pageCount": 94, "sizeBytes": 5832110, "durationMs": 6120, "url": "https://acme-payments--8x2k7q-sites.butterix.com", "isCurrent": true, "createdAt": 1, "finishedAt": 1 } ``` - `type` (string, required): schema 名称。 - `title` (string): 仅 `SchemaSnippet`:卡片标题。 - `highlight` (string | array): 仅 `SchemaSnippet`:高亮的行。 在页面的 `.md` 版本里,`<Schema>` 是字段表,`<SchemaSnippet>` 是 JSON 代码块。 --- # 可运行端点 > <RunnableEndpoint> 页内可直接发送请求的调试器。 这个组件引用 API 参考中的数据,随 OpenAPI 规范自动更新。下面的示例引用的都是本站的[平台 API](https://docs.butterix.com/api-reference.md)。 页内可直接发送请求的调试器(在页面的 `.md` 版本里是请求与响应示例),用法与属性见[在线调试与代理](https://docs.butterix.com/guides/api/try-it.md#页内调试runnableendpoint): ```mdx <RunnableEndpoint endpoint="GET /ai/models" collapsed /> ``` `GET /ai/models` ```bash curl https://api.butterix.com/v1/ai/models \ -H "Authorization: Bearer <token>" ``` 200: 模型列表(推荐模型排在最前) ```json { "models": [ { "id": "claude-opus-5-5", "label": "Claude Opus 5.5", "contextWindow": 1000000, "pricing": { "input": 4, "output": 20 }, "recommended": true, "reasoning": { "efforts": [ "none" ], "suggested": "low", "default": "high" } } ], "live": true, "error": "string" } ``` --- # Markdown 片段 > <Markdown>(别名 <Snippet>、<Include>)插入可复用的片段文件。 在页面中插入一个可复用的片段文件(别名 `<Snippet>`、`<Include>`)。额外传入的属性会替换片段中的占位符: ```mdx <Markdown src="/snippets/install-cli.mdx" /> <Snippet file="node-requirement.mdx" node="22.13" cli="0.1.0" /> ``` > **环境要求 · Requirements** > > Node.js ≥ 22.13 · `biti --version` ≥ 0.1.0 - `src` (string): 片段路径(也接受 `file`、`path`):`/snippets/x.mdx` 为项目根路径,`./x.mdx` 相对于当前文件,只写文件名时在项目根的 `snippets/` 下查找。 - `其他属性` (string | number): 替换片段正文中的 `\{name\}` 占位符。 片段不存在时报 `snippet/missing` 错误。地址规则、`import` 写法与占位符的转义要求见[可复用片段与变量](https://docs.butterix.com/guides/writing/snippets.md)。 --- # 条件渲染 > <If>(别名 <Conditional>)按语言、版本或产品决定是否渲染内容。 根据当前页面所在的语言、版本或产品决定是否渲染子内容(别名 `<Conditional>`),不产生任何包裹元素: ```mdx <If locales={["zh"]}>只在中文页面显示。</If> <If locales={["en"]}>Only on English pages.</If> <If versions={["v0"]}>只在 v0 显示。</If> <If products={["sdk"]} not>除 SDK 产品外都显示。</If> ``` > **Tip** > > 这条提示只在中文页面显示。 > **Tip** > > This tip only appears on English pages. - `locales` (string[]): 语言代码(也接受 `languages`、`lang`)。 - `versions` (string[]): 版本 id、slug 或显示名称。 - `products` (string[]): 产品 id、slug 或显示名称。 - `not` (boolean, default: false): 条件取反。 - `roles` (string[]): 按读者角色显示。静态构建没有登录用户,因此永远不成立。 多个条件同时设置时需要全部满足。 --- # 平台 API > ButterIX 托管平台的 REST API 概览:基础地址、认证方式、角色权限、错误格式与常用流程。 ButterIX 控制台与 `biti` CLI 能做的一切,都通过这套 REST API 完成:管理组织与成员、创建站点、上传与切换部署、配置域名和 Git、设置 Ask AI、读取分析数据,以及驱动可视化编辑器。 [**下载规范**](https://docs.butterix.com/openapi.yaml) OpenAPI 3.1(YAML) [**创建 API Key**](https://docs.butterix.com/api-reference/api-keys/create-api-key.md) CLI 与 CI 使用的组织密钥 [**创建部署**](https://docs.butterix.com/api-reference/deployments/create-deployment.md) 上传源码或从仓库重新构建 ## 基础地址 平台 API 的基础地址是 `https://api.butterix.com/v1`。 「文档站运行时」分组中的端点(Ask AI、MCP、试调代理、反馈)发往**文档站自己的域名**,例如 `https://acme-payments-sites.butterix.com/_mcp/server`。 ## 认证 **API Key(CLI / CI)** 在控制台「组织设置 → API Keys」创建密钥,通过 `Authorization` 头传递: ```bash curl https://api.butterix.com/v1/whoami \ -H "Authorization: Bearer $BITI_TOKEN" ``` API Key 属于组织,以 `editor` 角色行事:可以部署、编辑内容、读取数据,但不能执行需要 `admin` 的操作(成员、域名、密钥管理等)。 **会话 Cookie(浏览器)** `POST /auth/login` 成功后,平台设置 HttpOnly 的 `biti_session` Cookie(30 天),只在登录时所用的主机上有效。用 Cookie 认证的修改类请求必须同源:平台会校验 `Origin` 头,跨源请求返回 403。 ## 角色 | 角色 | 能做什么 | | -------- | ----------------------------------------- | | `owner` | 全部权限;组织至少要有一位 owner | | `admin` | 管理成员、站点设置、域名、Git、访问控制、Ask AI、API Key,删除站点 | | `editor` | 部署、切换生产部署、编辑与发布内容、测试 Ask AI | | `viewer` | 只读 | ## 约定 - 请求与响应都是 JSON;部署上传使用 `application/gzip`,编辑器上传使用 `multipart/form-data`。 - 时间戳是 Unix **毫秒**。 - `:site`、`:org` 参数既可以是 slug,也可以是 id。 - 出错时返回对应的 HTTP 状态码和 `{ "error": "…" }`。 ```json title="错误响应" { "error": "That subdomain is taken." } ``` ## 常用流程 ### 在 CI 中部署 ### 上传源码 `POST /sites/{site}/deployments`,请求体是项目的 tar.gz。返回 `{ id }`。 ### 轮询状态 `GET /deployments/{id}`,直到 `status` 变为 `ready` 或 `failed`。`biti deploy` 每秒轮询一次。 ### (可选)回滚 `POST /deployments/{id}/promote` 把任意成功的部署设为生产,即时生效。 ```bash tar --exclude=node_modules --exclude=.git --exclude=dist -czf site.tgz . curl -X POST https://api.butterix.com/v1/sites/acme-payments/deployments \ -H "Authorization: Bearer $BITI_TOKEN" \ -H "Content-Type: application/gzip" \ -H "x-biti-preview: 1" \ --data-binary @site.tgz ``` ### 用编辑器 API 修改一页 ### 新建草稿 `POST /sites/{site}/editor/branches` → `{ name }` ### 读取文件 `GET /sites/{site}/editor/file?branch=…&path=…` → `{ content, sha }` ### 保存 `PUT /sites/{site}/editor/file`,带上 `baseSha` 防止覆盖他人的修改 ### 发布 `POST /sites/{site}/editor/publish` 合并到生产分支并部署 完整的接口列表见下方各分组,或左侧导航。 --- # 注册 `POST /auth/signup` 创建账户并自动登录(设置 `biti_session` Cookie),同时为新用户创建一个个人组织。平台关闭自助注册时返回 403;持有邀请链接的人仍然可以注册。 Base URL: https://api.butterix.com/v1 ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `name` | string | yes | 显示名称 | | `email` | email | yes | | | `password` | string | yes | 至少 8 个字符 | ## Example request ```bash curl -X POST https://api.butterix.com/v1/auth/signup \ -H "Content-Type: application/json" \ -d '{ "name": "林晓", "email": "lin@example.com", "password": "correct-horse-battery" }' ``` ## Responses ### 201 注册成功 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `user` | object | no | | | `user.id` | string | no | | | `user.email` | email | no | | | `user.name` | string | no | | | `user.avatarUrl` | URL | no | | | `user.isAdmin` | boolean | no | 平台管理员 | ### 400 请求参数无效 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### 403 角色不足,或 API Key 不允许此操作 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### 409 冲突(名称已被占用、重复添加或合并冲突) Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (201) ```json { "user": { "id": "usr_3k9d2a", "email": "lin@example.com", "name": "林晓", "avatarUrl": "https://example.com", "isAdmin": false } } ``` --- # 登录 `POST /auth/login` 用邮箱和密码登录,成功后设置 HttpOnly 会话 Cookie `biti_session`(有效期 30 天)。连续失败会被临时限流。 Base URL: https://api.butterix.com/v1 ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `email` | email | yes | | | `password` | string | yes | | ## Example request ```bash curl -X POST https://api.butterix.com/v1/auth/login \ -H "Content-Type: application/json" \ -d '{ "email": "lin@example.com", "password": "correct-horse-battery" }' ``` ## Responses ### 200 登录成功 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `user` | object | no | | | `user.id` | string | no | | | `user.email` | email | no | | | `user.name` | string | no | | | `user.avatarUrl` | URL | no | | | `user.isAdmin` | boolean | no | 平台管理员 | ### 401 未登录或凭据无效 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "user": { "id": "usr_3k9d2a", "email": "lin@example.com", "name": "林晓", "avatarUrl": "https://example.com", "isAdmin": false } } ``` --- # 退出登录 `POST /auth/logout` 销毁当前会话并清除 Cookie。 Base URL: https://api.butterix.com/v1 Authentication: API key in cookie `biti_session` ## Example request ```bash curl -X POST https://api.butterix.com/v1/auth/logout ``` ## Responses ### 200 成功 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `ok` | true | no | Allowed: `true`. | ### Example response (200) ```json { "ok": true } ``` --- # 获取当前用户 `GET /me` 返回当前登录用户及其所属的全部组织(含该用户在每个组织中的角色)。仅支持会话认证。 Base URL: https://api.butterix.com/v1 Authentication: API key in cookie `biti_session` ## Example request ```bash curl https://api.butterix.com/v1/me ``` ## Responses ### 200 当前用户 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `user` | object | no | | | `user.id` | string | no | | | `user.email` | email | no | | | `user.name` | string | no | | | `user.avatarUrl` | URL | no | | | `user.isAdmin` | boolean | no | 平台管理员 | | `orgs` | list of objects | no | | | `orgs[].id` | string | no | | | `orgs[].slug` | string | no | | | `orgs[].name` | string | no | | | `orgs[].plan` | string | no | | | `orgs[].planName` | string | no | | | `orgs[].role` | enum | no | 组织角色 Allowed: `owner`, `admin`, `editor`, `viewer`. | | `orgs[].createdAt` | integer | no | | ### 401 未登录或凭据无效 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "user": { "id": "usr_3k9d2a", "email": "lin@example.com", "name": "林晓", "avatarUrl": "https://example.com", "isAdmin": false }, "orgs": [ { "id": "org_8f2k1c", "slug": "acme", "name": "Acme", "plan": "free", "planName": "Free", "role": "owner", "createdAt": 1763596800000 } ] } ``` --- # 更新当前用户 `PATCH /me` 修改显示名称或密码。修改密码时必须提供当前密码。 Base URL: https://api.butterix.com/v1 Authentication: API key in cookie `biti_session` ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `name` | string | no | | | `currentPassword` | string | no | | | `newPassword` | string | no | | ## Example request ```bash curl -X PATCH https://api.butterix.com/v1/me \ -H "Content-Type: application/json" \ -d '{}' ``` ## Responses ### 200 更新后的用户 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `user` | object | no | | | `user.id` | string | no | | | `user.email` | email | no | | | `user.name` | string | no | | | `user.avatarUrl` | URL | no | | | `user.isAdmin` | boolean | no | 平台管理员 | ### 400 请求参数无效 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "user": { "id": "usr_3k9d2a", "email": "lin@example.com", "name": "林晓", "avatarUrl": "https://example.com", "isAdmin": false } } ``` --- # 查询 API Key 所属组织 `GET /whoami` 用 API Key 调用,返回该密钥所属的组织。`biti login` 用它校验密钥。 Base URL: https://api.butterix.com/v1 Authentication: bearer token in Authorization header ## Example request ```bash curl https://api.butterix.com/v1/whoami \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 所属组织 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `org` | object | no | | | `org.id` | string | no | | | `org.slug` | string | no | | | `org.name` | string | no | | ### 401 未登录或凭据无效 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "org": { "id": "org_8f2k1c", "slug": "acme", "name": "Acme" } } ``` --- # 创建组织 `POST /orgs` 创建一个新组织,调用者成为 `owner`。 Base URL: https://api.butterix.com/v1 Authentication: API key in cookie `biti_session` ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `name` | string | yes | | | `slug` | string | no | 组织标识,默认由名称生成,创建后不可修改 | ## Example request ```bash curl -X POST https://api.butterix.com/v1/orgs \ -H "Content-Type: application/json" \ -d '{ "name": "Acme" }' ``` ## Responses ### 201 新组织 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `id` | string | no | | | `slug` | string | no | | | `name` | string | no | | | `plan` | string | no | | | `planName` | string | no | | | `role` | enum | no | 组织角色 Allowed: `owner`, `admin`, `editor`, `viewer`. | | `createdAt` | integer | no | | ### 409 冲突(名称已被占用、重复添加或合并冲突) Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (201) ```json { "id": "org_8f2k1c", "slug": "acme", "name": "Acme", "plan": "free", "planName": "Free", "role": "owner", "createdAt": 1763596800000 } ``` --- # 获取组织 `GET /orgs/{org}` 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 | |---|---|---|---| | `org` | string | yes | 组织 slug 或 id | ## Example request ```bash curl https://api.butterix.com/v1/orgs/acme \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 组织 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `id` | string | no | | | `slug` | string | no | | | `name` | string | no | | | `plan` | string | no | | | `planName` | string | no | | | `role` | enum | no | 组织角色 Allowed: `owner`, `admin`, `editor`, `viewer`. | | `createdAt` | integer | no | | ### 404 资源不存在,或你没有访问权限 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "id": "org_8f2k1c", "slug": "acme", "name": "Acme", "plan": "free", "planName": "Free", "role": "owner", "createdAt": 1763596800000 } ``` --- # 重命名组织 `PATCH /orgs/{org}` 需要 `admin` 角色。 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 | |---|---|---|---| | `org` | string | yes | 组织 slug 或 id | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `name` | string | no | | ## Example request ```bash curl -X PATCH https://api.butterix.com/v1/orgs/acme \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{}' ``` ## Responses ### 200 更新后的组织 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `id` | string | no | | | `slug` | string | no | | | `name` | string | no | | | `plan` | string | no | | | `planName` | string | no | | | `role` | enum | no | 组织角色 Allowed: `owner`, `admin`, `editor`, `viewer`. | | `createdAt` | integer | no | | ### 403 角色不足,或 API Key 不允许此操作 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "id": "org_8f2k1c", "slug": "acme", "name": "Acme", "plan": "free", "planName": "Free", "role": "owner", "createdAt": 1763596800000 } ``` --- # 审计日志 `GET /orgs/{org}/audit` 最近 200 条重要操作(站点创建与删除、部署切换、域名、成员、密钥、Ask AI 设置等)。需要 `admin` 角色。 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 | |---|---|---|---| | `org` | string | yes | 组织 slug 或 id | ## Example request ```bash curl https://api.butterix.com/v1/orgs/acme/audit \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 审计记录,按时间倒序 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `[].ts` | integer | no | | | `[].action` | string | no | | | `[].target` | string | no | | | `[].user` | object | no | | | `[].user.name` | string | no | | | `[].user.email` | string | no | | ### Example response (200) ```json [ { "ts": 1, "action": "deployment.promote", "target": "dpl_01jd8x2k7q", "user": { "name": "string", "email": "string" } } ] ``` --- # 组织 MCP 服务器 `POST /mcp` 组织的 MCP 服务器(Streamable HTTP 传输,JSON 响应),只读。只接受组织 API Key,工具见[托管平台](https://docs.butterix.com/guides/deploy/platform.md#组织-mcp-服务器)。 `GET` 请求返回 405;每个 API Key 每分钟最多 120 次调用,超过返回 429。 Base URL: https://api.butterix.com/v1 Authentication: bearer token in Authorization header ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `jsonrpc` | "2.0" | yes | Allowed: `2.0`. | | `id` | string | no | | | `method` | enum | yes | Allowed: `initialize`, `ping`, `tools/list`, `tools/call`. | | `params` | object | no | | ## Example request ```bash curl -X POST https://api.butterix.com/v1/mcp \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "list_sites", "arguments": {} } }' ``` ## Responses ### 200 JSON-RPC 响应 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `jsonrpc` | string | no | | | `id` | string | no | | | `result` | object | no | | | `error` | object | no | | | `error.code` | integer | no | | | `error.message` | string | no | | ### 202 通知类消息,无响应体 ### 401 未登录或凭据无效 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "jsonrpc": "string", "id": "string", "result": {}, "error": { "code": 1, "message": "string" } } ``` --- # 列出成员与邀请 `GET /orgs/{org}/members` 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 | |---|---|---|---| | `org` | string | yes | 组织 slug 或 id | ## Example request ```bash curl https://api.butterix.com/v1/orgs/acme/members \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 成员与待接受的邀请 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `members` | list of objects | no | | | `members[].user` | object | no | | | `members[].user.id` | string | no | | | `members[].user.name` | string | no | | | `members[].user.email` | string | no | | | `members[].user.avatarUrl` | string | no | | | `members[].role` | enum | no | 组织角色 Allowed: `owner`, `admin`, `editor`, `viewer`. | | `members[].createdAt` | integer | no | | | `invites` | list of objects | no | | | `invites[].id` | string | no | | | `invites[].email` | string | no | | | `invites[].role` | enum | no | 组织角色 Allowed: `owner`, `admin`, `editor`, `viewer`. | | `invites[].createdAt` | integer | no | | ### Example response (200) ```json { "members": [ { "user": { "id": "string", "name": "string", "email": "string", "avatarUrl": "string" }, "role": "owner", "createdAt": 1 } ], "invites": [ { "id": "inv_7cd2e1", "email": "chen@example.com", "role": "owner", "createdAt": 1 } ] } ``` --- # 添加或邀请成员 `POST /orgs/{org}/members` 需要 `admin` 角色。邮箱已注册时直接加入组织,返回 `{ "added": true }`; 否则生成一次性邀请链接,返回 `{ "invite": { "url" } }`,由你发给对方。 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 | |---|---|---|---| | `org` | string | yes | 组织 slug 或 id | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `email` | email | yes | | | `role` | enum | no | 组织角色 Allowed: `owner`, `admin`, `editor`, `viewer`. | ## Example request ```bash curl -X POST https://api.butterix.com/v1/orgs/acme/members \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "email": "chen@example.com", "role": "editor" }' ``` ## Responses ### 201 已加入或已生成邀请 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | _已加入_ | variant | | | | `added` | true | no | Allowed: `true`. | | _已邀请_ | variant | | | | `invite` | object | no | | | `invite.url` | URL | no | | ### 409 冲突(名称已被占用、重复添加或合并冲突) Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (201) ```json { "invite": { "url": "https://console.butterix.com/invite/q8Zt3vXc2bN0LmA4pR7sKd1e" } } ``` --- # 修改成员角色 `PATCH /orgs/{org}/members/{userId}` 需要 `admin` 角色。组织至少要保留一个 `owner`。 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 | |---|---|---|---| | `org` | string | yes | 组织 slug 或 id | | `userId` | string | yes | | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `role` | enum | yes | 组织角色 Allowed: `owner`, `admin`, `editor`, `viewer`. | ## Example request ```bash curl -X PATCH https://api.butterix.com/v1/orgs/acme/members/usr_3k9d2a \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "role": "owner" }' ``` ## Responses ### 200 成功 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `ok` | true | no | Allowed: `true`. | ### 400 请求参数无效 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "ok": true } ``` --- # 移除成员 `DELETE /orgs/{org}/members/{userId}` 需要 `admin` 角色。不能移除最后一个 `owner`。 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 | |---|---|---|---| | `org` | string | yes | 组织 slug 或 id | | `userId` | string | yes | | ## Example request ```bash curl -X DELETE https://api.butterix.com/v1/orgs/acme/members/usr_3k9d2a \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 成功 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `ok` | true | no | Allowed: `true`. | ### 400 请求参数无效 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "ok": true } ``` --- # 撤销邀请 `DELETE /orgs/{org}/invites/{inviteId}` 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 | |---|---|---|---| | `org` | string | yes | 组织 slug 或 id | | `inviteId` | string | yes | | ## Example request ```bash curl -X DELETE https://api.butterix.com/v1/orgs/acme/invites/inv_7cd2e1 \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 成功 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `ok` | true | no | Allowed: `true`. | ### Example response (200) ```json { "ok": true } ``` --- # 接受邀请 `POST /invites/{token}/accept` 已登录用户接受邀请并以邀请时指定的角色加入组织。每个邀请只能使用一次。 Base URL: https://api.butterix.com/v1 Authentication: API key in cookie `biti_session` ## Path parameters | Name | Type | Required | Description | |---|---|---|---| | `token` | string | yes | 邀请链接中的令牌 | ## Example request ```bash curl -X POST https://api.butterix.com/v1/invites/string/accept ``` ## Responses ### 200 加入的组织 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `org` | object | no | | | `org.id` | string | no | | | `org.slug` | string | no | | | `org.name` | string | no | | | `org.plan` | string | no | | | `org.planName` | string | no | | | `org.role` | enum | no | 组织角色 Allowed: `owner`, `admin`, `editor`, `viewer`. | | `org.createdAt` | integer | no | | ### 404 资源不存在,或你没有访问权限 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "org": { "id": "org_8f2k1c", "slug": "acme", "name": "Acme", "plan": "free", "planName": "Free", "role": "owner", "createdAt": 1763596800000 } } ``` --- # 列出 API Key `GET /orgs/{org}/api-keys` 需要 `admin` 角色(因此只能用会话认证调用)。只返回密钥的开头和末尾,不返回完整密钥。 Base URL: https://api.butterix.com/v1 Authentication: API key in cookie `biti_session` ## Path parameters | Name | Type | Required | Description | |---|---|---|---| | `org` | string | yes | 组织 slug 或 id | ## Example request ```bash curl https://api.butterix.com/v1/orgs/acme/api-keys ``` ## Responses ### 200 密钥列表 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `[].id` | string | no | | | `[].name` | string | no | | | `[].prefix` | string | no | 密钥前 10 个字符 | | `[].suffix` | string | no | 密钥末尾 10 个字符 | | `[].createdAt` | integer | no | | | `[].lastUsedAt` | integer | no | | ### Example response (200) ```json [ { "id": "key_5h2m8q", "name": "GitHub Actions", "prefix": "biti_Q2xha", "suffix": "Kd82mQx0Zt", "createdAt": 1, "lastUsedAt": 1 } ] ``` --- # 创建 API Key `POST /orgs/{org}/api-keys` 需要 `admin` 角色。完整的 `token` **只在这次响应中返回一次**,请立即保存。 Base URL: https://api.butterix.com/v1 Authentication: API key in cookie `biti_session` ## Path parameters | Name | Type | Required | Description | |---|---|---|---| | `org` | string | yes | 组织 slug 或 id | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `name` | string | no | | ## Example request ```bash curl -X POST https://api.butterix.com/v1/orgs/acme/api-keys \ -H "Content-Type: application/json" \ -d '{}' ``` ## Responses ### 201 新密钥 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `id` | string | no | | | `token` | string | no | | ### Example response (201) ```json { "id": "key_5h2m8q", "token": "biti_Q2xhdWRlIGlzIGF3ZXNvbWUh9x" } ``` --- # 删除 API Key `DELETE /orgs/{org}/api-keys/{keyId}` 使用该密钥的 CLI 与 CI 立即失效。 Base URL: https://api.butterix.com/v1 Authentication: API key in cookie `biti_session` ## Path parameters | Name | Type | Required | Description | |---|---|---|---| | `org` | string | yes | 组织 slug 或 id | | `keyId` | string | yes | | ## Example request ```bash curl -X DELETE https://api.butterix.com/v1/orgs/acme/api-keys/key_5h2m8q ``` ## Responses ### 200 成功 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `ok` | true | no | Allowed: `true`. | ### Example response (200) ```json { "ok": true } ``` --- # 列出站点 `GET /orgs/{org}/sites` 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 | |---|---|---|---| | `org` | string | yes | 组织 slug 或 id | ## Example request ```bash curl https://api.butterix.com/v1/orgs/acme/sites \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 组织下的站点,按创建时间倒序 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `[].id` | string | no | | | `[].slug` | string | no | | | `[].name` | string | no | | | `[].url` | URL | no | | | `[].sourceType` | enum | no | 内容来源:托管仓库、外部 Git 仓库或 CLI 上传 Allowed: `hosted`, `git`, `upload`. | | `[].status` | enum | no | 最近一次部署的状态,没有部署时为 `none` Allowed: `queued`, `building`, `ready`, `failed`, `canceled`, `none`. | | `[].updatedAt` | integer | no | | | `[].pageCount` | integer | no | 生产部署的页面数 | ### Example response (200) ```json [ { "id": "site_2m4k8p", "slug": "acme-payments", "name": "Acme 文档", "url": "https://acme-payments-sites.butterix.com", "sourceType": "hosted", "status": "queued", "updatedAt": 1, "pageCount": 94 } ] ``` --- # 创建站点 `POST /orgs/{org}/sites` 需要 `admin` 角色。平台会为站点创建托管 Git 仓库、写入模板内容并立即开始首次生产部署。 - `starter`:简介、快速开始、写作指南三页。 - `blank`:只有一个首页。 - `openapi`:根据 `openapiText` 生成 API 参考,必须同时提供规范内容。 `slug` 是站点子域名:5–40 个小写字母、数字或单个连字符,首尾不能是连字符,不能包含 `--`(预览地址使用 `--` 分隔),部分保留字(如 `console`、`managements`、`butterix`)不可用。站点地址为 `https://<slug>-sites.butterix.com`。 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 | |---|---|---|---| | `org` | string | yes | 组织 slug 或 id | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `name` | string | yes | | | `slug` | string | no | 默认由名称生成 | | `template` | enum | no | Allowed: `starter`, `blank`, `openapi`. | | `openapiText` | string | no | `template` 为 `openapi` 时必填:OpenAPI 3.x 的 YAML 或 JSON 文本 | ## Example request ```bash curl -X POST https://api.butterix.com/v1/orgs/acme/sites \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "name": "Acme 文档", "slug": "acme-payments", "template": "starter" }' ``` ## Responses ### 201 新站点 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `id` | string | no | | | `slug` | string | no | | | `name` | string | no | | | `url` | URL | no | | | `sourceType` | enum | no | 内容来源:托管仓库、外部 Git 仓库或 CLI 上传 Allowed: `hosted`, `git`, `upload`. | | `status` | enum | no | 最近一次部署的状态,没有部署时为 `none` Allowed: `queued`, `building`, `ready`, `failed`, `canceled`, `none`. | | `updatedAt` | integer | no | | | `pageCount` | integer | no | 生产部署的页面数 | | `orgSlug` | string | no | | | `git` | object | no | 连接了 Git 仓库时存在 | | `git.url` | string | no | | | `git.branch` | string | no | | | `git.hasToken` | boolean | no | | | `git.webhookUrl` | string | no | | | `git.webhookSecret` | string | no | | | `production` | object | no | | | `production.id` | string | no | | | `production.siteId` | string | no | | | `production.kind` | enum | no | Allowed: `production`, `preview`. | | `production.status` | enum | no | Allowed: `queued`, `building`, `ready`, `failed`, `canceled`. | | `production.source` | string | no | `cli`(上传)、`hosted`(托管仓库)或 `git` | | `production.branch` | string | no | | | `production.commitSha` | string | no | | | `production.message` | string | no | | | `production.createdBy` | object | no | 触发者;用 API Key 触发时是创建密钥的人 | | `production.createdBy.id` | string | no | | | `production.createdBy.name` | string | no | | | `production.apiKey` | object | no | 用 API Key(CLI / CI)触发时,密钥的名称与首尾 | | `production.apiKey.name` | string | no | | | `production.apiKey.prefix` | string | no | 密钥前 10 个字符 | | `production.apiKey.suffix` | string | no | 密钥末尾 10 个字符 | | `production.error` | string | no | 失败原因 | | `production.pageCount` | integer | no | | | `production.sizeBytes` | integer | no | | | `production.durationMs` | integer | no | | | `production.url` | URL | no | 成功后才有。生产部署是站点地址,预览部署是 `<site>--<id 后 8 位>` 子域名 | | `production.isCurrent` | boolean | no | 是否为当前生产部署 | | `production.createdAt` | integer | no | | | `production.finishedAt` | integer | no | | | `domains` | list of objects | no | | | `domains[].domain` | string | no | | | `domains[].verified` | boolean | no | | | `domains[].primary` | boolean | no | 是否为主域名 | | `domains[].verifyRecord` | object | no | 需要添加的 TXT 记录 | | `domains[].verifyRecord.type` | "TXT" | no | Allowed: `TXT`. | | `domains[].verifyRecord.name` | string | no | | | `domains[].verifyRecord.value` | string | no | | | `domains[].cname` | string | no | CNAME 目标 | | `domains[].createdAt` | integer | no | | | `access` | object | no | | | `access.mode` | enum | no | Allowed: `public`, `password`. | | `ai` | object | no | | | `ai.enabled` | boolean | no | | | `ai.provider` | enum | no | Allowed: `anthropic`, `deepseek`, `openrouter`. | | `ai.model` | string | no | | | `ai.hasKey` | boolean | no | 是否设置了站点密钥 | | `ai.keyMasked` | string | no | | | `ai.platformKeyAvailable` | boolean | no | 平台是否为当前提供商配置了默认密钥 | | `ai.platformKeys` | map from strings to booleans | no | 每个提供商是否有平台密钥 | | `ai.guidance` | string | no | | | `ai.effort` | enum | no | 推理强度;`null` 表示使用模型的建议档位 May be null. Allowed: `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`. | | `ai.retentionDays` | integer | no | 提问记录保留天数;`null` 表示一直保留 May be null. | | `ai.dailyLimit` | integer | no | 滚动 24 小时内调用模型的提问上限;`null` 表示不限 May be null. | | `ai.agent` | boolean | no | 控制台 AI 是否启用 | | `ai.gaps` | boolean | no | 是否每天自动整理文档缺口 | | `ai.support` | object | no | 答不上时转人工 | | `ai.support.enabled` | boolean | no | | | `ai.support.url` | string | no | | | `ai.support.email` | string | no | | | `primaryUrl` | URL | no | 主域名的地址;没有自定义域名时与 `url` 相同 | | `mcpUrl` | URL | no | | ### 400 请求参数无效 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### 409 冲突(名称已被占用、重复添加或合并冲突) Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (201) ```json { "id": "site_2m4k8p", "slug": "acme-payments", "name": "Acme 文档", "url": "https://acme-payments-sites.butterix.com", "sourceType": "hosted", "status": "queued", "updatedAt": 1, "pageCount": 94, "orgSlug": "acme", "git": { "url": "https://github.com/acme/docs.git", "branch": "main", "hasToken": true, "webhookUrl": "https://api.butterix.com/v1/webhooks/github/site_2m4k8p", "webhookSecret": "string" }, "production": { "id": "dpl_01jd8x2k7q", "siteId": "site_2m4k8p", "kind": "production", "status": "queued", "source": "git", "branch": "main", "commitSha": "9fceb02d0ae598e95dc970b74767f19372d61af8", "message": "docs: 更新快速开始", "createdBy": { "id": "string", "name": "string" }, "apiKey": { "name": "GitHub Actions", "prefix": "biti_a1B2c", "suffix": "Kd82mQx0Zt" }, "error": "string", "pageCount": 94, "sizeBytes": 5832110, "durationMs": 6120, "url": "https://acme-payments--8x2k7q-sites.butterix.com", "isCurrent": true, "createdAt": 1, "finishedAt": 1 }, "domains": [ { "domain": "docs.acme.com", "verified": false, "primary": false, "verifyRecord": { "type": "TXT", "name": "_butterix.docs.acme.com", "value": "butterix-verify=a1b2c3d4e5f6" }, "cname": "sites.butterix.com", "createdAt": 1 } ], "access": { "mode": "public" }, "ai": { "enabled": true, "provider": "anthropic", "model": "claude-opus-5-5", "hasKey": true, "keyMasked": "sk-a…9f2c", "platformKeyAvailable": true, "platformKeys": { "key": true }, "guidance": "string", "effort": "none", "retentionDays": 1, "dailyLimit": 200, "agent": true, "gaps": false, "support": { "enabled": false, "url": "", "email": "" } }, "primaryUrl": "https://docs.acme.com", "mcpUrl": "https://docs.acme.com/_mcp/server" } ``` --- # 获取站点 `GET /sites/{site}` 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 | ## Example request ```bash curl https://api.butterix.com/v1/sites/acme-payments \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 站点详情 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `id` | string | no | | | `slug` | string | no | | | `name` | string | no | | | `url` | URL | no | | | `sourceType` | enum | no | 内容来源:托管仓库、外部 Git 仓库或 CLI 上传 Allowed: `hosted`, `git`, `upload`. | | `status` | enum | no | 最近一次部署的状态,没有部署时为 `none` Allowed: `queued`, `building`, `ready`, `failed`, `canceled`, `none`. | | `updatedAt` | integer | no | | | `pageCount` | integer | no | 生产部署的页面数 | | `orgSlug` | string | no | | | `git` | object | no | 连接了 Git 仓库时存在 | | `git.url` | string | no | | | `git.branch` | string | no | | | `git.hasToken` | boolean | no | | | `git.webhookUrl` | string | no | | | `git.webhookSecret` | string | no | | | `production` | object | no | | | `production.id` | string | no | | | `production.siteId` | string | no | | | `production.kind` | enum | no | Allowed: `production`, `preview`. | | `production.status` | enum | no | Allowed: `queued`, `building`, `ready`, `failed`, `canceled`. | | `production.source` | string | no | `cli`(上传)、`hosted`(托管仓库)或 `git` | | `production.branch` | string | no | | | `production.commitSha` | string | no | | | `production.message` | string | no | | | `production.createdBy` | object | no | 触发者;用 API Key 触发时是创建密钥的人 | | `production.createdBy.id` | string | no | | | `production.createdBy.name` | string | no | | | `production.apiKey` | object | no | 用 API Key(CLI / CI)触发时,密钥的名称与首尾 | | `production.apiKey.name` | string | no | | | `production.apiKey.prefix` | string | no | 密钥前 10 个字符 | | `production.apiKey.suffix` | string | no | 密钥末尾 10 个字符 | | `production.error` | string | no | 失败原因 | | `production.pageCount` | integer | no | | | `production.sizeBytes` | integer | no | | | `production.durationMs` | integer | no | | | `production.url` | URL | no | 成功后才有。生产部署是站点地址,预览部署是 `<site>--<id 后 8 位>` 子域名 | | `production.isCurrent` | boolean | no | 是否为当前生产部署 | | `production.createdAt` | integer | no | | | `production.finishedAt` | integer | no | | | `domains` | list of objects | no | | | `domains[].domain` | string | no | | | `domains[].verified` | boolean | no | | | `domains[].primary` | boolean | no | 是否为主域名 | | `domains[].verifyRecord` | object | no | 需要添加的 TXT 记录 | | `domains[].verifyRecord.type` | "TXT" | no | Allowed: `TXT`. | | `domains[].verifyRecord.name` | string | no | | | `domains[].verifyRecord.value` | string | no | | | `domains[].cname` | string | no | CNAME 目标 | | `domains[].createdAt` | integer | no | | | `access` | object | no | | | `access.mode` | enum | no | Allowed: `public`, `password`. | | `ai` | object | no | | | `ai.enabled` | boolean | no | | | `ai.provider` | enum | no | Allowed: `anthropic`, `deepseek`, `openrouter`. | | `ai.model` | string | no | | | `ai.hasKey` | boolean | no | 是否设置了站点密钥 | | `ai.keyMasked` | string | no | | | `ai.platformKeyAvailable` | boolean | no | 平台是否为当前提供商配置了默认密钥 | | `ai.platformKeys` | map from strings to booleans | no | 每个提供商是否有平台密钥 | | `ai.guidance` | string | no | | | `ai.effort` | enum | no | 推理强度;`null` 表示使用模型的建议档位 May be null. Allowed: `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`. | | `ai.retentionDays` | integer | no | 提问记录保留天数;`null` 表示一直保留 May be null. | | `ai.dailyLimit` | integer | no | 滚动 24 小时内调用模型的提问上限;`null` 表示不限 May be null. | | `ai.agent` | boolean | no | 控制台 AI 是否启用 | | `ai.gaps` | boolean | no | 是否每天自动整理文档缺口 | | `ai.support` | object | no | 答不上时转人工 | | `ai.support.enabled` | boolean | no | | | `ai.support.url` | string | no | | | `ai.support.email` | string | no | | | `primaryUrl` | URL | no | 主域名的地址;没有自定义域名时与 `url` 相同 | | `mcpUrl` | URL | no | | ### 404 资源不存在,或你没有访问权限 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "id": "site_2m4k8p", "slug": "acme-payments", "name": "Acme 文档", "url": "https://acme-payments-sites.butterix.com", "sourceType": "hosted", "status": "queued", "updatedAt": 1, "pageCount": 94, "orgSlug": "acme", "git": { "url": "https://github.com/acme/docs.git", "branch": "main", "hasToken": true, "webhookUrl": "https://api.butterix.com/v1/webhooks/github/site_2m4k8p", "webhookSecret": "string" }, "production": { "id": "dpl_01jd8x2k7q", "siteId": "site_2m4k8p", "kind": "production", "status": "queued", "source": "git", "branch": "main", "commitSha": "9fceb02d0ae598e95dc970b74767f19372d61af8", "message": "docs: 更新快速开始", "createdBy": { "id": "string", "name": "string" }, "apiKey": { "name": "GitHub Actions", "prefix": "biti_a1B2c", "suffix": "Kd82mQx0Zt" }, "error": "string", "pageCount": 94, "sizeBytes": 5832110, "durationMs": 6120, "url": "https://acme-payments--8x2k7q-sites.butterix.com", "isCurrent": true, "createdAt": 1, "finishedAt": 1 }, "domains": [ { "domain": "docs.acme.com", "verified": false, "primary": false, "verifyRecord": { "type": "TXT", "name": "_butterix.docs.acme.com", "value": "butterix-verify=a1b2c3d4e5f6" }, "cname": "sites.butterix.com", "createdAt": 1 } ], "access": { "mode": "public" }, "ai": { "enabled": true, "provider": "anthropic", "model": "claude-opus-5-5", "hasKey": true, "keyMasked": "sk-a…9f2c", "platformKeyAvailable": true, "platformKeys": { "key": true }, "guidance": "string", "effort": "none", "retentionDays": 1, "dailyLimit": 200, "agent": true, "gaps": false, "support": { "enabled": false, "url": "", "email": "" } }, "primaryUrl": "https://docs.acme.com", "mcpUrl": "https://docs.acme.com/_mcp/server" } ``` --- # 重命名站点 `PATCH /sites/{site}` 需要 `admin` 角色。子域名(slug)创建后不可修改。 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 | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `name` | string | no | | ## Example request ```bash curl -X PATCH https://api.butterix.com/v1/sites/acme-payments \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{}' ``` ## Responses ### 200 站点详情 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `id` | string | no | | | `slug` | string | no | | | `name` | string | no | | | `url` | URL | no | | | `sourceType` | enum | no | 内容来源:托管仓库、外部 Git 仓库或 CLI 上传 Allowed: `hosted`, `git`, `upload`. | | `status` | enum | no | 最近一次部署的状态,没有部署时为 `none` Allowed: `queued`, `building`, `ready`, `failed`, `canceled`, `none`. | | `updatedAt` | integer | no | | | `pageCount` | integer | no | 生产部署的页面数 | | `orgSlug` | string | no | | | `git` | object | no | 连接了 Git 仓库时存在 | | `git.url` | string | no | | | `git.branch` | string | no | | | `git.hasToken` | boolean | no | | | `git.webhookUrl` | string | no | | | `git.webhookSecret` | string | no | | | `production` | object | no | | | `production.id` | string | no | | | `production.siteId` | string | no | | | `production.kind` | enum | no | Allowed: `production`, `preview`. | | `production.status` | enum | no | Allowed: `queued`, `building`, `ready`, `failed`, `canceled`. | | `production.source` | string | no | `cli`(上传)、`hosted`(托管仓库)或 `git` | | `production.branch` | string | no | | | `production.commitSha` | string | no | | | `production.message` | string | no | | | `production.createdBy` | object | no | 触发者;用 API Key 触发时是创建密钥的人 | | `production.createdBy.id` | string | no | | | `production.createdBy.name` | string | no | | | `production.apiKey` | object | no | 用 API Key(CLI / CI)触发时,密钥的名称与首尾 | | `production.apiKey.name` | string | no | | | `production.apiKey.prefix` | string | no | 密钥前 10 个字符 | | `production.apiKey.suffix` | string | no | 密钥末尾 10 个字符 | | `production.error` | string | no | 失败原因 | | `production.pageCount` | integer | no | | | `production.sizeBytes` | integer | no | | | `production.durationMs` | integer | no | | | `production.url` | URL | no | 成功后才有。生产部署是站点地址,预览部署是 `<site>--<id 后 8 位>` 子域名 | | `production.isCurrent` | boolean | no | 是否为当前生产部署 | | `production.createdAt` | integer | no | | | `production.finishedAt` | integer | no | | | `domains` | list of objects | no | | | `domains[].domain` | string | no | | | `domains[].verified` | boolean | no | | | `domains[].primary` | boolean | no | 是否为主域名 | | `domains[].verifyRecord` | object | no | 需要添加的 TXT 记录 | | `domains[].verifyRecord.type` | "TXT" | no | Allowed: `TXT`. | | `domains[].verifyRecord.name` | string | no | | | `domains[].verifyRecord.value` | string | no | | | `domains[].cname` | string | no | CNAME 目标 | | `domains[].createdAt` | integer | no | | | `access` | object | no | | | `access.mode` | enum | no | Allowed: `public`, `password`. | | `ai` | object | no | | | `ai.enabled` | boolean | no | | | `ai.provider` | enum | no | Allowed: `anthropic`, `deepseek`, `openrouter`. | | `ai.model` | string | no | | | `ai.hasKey` | boolean | no | 是否设置了站点密钥 | | `ai.keyMasked` | string | no | | | `ai.platformKeyAvailable` | boolean | no | 平台是否为当前提供商配置了默认密钥 | | `ai.platformKeys` | map from strings to booleans | no | 每个提供商是否有平台密钥 | | `ai.guidance` | string | no | | | `ai.effort` | enum | no | 推理强度;`null` 表示使用模型的建议档位 May be null. Allowed: `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`. | | `ai.retentionDays` | integer | no | 提问记录保留天数;`null` 表示一直保留 May be null. | | `ai.dailyLimit` | integer | no | 滚动 24 小时内调用模型的提问上限;`null` 表示不限 May be null. | | `ai.agent` | boolean | no | 控制台 AI 是否启用 | | `ai.gaps` | boolean | no | 是否每天自动整理文档缺口 | | `ai.support` | object | no | 答不上时转人工 | | `ai.support.enabled` | boolean | no | | | `ai.support.url` | string | no | | | `ai.support.email` | string | no | | | `primaryUrl` | URL | no | 主域名的地址;没有自定义域名时与 `url` 相同 | | `mcpUrl` | URL | no | | ### Example response (200) ```json { "id": "site_2m4k8p", "slug": "acme-payments", "name": "Acme 文档", "url": "https://acme-payments-sites.butterix.com", "sourceType": "hosted", "status": "queued", "updatedAt": 1, "pageCount": 94, "orgSlug": "acme", "git": { "url": "https://github.com/acme/docs.git", "branch": "main", "hasToken": true, "webhookUrl": "https://api.butterix.com/v1/webhooks/github/site_2m4k8p", "webhookSecret": "string" }, "production": { "id": "dpl_01jd8x2k7q", "siteId": "site_2m4k8p", "kind": "production", "status": "queued", "source": "git", "branch": "main", "commitSha": "9fceb02d0ae598e95dc970b74767f19372d61af8", "message": "docs: 更新快速开始", "createdBy": { "id": "string", "name": "string" }, "apiKey": { "name": "GitHub Actions", "prefix": "biti_a1B2c", "suffix": "Kd82mQx0Zt" }, "error": "string", "pageCount": 94, "sizeBytes": 5832110, "durationMs": 6120, "url": "https://acme-payments--8x2k7q-sites.butterix.com", "isCurrent": true, "createdAt": 1, "finishedAt": 1 }, "domains": [ { "domain": "docs.acme.com", "verified": false, "primary": false, "verifyRecord": { "type": "TXT", "name": "_butterix.docs.acme.com", "value": "butterix-verify=a1b2c3d4e5f6" }, "cname": "sites.butterix.com", "createdAt": 1 } ], "access": { "mode": "public" }, "ai": { "enabled": true, "provider": "anthropic", "model": "claude-opus-5-5", "hasKey": true, "keyMasked": "sk-a…9f2c", "platformKeyAvailable": true, "platformKeys": { "key": true }, "guidance": "string", "effort": "none", "retentionDays": 1, "dailyLimit": 200, "agent": true, "gaps": false, "support": { "enabled": false, "url": "", "email": "" } }, "primaryUrl": "https://docs.acme.com", "mcpUrl": "https://docs.acme.com/_mcp/server" } ``` --- # 删除站点 `DELETE /sites/{site}` 需要 `admin` 角色。永久删除站点、所有部署文件、托管仓库、域名映射与分析数据,**无法撤销**。 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 | ## Example request ```bash curl -X DELETE https://api.butterix.com/v1/sites/acme-payments \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 成功 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `ok` | true | no | Allowed: `true`. | ### Example response (200) ```json { "ok": true } ``` --- # 设置访问控制 `PUT /sites/{site}/access` 需要 `admin` 角色。`password` 模式下访客首次访问会看到密码页,验证通过后获得 30 天有效的访问 Cookie。 已设置过密码时,切换到 `password` 模式可以不传 `password`(沿用原密码)。修改密码会使所有访客的登录与 MCP 登录失效,访问令牌不受影响。 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 | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `mode` | enum | yes | Allowed: `public`, `password`. | | `password` | string | no | | ## Example request ```bash curl -X PUT https://api.butterix.com/v1/sites/acme-payments/access \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "mode": "password", "password": "preview-2026" }' ``` ## Responses ### 200 当前模式 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `mode` | enum | no | Allowed: `public`, `password`. | ### 400 请求参数无效 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "mode": "public" } ``` --- # 列出访问令牌 `GET /sites/{site}/access-tokens` 需要 `admin` 角色。包含访问令牌与仍然有效的 MCP 登录,不返回令牌本身。 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 | ## Example request ```bash curl https://api.butterix.com/v1/sites/acme-payments/access-tokens \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 访问令牌 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `[].id` | string | no | | | `[].kind` | enum | no | `token` 访问令牌,`oauth` MCP 登录 Allowed: `token`, `oauth`. | | `[].name` | string | no | | | `[].prefix` | string | no | 令牌开头 | | `[].expiresAt` | integer | no | 过期时间;`null` 表示一直有效 May be null. | | `[].createdAt` | integer | no | | | `[].lastUsedAt` | integer | no | May be null. | ### Example response (200) ```json [ { "id": "tok_01jd8x2k7q", "kind": "token", "name": "内部助手", "prefix": "bxt_a1b2c3", "expiresAt": 1, "createdAt": 1, "lastUsedAt": 1 } ] ``` --- # 创建访问令牌 `POST /sites/{site}/access-tokens` 需要 `admin` 角色。用于以 `Authorization Bearer` 访问受密码保护站点的页面、`.md`、`llms.txt` 与 MCP 服务器。令牌只在创建时返回一次,每个站点最多 50 个。 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 | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `name` | string | yes | | | `expiresInDays` | integer | no | 有效天数;不传或 `null` 表示一直有效 May be null. | ## Example request ```bash curl -X POST https://api.butterix.com/v1/sites/acme-payments/access-tokens \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "name": "内部助手" }' ``` ## Responses ### 201 新令牌 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `id` | string | no | | | `token` | string | no | 完整令牌,只返回这一次 | ### 400 请求参数无效 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (201) ```json { "id": "tok_01jd8x2k7q", "token": "bxt_xxxxxxxxxxxxxxxx" } ``` --- # 吊销访问令牌 `DELETE /sites/{site}/access-tokens/{id}` 需要 `admin` 角色。 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 | ## Example request ```bash curl -X DELETE https://api.butterix.com/v1/sites/acme-payments/access-tokens/tok_01jd8x2k7q \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 成功 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `ok` | true | no | Allowed: `true`. | ### 404 资源不存在,或你没有访问权限 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "ok": true } ``` --- # 404 推荐重定向 `GET /sites/{site}/redirects` 最近 30 天读者访问过、但不存在的地址与推荐的页面,可以合并的整段搬家,以及已经加上的重定向。 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 | ## Example request ```bash curl https://api.butterix.com/v1/sites/acme-payments/redirects \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 推荐与已加上的重定向 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `suggestions` | list of objects | no | | | `suggestions[].path` | string | no | | | `suggestions[].count` | integer | no | | | `suggestions[].last` | integer | no | | | `suggestions[].target` | object | no | 地址最像的页面;没有把握时不给 | | `suggestions[].target.path` | string | no | | | `suggestions[].target.title` | string | no | | | `suggestions[].target.score` | number | no | | | `groups` | list of objects | no | | | `groups[].from` | string | no | | | `groups[].to` | string | no | | | `groups[].paths` | list of strings | no | | | `groups[].count` | integer | no | | | `rules` | list of objects | no | | | `rules[].from` | string | no | | | `rules[].to` | string | no | | | `rules[].status` | enum | no | Allowed: `301`, `302`. | | `rules[].at` | integer | no | | | `rules[].active` | boolean | no | 原地址有了页面时为 false,不再跳转 | ### Example response (200) ```json { "suggestions": [ { "path": "/gide", "count": 12, "last": 1, "target": { "path": "/guide", "title": "string", "score": 1.1 } } ], "groups": [ { "from": "/docs/old/*", "to": "/docs/new/:splat", "paths": [ "string" ], "count": 1 } ], "rules": [ { "from": "string", "to": "string", "status": 301, "at": 1, "active": true } ] } ``` --- # 加上重定向 `POST /sites/{site}/redirects` 需要 `editor` 角色。立即生效,不用重新部署;只在原地址没有页面时跳转。来源以 `/` 开头,可以以 `/*` 结尾;目标必须是站内地址,可以用 `:splat`。最多 200 条。 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 | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `from` | string | yes | | | `to` | string | yes | | | `status` | enum | no | Allowed: `301`, `302`. | ## Example request ```bash curl -X POST https://api.butterix.com/v1/sites/acme-payments/redirects \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "from": "/docs/old/*", "to": "/docs/new/:splat" }' ``` ## Responses ### 201 现在的全部重定向 --- # 去掉重定向 `DELETE /sites/{site}/redirects` 需要 `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 | ## Query parameters | Name | Type | Required | Description | |---|---|---|---| | `from` | string | yes | | ## Example request ```bash curl -X DELETE https://api.butterix.com/v1/sites/acme-payments/redirects?from=%2Fgide \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 现在的全部重定向 --- # 可导出的内容 `GET /sites/{site}/export` 线上版本的语言、版本、标签页与分组,以及各有多少页。还没有可导出的内容时 `outline` 为 `null`。 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 | ## Example request ```bash curl https://api.butterix.com/v1/sites/acme-payments/export \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 可导出的内容 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `outline` | object | no | May be null. | | `outline.title` | string | no | | | `outline.variants` | list of objects | no | | | `outline.variants[].key` | string | no | | | `outline.variants[].locale` | string | no | | | `outline.variants[].version` | string | no | | | `outline.variants[].product` | string | no | | | `outline.variants[].default` | boolean | no | | | `outline.variants[].pages` | integer | no | | | `outline.variants[].tabs` | list of objects | no | | | `outline.variants[].tabs[].id` | string | no | | | `outline.variants[].tabs[].title` | string | no | | | `outline.variants[].tabs[].pages` | integer | no | | | `outline.variants[].tabs[].sections` | list of objects | no | | ### Example response (200) ```json { "outline": { "title": "Acme", "variants": [ { "key": "zh||v1", "locale": "zh", "version": "v1", "product": "string", "default": true, "pages": 194, "tabs": [ { "id": "guides", "title": "指南", "pages": 44, "sections": [ {} ] } ] } ] } } ``` --- # 导出 Markdown `GET /sites/{site}/export/markdown` 线上版本的 Markdown 压缩包:每页一个文件,带图片(合计 50 MB 以内,超出的保留线上地址),页面之间是相对链接。每个成员同时导出一个,十分钟内最多 10 次,整个组织最多 30 次。下载太慢会断开。 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 | ## Query parameters | Name | Type | Required | Description | |---|---|---|---| | `variant` | string | no | 语言与版本,取自可导出的内容里的 `key`,省略时用默认语言与默认版本 | | `part` | string | no | 标签页或分组的 `id`,省略时导出全部 | ## Example request ```bash curl https://api.butterix.com/v1/sites/acme-payments/export/markdown \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 压缩包 Content type: `application/zip` Type: file ### Example response (200) ```json "<file>" ``` --- # 列出部署 `GET /sites/{site}/deployments` 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 | ## Query parameters | Name | Type | Required | Description | |---|---|---|---| | `limit` | integer | no | 返回条数,最大 200 | ## Example request ```bash curl https://api.butterix.com/v1/sites/acme-payments/deployments \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 部署列表,按创建时间倒序 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `[].id` | string | no | | | `[].siteId` | string | no | | | `[].kind` | enum | no | Allowed: `production`, `preview`. | | `[].status` | enum | no | Allowed: `queued`, `building`, `ready`, `failed`, `canceled`. | | `[].source` | string | no | `cli`(上传)、`hosted`(托管仓库)或 `git` | | `[].branch` | string | no | | | `[].commitSha` | string | no | | | `[].message` | string | no | | | `[].createdBy` | object | no | 触发者;用 API Key 触发时是创建密钥的人 | | `[].createdBy.id` | string | no | | | `[].createdBy.name` | string | no | | | `[].apiKey` | object | no | 用 API Key(CLI / CI)触发时,密钥的名称与首尾 | | `[].apiKey.name` | string | no | | | `[].apiKey.prefix` | string | no | 密钥前 10 个字符 | | `[].apiKey.suffix` | string | no | 密钥末尾 10 个字符 | | `[].error` | string | no | 失败原因 | | `[].pageCount` | integer | no | | | `[].sizeBytes` | integer | no | | | `[].durationMs` | integer | no | | | `[].url` | URL | no | 成功后才有。生产部署是站点地址,预览部署是 `<site>--<id 后 8 位>` 子域名 | | `[].isCurrent` | boolean | no | 是否为当前生产部署 | | `[].createdAt` | integer | no | | | `[].finishedAt` | integer | no | | ### Example response (200) ```json [ { "id": "dpl_01jd8x2k7q", "siteId": "site_2m4k8p", "kind": "production", "status": "queued", "source": "git", "branch": "main", "commitSha": "9fceb02d0ae598e95dc970b74767f19372d61af8", "message": "docs: 更新快速开始", "createdBy": { "id": "string", "name": "string" }, "apiKey": { "name": "GitHub Actions", "prefix": "biti_a1B2c", "suffix": "Kd82mQx0Zt" }, "error": "string", "pageCount": 94, "sizeBytes": 5832110, "durationMs": 6120, "url": "https://acme-payments--8x2k7q-sites.butterix.com", "isCurrent": true, "createdAt": 1, "finishedAt": 1 } ] ``` --- # 创建部署 `POST /sites/{site}/deployments` 需要 `editor` 角色。两种用法: 1. **上传源码**(`biti deploy` 使用):请求体是项目目录的 gzip tar 包(`Content-Type: application/gzip`,最大 200 MB)。 请求头 `x-biti-preview: 1` 创建预览部署,`x-biti-message` 是 URL 编码的部署说明。 2. **从仓库重新构建**:JSON `{ preview?, branch? }`,从托管仓库或已连接的 Git 仓库构建。通过 CLI 上传过的站点不支持这种方式。 返回 202 与部署 id,用[获取部署](https://docs.butterix.com/api-reference/deployments/get-deployment.md)轮询状态。 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 | ## Header parameters | Name | Type | Required | Description | |---|---|---|---| | `x-biti-preview` | enum | no | 上传源码时:`1` 表示预览部署 Allowed: `0`, `1`. | | `x-biti-message` | string | no | 上传源码时:URL 编码的部署说明 | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `preview` | boolean | no | 创建预览部署而不是生产部署 | | `branch` | string | no | 构建的分支,默认是站点的生产分支 | ## Example request ```bash tar --exclude=node_modules --exclude=.git --exclude=dist -czf site.tgz . curl -X POST https://api.butterix.com/v1/sites/acme-payments/deployments \ -H "Authorization: Bearer $BITI_TOKEN" \ -H "Content-Type: application/gzip" \ -H "x-biti-preview: 1" \ --data-binary @site.tgz ``` ## Responses ### 202 已排队 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `id` | string | no | | ### 400 请求参数无效 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### 413 上传超过 200 MB Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (202) ```json { "id": "dpl_01jd8x2k7q" } ``` --- # 获取部署 `GET /deployments/{id}` 部署详情与构建日志。构建进行中时 `log` 是实时日志。 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 | |---|---|---|---| | `id` | string | yes | | ## Example request ```bash curl https://api.butterix.com/v1/deployments/dpl_01jd8x2k7q \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 部署 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `id` | string | no | | | `siteId` | string | no | | | `kind` | enum | no | Allowed: `production`, `preview`. | | `status` | enum | no | Allowed: `queued`, `building`, `ready`, `failed`, `canceled`. | | `source` | string | no | `cli`(上传)、`hosted`(托管仓库)或 `git` | | `branch` | string | no | | | `commitSha` | string | no | | | `message` | string | no | | | `createdBy` | object | no | 触发者;用 API Key 触发时是创建密钥的人 | | `createdBy.id` | string | no | | | `createdBy.name` | string | no | | | `apiKey` | object | no | 用 API Key(CLI / CI)触发时,密钥的名称与首尾 | | `apiKey.name` | string | no | | | `apiKey.prefix` | string | no | 密钥前 10 个字符 | | `apiKey.suffix` | string | no | 密钥末尾 10 个字符 | | `error` | string | no | 失败原因 | | `pageCount` | integer | no | | | `sizeBytes` | integer | no | | | `durationMs` | integer | no | | | `url` | URL | no | 成功后才有。生产部署是站点地址,预览部署是 `<site>--<id 后 8 位>` 子域名 | | `isCurrent` | boolean | no | 是否为当前生产部署 | | `createdAt` | integer | no | | | `finishedAt` | integer | no | | | `log` | string | no | 构建日志 | ### 404 资源不存在,或你没有访问权限 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "id": "dpl_01jd8x2k7q", "siteId": "site_2m4k8p", "kind": "production", "status": "queued", "source": "git", "branch": "main", "commitSha": "9fceb02d0ae598e95dc970b74767f19372d61af8", "message": "docs: 更新快速开始", "createdBy": { "id": "string", "name": "string" }, "apiKey": { "name": "GitHub Actions", "prefix": "biti_a1B2c", "suffix": "Kd82mQx0Zt" }, "error": "string", "pageCount": 94, "sizeBytes": 5832110, "durationMs": 6120, "url": "https://acme-payments--8x2k7q-sites.butterix.com", "isCurrent": true, "createdAt": 1, "finishedAt": 1, "log": "string" } ``` --- # 设为生产(回滚) `POST /deployments/{id}/promote` 需要 `editor` 角色。把任意一个状态为 `ready` 的部署(包括预览部署和更早的生产部署)设为生产。只是切换指针,即时生效,不会重新构建。 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 | |---|---|---|---| | `id` | string | yes | | ## Example request ```bash curl -X POST https://api.butterix.com/v1/deployments/dpl_01jd8x2k7q/promote \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 新的生产部署 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `id` | string | no | | | `siteId` | string | no | | | `kind` | enum | no | Allowed: `production`, `preview`. | | `status` | enum | no | Allowed: `queued`, `building`, `ready`, `failed`, `canceled`. | | `source` | string | no | `cli`(上传)、`hosted`(托管仓库)或 `git` | | `branch` | string | no | | | `commitSha` | string | no | | | `message` | string | no | | | `createdBy` | object | no | 触发者;用 API Key 触发时是创建密钥的人 | | `createdBy.id` | string | no | | | `createdBy.name` | string | no | | | `apiKey` | object | no | 用 API Key(CLI / CI)触发时,密钥的名称与首尾 | | `apiKey.name` | string | no | | | `apiKey.prefix` | string | no | 密钥前 10 个字符 | | `apiKey.suffix` | string | no | 密钥末尾 10 个字符 | | `error` | string | no | 失败原因 | | `pageCount` | integer | no | | | `sizeBytes` | integer | no | | | `durationMs` | integer | no | | | `url` | URL | no | 成功后才有。生产部署是站点地址,预览部署是 `<site>--<id 后 8 位>` 子域名 | | `isCurrent` | boolean | no | 是否为当前生产部署 | | `createdAt` | integer | no | | | `finishedAt` | integer | no | | ### 400 请求参数无效 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "id": "dpl_01jd8x2k7q", "siteId": "site_2m4k8p", "kind": "production", "status": "queued", "source": "git", "branch": "main", "commitSha": "9fceb02d0ae598e95dc970b74767f19372d61af8", "message": "docs: 更新快速开始", "createdBy": { "id": "string", "name": "string" }, "apiKey": { "name": "GitHub Actions", "prefix": "biti_a1B2c", "suffix": "Kd82mQx0Zt" }, "error": "string", "pageCount": 94, "sizeBytes": 5832110, "durationMs": 6120, "url": "https://acme-payments--8x2k7q-sites.butterix.com", "isCurrent": true, "createdAt": 1, "finishedAt": 1 } ``` --- # 取消部署 `POST /deployments/{id}/cancel` 只能取消仍在排队(`queued`)的部署。 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 | |---|---|---|---| | `id` | string | yes | | ## Example request ```bash curl -X POST https://api.butterix.com/v1/deployments/dpl_01jd8x2k7q/cancel \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 成功 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `ok` | true | no | Allowed: `true`. | ### 400 请求参数无效 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "ok": true } ``` --- # 列出域名 `GET /sites/{site}/domains` 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 | ## Example request ```bash curl https://api.butterix.com/v1/sites/acme-payments/domains \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 域名列表 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `[].domain` | string | no | | | `[].verified` | boolean | no | | | `[].primary` | boolean | no | 是否为主域名 | | `[].verifyRecord` | object | no | 需要添加的 TXT 记录 | | `[].verifyRecord.type` | "TXT" | no | Allowed: `TXT`. | | `[].verifyRecord.name` | string | no | | | `[].verifyRecord.value` | string | no | | | `[].cname` | string | no | CNAME 目标 | | `[].createdAt` | integer | no | | ### Example response (200) ```json [ { "domain": "docs.acme.com", "verified": false, "primary": false, "verifyRecord": { "type": "TXT", "name": "_butterix.docs.acme.com", "value": "butterix-verify=a1b2c3d4e5f6" }, "cname": "sites.butterix.com", "createdAt": 1 } ] ``` --- # 添加域名 `POST /sites/{site}/domains` 需要 `admin` 角色。返回需要配置的 TXT 验证记录与 CNAME 目标。一个域名只能连接到一个站点。 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 | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `domain` | string | yes | | ## Example request ```bash curl -X POST https://api.butterix.com/v1/sites/acme-payments/domains \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "domain": "docs.acme.com" }' ``` ## Responses ### 201 新域名(未验证) Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `domain` | string | no | | | `verified` | boolean | no | | | `primary` | boolean | no | 是否为主域名 | | `verifyRecord` | object | no | 需要添加的 TXT 记录 | | `verifyRecord.type` | "TXT" | no | Allowed: `TXT`. | | `verifyRecord.name` | string | no | | | `verifyRecord.value` | string | no | | | `cname` | string | no | CNAME 目标 | | `createdAt` | integer | no | | ### 400 请求参数无效 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### 409 冲突(名称已被占用、重复添加或合并冲突) Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (201) ```json { "domain": "docs.acme.com", "verified": false, "primary": false, "verifyRecord": { "type": "TXT", "name": "_butterix.docs.acme.com", "value": "butterix-verify=a1b2c3d4e5f6" }, "cname": "sites.butterix.com", "createdAt": 1 } ``` --- # 验证域名 `POST /sites/{site}/domains/{domain}/verify` 查询 `_butterix.<domain>` 的 TXT 记录,匹配后标记为已验证,域名立即开始指向站点,平台随后自动通过 Let's Encrypt 签发 HTTPS 证书。 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 | | `domain` | string | yes | | ## Example request ```bash curl -X POST https://api.butterix.com/v1/sites/acme-payments/domains/docs.acme.com/verify \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 验证结果 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `domain` | string | no | | | `verified` | boolean | no | | | `primary` | boolean | no | 是否为主域名 | | `verifyRecord` | object | no | 需要添加的 TXT 记录 | | `verifyRecord.type` | "TXT" | no | Allowed: `TXT`. | | `verifyRecord.name` | string | no | | | `verifyRecord.value` | string | no | | | `cname` | string | no | CNAME 目标 | | `createdAt` | integer | no | | | `checked` | true | no | Allowed: `true`. | ### Example response (200) ```json { "domain": "docs.acme.com", "verified": false, "primary": false, "verifyRecord": { "type": "TXT", "name": "_butterix.docs.acme.com", "value": "butterix-verify=a1b2c3d4e5f6" }, "cname": "sites.butterix.com", "createdAt": 1, "checked": true } ``` --- # 设为主域名 `POST /sites/{site}/domains/{domain}/primary` 需要 `admin` 角色。canonical、站点地图、`llms.txt` 与 `.md` 里的绝对地址改用这个域名,并自动重新部署线上的版本。域名需要已验证,且 HTTPS 证书已生效。 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 | | `domain` | string | yes | | ## Example request ```bash curl -X POST https://api.butterix.com/v1/sites/acme-payments/domains/docs.acme.com/primary \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 主域名 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `domain` | string | no | | | `verified` | boolean | no | | | `primary` | boolean | no | 是否为主域名 | | `verifyRecord` | object | no | 需要添加的 TXT 记录 | | `verifyRecord.type` | "TXT" | no | Allowed: `TXT`. | | `verifyRecord.name` | string | no | | | `verifyRecord.value` | string | no | | | `cname` | string | no | CNAME 目标 | | `createdAt` | integer | no | | | `deployment` | string | no | 因此开始的部署;不需要或无法重新部署时没有 | ### 400 请求参数无效 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "domain": "docs.acme.com", "verified": false, "primary": false, "verifyRecord": { "type": "TXT", "name": "_butterix.docs.acme.com", "value": "butterix-verify=a1b2c3d4e5f6" }, "cname": "sites.butterix.com", "createdAt": 1, "deployment": "string" } ``` --- # 移除域名 `DELETE /sites/{site}/domains/{domain}` 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 | | `domain` | string | yes | | ## Example request ```bash curl -X DELETE https://api.butterix.com/v1/sites/acme-payments/domains/docs.acme.com \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 成功 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `ok` | true | no | Allowed: `true`. | ### Example response (200) ```json { "ok": true } ``` --- # 连接 Git 仓库 `PUT /sites/{site}/git` 需要 `admin` 角色。用远程仓库替换托管仓库,立即拉取并开始一次生产部署。 私有仓库需要提供具有读取权限的访问令牌(加密存储);使用可视化编辑器发布时还需要写权限。 连接后请在仓库中配置 Webhook(地址与密钥见响应中的 `git`)。 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 | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `url` | string | yes | https 地址 | | `branch` | string | no | | | `token` | string | no | 访问令牌;留空时保留已有令牌 | ## Example request ```bash curl -X PUT https://api.butterix.com/v1/sites/acme-payments/git \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "url": "https://github.com/acme/docs.git" }' ``` ## Responses ### 200 站点详情 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `id` | string | no | | | `slug` | string | no | | | `name` | string | no | | | `url` | URL | no | | | `sourceType` | enum | no | 内容来源:托管仓库、外部 Git 仓库或 CLI 上传 Allowed: `hosted`, `git`, `upload`. | | `status` | enum | no | 最近一次部署的状态,没有部署时为 `none` Allowed: `queued`, `building`, `ready`, `failed`, `canceled`, `none`. | | `updatedAt` | integer | no | | | `pageCount` | integer | no | 生产部署的页面数 | | `orgSlug` | string | no | | | `git` | object | no | 连接了 Git 仓库时存在 | | `git.url` | string | no | | | `git.branch` | string | no | | | `git.hasToken` | boolean | no | | | `git.webhookUrl` | string | no | | | `git.webhookSecret` | string | no | | | `production` | object | no | | | `production.id` | string | no | | | `production.siteId` | string | no | | | `production.kind` | enum | no | Allowed: `production`, `preview`. | | `production.status` | enum | no | Allowed: `queued`, `building`, `ready`, `failed`, `canceled`. | | `production.source` | string | no | `cli`(上传)、`hosted`(托管仓库)或 `git` | | `production.branch` | string | no | | | `production.commitSha` | string | no | | | `production.message` | string | no | | | `production.createdBy` | object | no | 触发者;用 API Key 触发时是创建密钥的人 | | `production.createdBy.id` | string | no | | | `production.createdBy.name` | string | no | | | `production.apiKey` | object | no | 用 API Key(CLI / CI)触发时,密钥的名称与首尾 | | `production.apiKey.name` | string | no | | | `production.apiKey.prefix` | string | no | 密钥前 10 个字符 | | `production.apiKey.suffix` | string | no | 密钥末尾 10 个字符 | | `production.error` | string | no | 失败原因 | | `production.pageCount` | integer | no | | | `production.sizeBytes` | integer | no | | | `production.durationMs` | integer | no | | | `production.url` | URL | no | 成功后才有。生产部署是站点地址,预览部署是 `<site>--<id 后 8 位>` 子域名 | | `production.isCurrent` | boolean | no | 是否为当前生产部署 | | `production.createdAt` | integer | no | | | `production.finishedAt` | integer | no | | | `domains` | list of objects | no | | | `domains[].domain` | string | no | | | `domains[].verified` | boolean | no | | | `domains[].primary` | boolean | no | 是否为主域名 | | `domains[].verifyRecord` | object | no | 需要添加的 TXT 记录 | | `domains[].verifyRecord.type` | "TXT" | no | Allowed: `TXT`. | | `domains[].verifyRecord.name` | string | no | | | `domains[].verifyRecord.value` | string | no | | | `domains[].cname` | string | no | CNAME 目标 | | `domains[].createdAt` | integer | no | | | `access` | object | no | | | `access.mode` | enum | no | Allowed: `public`, `password`. | | `ai` | object | no | | | `ai.enabled` | boolean | no | | | `ai.provider` | enum | no | Allowed: `anthropic`, `deepseek`, `openrouter`. | | `ai.model` | string | no | | | `ai.hasKey` | boolean | no | 是否设置了站点密钥 | | `ai.keyMasked` | string | no | | | `ai.platformKeyAvailable` | boolean | no | 平台是否为当前提供商配置了默认密钥 | | `ai.platformKeys` | map from strings to booleans | no | 每个提供商是否有平台密钥 | | `ai.guidance` | string | no | | | `ai.effort` | enum | no | 推理强度;`null` 表示使用模型的建议档位 May be null. Allowed: `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`. | | `ai.retentionDays` | integer | no | 提问记录保留天数;`null` 表示一直保留 May be null. | | `ai.dailyLimit` | integer | no | 滚动 24 小时内调用模型的提问上限;`null` 表示不限 May be null. | | `ai.agent` | boolean | no | 控制台 AI 是否启用 | | `ai.gaps` | boolean | no | 是否每天自动整理文档缺口 | | `ai.support` | object | no | 答不上时转人工 | | `ai.support.enabled` | boolean | no | | | `ai.support.url` | string | no | | | `ai.support.email` | string | no | | | `primaryUrl` | URL | no | 主域名的地址;没有自定义域名时与 `url` 相同 | | `mcpUrl` | URL | no | | ### 400 请求参数无效 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "id": "site_2m4k8p", "slug": "acme-payments", "name": "Acme 文档", "url": "https://acme-payments-sites.butterix.com", "sourceType": "hosted", "status": "queued", "updatedAt": 1, "pageCount": 94, "orgSlug": "acme", "git": { "url": "https://github.com/acme/docs.git", "branch": "main", "hasToken": true, "webhookUrl": "https://api.butterix.com/v1/webhooks/github/site_2m4k8p", "webhookSecret": "string" }, "production": { "id": "dpl_01jd8x2k7q", "siteId": "site_2m4k8p", "kind": "production", "status": "queued", "source": "git", "branch": "main", "commitSha": "9fceb02d0ae598e95dc970b74767f19372d61af8", "message": "docs: 更新快速开始", "createdBy": { "id": "string", "name": "string" }, "apiKey": { "name": "GitHub Actions", "prefix": "biti_a1B2c", "suffix": "Kd82mQx0Zt" }, "error": "string", "pageCount": 94, "sizeBytes": 5832110, "durationMs": 6120, "url": "https://acme-payments--8x2k7q-sites.butterix.com", "isCurrent": true, "createdAt": 1, "finishedAt": 1 }, "domains": [ { "domain": "docs.acme.com", "verified": false, "primary": false, "verifyRecord": { "type": "TXT", "name": "_butterix.docs.acme.com", "value": "butterix-verify=a1b2c3d4e5f6" }, "cname": "sites.butterix.com", "createdAt": 1 } ], "access": { "mode": "public" }, "ai": { "enabled": true, "provider": "anthropic", "model": "claude-opus-5-5", "hasKey": true, "keyMasked": "sk-a…9f2c", "platformKeyAvailable": true, "platformKeys": { "key": true }, "guidance": "string", "effort": "none", "retentionDays": 1, "dailyLimit": 200, "agent": true, "gaps": false, "support": { "enabled": false, "url": "", "email": "" } }, "primaryUrl": "https://docs.acme.com", "mcpUrl": "https://docs.acme.com/_mcp/server" } ``` --- # 断开 Git 仓库 `DELETE /sites/{site}/git` 回到 ButterIX 托管仓库,之后的推送不再触发部署。 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 | ## Example request ```bash curl -X DELETE https://api.butterix.com/v1/sites/acme-payments/git \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 站点详情 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `id` | string | no | | | `slug` | string | no | | | `name` | string | no | | | `url` | URL | no | | | `sourceType` | enum | no | 内容来源:托管仓库、外部 Git 仓库或 CLI 上传 Allowed: `hosted`, `git`, `upload`. | | `status` | enum | no | 最近一次部署的状态,没有部署时为 `none` Allowed: `queued`, `building`, `ready`, `failed`, `canceled`, `none`. | | `updatedAt` | integer | no | | | `pageCount` | integer | no | 生产部署的页面数 | | `orgSlug` | string | no | | | `git` | object | no | 连接了 Git 仓库时存在 | | `git.url` | string | no | | | `git.branch` | string | no | | | `git.hasToken` | boolean | no | | | `git.webhookUrl` | string | no | | | `git.webhookSecret` | string | no | | | `production` | object | no | | | `production.id` | string | no | | | `production.siteId` | string | no | | | `production.kind` | enum | no | Allowed: `production`, `preview`. | | `production.status` | enum | no | Allowed: `queued`, `building`, `ready`, `failed`, `canceled`. | | `production.source` | string | no | `cli`(上传)、`hosted`(托管仓库)或 `git` | | `production.branch` | string | no | | | `production.commitSha` | string | no | | | `production.message` | string | no | | | `production.createdBy` | object | no | 触发者;用 API Key 触发时是创建密钥的人 | | `production.createdBy.id` | string | no | | | `production.createdBy.name` | string | no | | | `production.apiKey` | object | no | 用 API Key(CLI / CI)触发时,密钥的名称与首尾 | | `production.apiKey.name` | string | no | | | `production.apiKey.prefix` | string | no | 密钥前 10 个字符 | | `production.apiKey.suffix` | string | no | 密钥末尾 10 个字符 | | `production.error` | string | no | 失败原因 | | `production.pageCount` | integer | no | | | `production.sizeBytes` | integer | no | | | `production.durationMs` | integer | no | | | `production.url` | URL | no | 成功后才有。生产部署是站点地址,预览部署是 `<site>--<id 后 8 位>` 子域名 | | `production.isCurrent` | boolean | no | 是否为当前生产部署 | | `production.createdAt` | integer | no | | | `production.finishedAt` | integer | no | | | `domains` | list of objects | no | | | `domains[].domain` | string | no | | | `domains[].verified` | boolean | no | | | `domains[].primary` | boolean | no | 是否为主域名 | | `domains[].verifyRecord` | object | no | 需要添加的 TXT 记录 | | `domains[].verifyRecord.type` | "TXT" | no | Allowed: `TXT`. | | `domains[].verifyRecord.name` | string | no | | | `domains[].verifyRecord.value` | string | no | | | `domains[].cname` | string | no | CNAME 目标 | | `domains[].createdAt` | integer | no | | | `access` | object | no | | | `access.mode` | enum | no | Allowed: `public`, `password`. | | `ai` | object | no | | | `ai.enabled` | boolean | no | | | `ai.provider` | enum | no | Allowed: `anthropic`, `deepseek`, `openrouter`. | | `ai.model` | string | no | | | `ai.hasKey` | boolean | no | 是否设置了站点密钥 | | `ai.keyMasked` | string | no | | | `ai.platformKeyAvailable` | boolean | no | 平台是否为当前提供商配置了默认密钥 | | `ai.platformKeys` | map from strings to booleans | no | 每个提供商是否有平台密钥 | | `ai.guidance` | string | no | | | `ai.effort` | enum | no | 推理强度;`null` 表示使用模型的建议档位 May be null. Allowed: `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`. | | `ai.retentionDays` | integer | no | 提问记录保留天数;`null` 表示一直保留 May be null. | | `ai.dailyLimit` | integer | no | 滚动 24 小时内调用模型的提问上限;`null` 表示不限 May be null. | | `ai.agent` | boolean | no | 控制台 AI 是否启用 | | `ai.gaps` | boolean | no | 是否每天自动整理文档缺口 | | `ai.support` | object | no | 答不上时转人工 | | `ai.support.enabled` | boolean | no | | | `ai.support.url` | string | no | | | `ai.support.email` | string | no | | | `primaryUrl` | URL | no | 主域名的地址;没有自定义域名时与 `url` 相同 | | `mcpUrl` | URL | no | | ### Example response (200) ```json { "id": "site_2m4k8p", "slug": "acme-payments", "name": "Acme 文档", "url": "https://acme-payments-sites.butterix.com", "sourceType": "hosted", "status": "queued", "updatedAt": 1, "pageCount": 94, "orgSlug": "acme", "git": { "url": "https://github.com/acme/docs.git", "branch": "main", "hasToken": true, "webhookUrl": "https://api.butterix.com/v1/webhooks/github/site_2m4k8p", "webhookSecret": "string" }, "production": { "id": "dpl_01jd8x2k7q", "siteId": "site_2m4k8p", "kind": "production", "status": "queued", "source": "git", "branch": "main", "commitSha": "9fceb02d0ae598e95dc970b74767f19372d61af8", "message": "docs: 更新快速开始", "createdBy": { "id": "string", "name": "string" }, "apiKey": { "name": "GitHub Actions", "prefix": "biti_a1B2c", "suffix": "Kd82mQx0Zt" }, "error": "string", "pageCount": 94, "sizeBytes": 5832110, "durationMs": 6120, "url": "https://acme-payments--8x2k7q-sites.butterix.com", "isCurrent": true, "createdAt": 1, "finishedAt": 1 }, "domains": [ { "domain": "docs.acme.com", "verified": false, "primary": false, "verifyRecord": { "type": "TXT", "name": "_butterix.docs.acme.com", "value": "butterix-verify=a1b2c3d4e5f6" }, "cname": "sites.butterix.com", "createdAt": 1 } ], "access": { "mode": "public" }, "ai": { "enabled": true, "provider": "anthropic", "model": "claude-opus-5-5", "hasKey": true, "keyMasked": "sk-a…9f2c", "platformKeyAvailable": true, "platformKeys": { "key": true }, "guidance": "string", "effort": "none", "retentionDays": 1, "dailyLimit": 200, "agent": true, "gaps": false, "support": { "enabled": false, "url": "", "email": "" } }, "primaryUrl": "https://docs.acme.com", "mcpUrl": "https://docs.acme.com/_mcp/server" } ``` --- # 接收 GitHub Webhook `POST /webhooks/github/{siteId}` 由 GitHub(或兼容的 Git 服务)调用,无需 API 认证,但必须带正确的 `X-Hub-Signature-256` 签名(HMAC-SHA256,密钥为站点的 webhook secret)。 - `push` 到生产分支 → 生产部署。 - `pull_request` 的 `opened` / `synchronize` / `reopened` → 该分支的预览部署。 - `ping` → `{ ok: true }`;其他事件 → `{ ignored: true }`。 Base URL: https://api.butterix.com/v1 ## Path parameters | Name | Type | Required | Description | |---|---|---|---| | `siteId` | string | yes | 站点 id(不是 slug) | ## Header parameters | Name | Type | Required | Description | |---|---|---|---| | `X-GitHub-Event` | enum | yes | Allowed: `push`, `pull_request`, `ping`. | | `X-Hub-Signature-256` | string | yes | | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `ref` | string | no | | | `after` | string | no | | | `head_commit` | object | no | | | `head_commit.message` | string | no | | | `action` | string | no | | | `pull_request` | object | no | | | `pull_request.number` | integer | no | | | `pull_request.title` | string | no | | | `pull_request.head` | object | no | | | `pull_request.head.ref` | string | no | | | `pull_request.head.sha` | string | no | | ## Example request ```bash curl -X POST https://api.butterix.com/v1/webhooks/github/site_2m4k8p \ -H "X-GitHub-Event: push" \ -H "X-Hub-Signature-256: sha256=4f1c…" \ -H "Content-Type: application/json" \ -d '{}' ``` ## Responses ### 200 ping 或被忽略的事件 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `ok` | boolean | no | | | `ignored` | boolean | no | | ### 202 已创建部署 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `deploymentId` | string | no | | ### 401 签名错误 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "ok": true, "ignored": true } ``` --- # 获取 Ask AI 设置 `GET /sites/{site}/ai` 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 | ## Example request ```bash curl https://api.butterix.com/v1/sites/acme-payments/ai \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 当前设置(密钥只返回掩码) Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `enabled` | boolean | no | | | `provider` | enum | no | Allowed: `anthropic`, `deepseek`, `openrouter`. | | `model` | string | no | | | `hasKey` | boolean | no | 是否设置了站点密钥 | | `keyMasked` | string | no | | | `platformKeyAvailable` | boolean | no | 平台是否为当前提供商配置了默认密钥 | | `platformKeys` | map from strings to booleans | no | 每个提供商是否有平台密钥 | | `guidance` | string | no | | | `effort` | enum | no | 推理强度;`null` 表示使用模型的建议档位 May be null. Allowed: `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`. | | `retentionDays` | integer | no | 提问记录保留天数;`null` 表示一直保留 May be null. | | `dailyLimit` | integer | no | 滚动 24 小时内调用模型的提问上限;`null` 表示不限 May be null. | | `agent` | boolean | no | 控制台 AI 是否启用 | | `gaps` | boolean | no | 是否每天自动整理文档缺口 | | `support` | object | no | 答不上时转人工 | | `support.enabled` | boolean | no | | | `support.url` | string | no | | | `support.email` | string | no | | ### Example response (200) ```json { "enabled": true, "provider": "anthropic", "model": "claude-opus-5-5", "hasKey": true, "keyMasked": "sk-a…9f2c", "platformKeyAvailable": true, "platformKeys": { "key": true }, "guidance": "string", "effort": "none", "retentionDays": 1, "dailyLimit": 200, "agent": true, "gaps": false, "support": { "enabled": false, "url": "", "email": "" } } ``` --- # 更新 Ask AI 设置 `PUT /sites/{site}/ai` 需要 `admin` 角色。只更新传入的字段。 - 切换 `provider` 且未传 `model` 时,模型重置为该提供商的默认模型;未传 `apiKey` 时清除原密钥(密钥与提供商绑定)。 - `apiKey: null` 清除站点密钥,回退到平台密钥(如有)。密钥以 AES-256-GCM 加密存储。 - `effort` 的可选档位由模型决定(见 [模型列表](https://docs.butterix.com/api-reference/ai/list-models.md) 里的 `reasoning`);不支持的档位使用时换成最接近的一档,`null` 表示使用模型的建议档位。 - `dailyLimit` 是滚动 24 小时内调用模型的提问上限(1–1000000),`null` 表示不限;未设置时默认 200。 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 | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `enabled` | boolean | no | | | `provider` | enum | no | Allowed: `anthropic`, `deepseek`, `openrouter`. | | `model` | string | no | | | `apiKey` | string | no | 新密钥;`null` 表示清除 May be null. | | `guidance` | string | no | 附加到系统提示的指引 | | `effort` | enum | no | 推理强度;`null` 表示使用模型的建议档位 May be null. Allowed: `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`. | | `dailyLimit` | integer | no | 滚动 24 小时内调用模型的提问上限;`null` 表示不限 May be null. | | `agent` | boolean | no | 控制台 AI(Agent、定时任务、AI 翻译、文档缺口)的开关,与 Ask AI 互不影响 | | `gaps` | boolean | no | 每天自动整理文档缺口 | | `support` | object | no | 答不上时转人工。只更新传入的字段;开启时至少要有一种联系方式 | | `support.enabled` | boolean | no | | | `support.url` | string | no | 支持页面:`https://` 地址或 `/` 开头的站内路径;空串表示清除 | | `support.email` | string | no | 支持邮箱;空串表示清除 | ## Example request ```bash curl -X PUT https://api.butterix.com/v1/sites/acme-payments/ai \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "provider": "deepseek", "model": "deepseek-flash", "apiKey": "sk-xxxxxxxxxxxxxxxx" }' ``` ## Responses ### 200 更新后的设置 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `enabled` | boolean | no | | | `provider` | enum | no | Allowed: `anthropic`, `deepseek`, `openrouter`. | | `model` | string | no | | | `hasKey` | boolean | no | 是否设置了站点密钥 | | `keyMasked` | string | no | | | `platformKeyAvailable` | boolean | no | 平台是否为当前提供商配置了默认密钥 | | `platformKeys` | map from strings to booleans | no | 每个提供商是否有平台密钥 | | `guidance` | string | no | | | `effort` | enum | no | 推理强度;`null` 表示使用模型的建议档位 May be null. Allowed: `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`. | | `retentionDays` | integer | no | 提问记录保留天数;`null` 表示一直保留 May be null. | | `dailyLimit` | integer | no | 滚动 24 小时内调用模型的提问上限;`null` 表示不限 May be null. | | `agent` | boolean | no | 控制台 AI 是否启用 | | `gaps` | boolean | no | 是否每天自动整理文档缺口 | | `support` | object | no | 答不上时转人工 | | `support.enabled` | boolean | no | | | `support.url` | string | no | | | `support.email` | string | no | | ### Example response (200) ```json { "enabled": true, "provider": "anthropic", "model": "claude-opus-5-5", "hasKey": true, "keyMasked": "sk-a…9f2c", "platformKeyAvailable": true, "platformKeys": { "key": true }, "guidance": "string", "effort": "none", "retentionDays": 1, "dailyLimit": 200, "agent": true, "gaps": false, "support": { "enabled": false, "url": "", "email": "" } } ``` --- # 测试提问 `POST /sites/{site}/ai/test` 需要 `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 | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `question` | string | no | | ## Example request ```bash curl -X POST https://api.butterix.com/v1/sites/acme-payments/ai/test \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{}' ``` ## Responses ### 200 回答 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `answer` | string | no | | | `sources` | list of objects | no | | | `sources[].title` | string | no | | | `sources[].url` | string | no | | | `model` | string | no | | | `provider` | enum | no | Allowed: `anthropic`, `deepseek`, `openrouter`. | | `ms` | integer | no | | ### 400 请求参数无效 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### 502 模型提供商返回错误 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "answer": "在控制台的「组织设置 → API Keys」中创建密钥 [1]。", "sources": [ { "title": "CLI 部署与 API Key", "url": "/guides/deploy/cli-deploy" } ], "model": "claude-opus-5-5", "provider": "anthropic", "ms": 2380 } ``` --- # 列出可用模型 `GET /ai/models` 实时从提供商拉取模型列表(缓存 10 分钟)。传 `site` 时优先使用该站点的密钥,否则使用平台密钥。 无法拉取时返回内置列表,并设置 `live: false` 与 `error`。 Base URL: https://api.butterix.com/v1 Authentication: bearer token in Authorization header or API key in cookie `biti_session` ## Query parameters | Name | Type | Required | Description | |---|---|---|---| | `provider` | enum | no | Allowed: `anthropic`, `deepseek`, `openrouter`. | | `site` | string | no | 站点 slug 或 id | ## Example request ```bash curl https://api.butterix.com/v1/ai/models \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 模型列表(推荐模型排在最前) Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `models` | list of objects | no | | | `models[].id` | string | no | | | `models[].label` | string | no | | | `models[].contextWindow` | integer | no | | | `models[].pricing` | object | no | 每百万 tokens 的美元价格(提供商报告时) | | `models[].pricing.input` | number | no | | | `models[].pricing.output` | number | no | | | `models[].recommended` | boolean | no | | | `models[].reasoning` | object | no | 模型支持的推理强度;没有时不返回 | | `models[].reasoning.efforts` | list of enums | no | 由低到高的档位,`none` 是关闭思考;为空表示会思考但没有档位可选 | | `models[].reasoning.suggested` | string | no | 没有设置时使用的档位 | | `models[].reasoning.default` | string | no | 模型自己的默认档位 | | `live` | boolean | no | | | `error` | string | no | | ### Example response (200) ```json { "models": [ { "id": "claude-opus-5-5", "label": "Claude Opus 5.5", "contextWindow": 1000000, "pricing": { "input": 4, "output": 20 }, "recommended": true, "reasoning": { "efforts": [ "none" ], "suggested": "low", "default": "high" } } ], "live": true, "error": "string" } ``` --- # 列出指定问答 `GET /sites/{site}/guidance` 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 | ## Example request ```bash curl https://api.butterix.com/v1/sites/acme-payments/guidance \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 指定问答,按创建时间倒序 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `[].id` | string | no | | | `[].context` | list of strings | no | 示例问题 | | `[].document` | string | no | 答案(Markdown) | | `[].enabled` | boolean | no | | | `[].createdAt` | integer | no | | | `[].updatedAt` | integer | no | | ### Example response (200) ```json [ { "id": "gd_01jd8x2k7q", "context": [ "怎么联系支持?" ], "document": "string", "enabled": true, "createdAt": 1, "updatedAt": 1 } ] ``` --- # 创建指定问答 `POST /sites/{site}/guidance` 需要 `editor` 角色。读者的问题与任一示例问题相近时,Ask AI 优先按 `document` 回答。每个站点最多 200 条。 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 | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `context` | list of strings | yes | 示例问题 | | `document` | string | yes | 答案(Markdown) | | `enabled` | boolean | no | | ## Example request ```bash curl -X POST https://api.butterix.com/v1/sites/acme-payments/guidance \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "context": [ "怎么联系支持?", "有客服吗" ], "document": "发邮件到 support@acme.com,工作日 4 小时内回复。" }' ``` ## Responses ### 201 新的指定问答 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `id` | string | no | | | `context` | list of strings | no | 示例问题 | | `document` | string | no | 答案(Markdown) | | `enabled` | boolean | no | | | `createdAt` | integer | no | | | `updatedAt` | integer | no | | ### 400 请求参数无效 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (201) ```json { "id": "gd_01jd8x2k7q", "context": [ "怎么联系支持?" ], "document": "string", "enabled": true, "createdAt": 1, "updatedAt": 1 } ``` --- # 获取指定问答 `GET /sites/{site}/guidance/{id}` 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 | ## Example request ```bash curl https://api.butterix.com/v1/sites/acme-payments/guidance/gd_01jd8x2k7q \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 指定问答 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `id` | string | no | | | `context` | list of strings | no | 示例问题 | | `document` | string | no | 答案(Markdown) | | `enabled` | boolean | no | | | `createdAt` | integer | no | | | `updatedAt` | integer | no | | ### 404 资源不存在,或你没有访问权限 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "id": "gd_01jd8x2k7q", "context": [ "怎么联系支持?" ], "document": "string", "enabled": true, "createdAt": 1, "updatedAt": 1 } ``` --- # 更新指定问答 `PATCH /sites/{site}/guidance/{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 | |---|---|---|---| | `context` | list of strings | no | | | `document` | string | no | | | `enabled` | boolean | no | | ## Example request ```bash curl -X PATCH https://api.butterix.com/v1/sites/acme-payments/guidance/gd_01jd8x2k7q \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{}' ``` ## Responses ### 200 更新后的指定问答 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `id` | string | no | | | `context` | list of strings | no | 示例问题 | | `document` | string | no | 答案(Markdown) | | `enabled` | boolean | no | | | `createdAt` | integer | no | | | `updatedAt` | integer | no | | ### 400 请求参数无效 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "id": "gd_01jd8x2k7q", "context": [ "怎么联系支持?" ], "document": "string", "enabled": true, "createdAt": 1, "updatedAt": 1 } ``` --- # 删除指定问答 `DELETE /sites/{site}/guidance/{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 | ## Example request ```bash curl -X DELETE https://api.butterix.com/v1/sites/acme-payments/guidance/gd_01jd8x2k7q \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 成功 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `ok` | true | no | Allowed: `true`. | ### Example response (200) ```json { "ok": true } ``` --- # 列出内容来源 `GET /sites/{site}/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 | 站点 slug 或 id | ## Example request ```bash curl https://api.butterix.com/v1/sites/acme-payments/sources \ -H "Authorization: Bearer <token>" ``` ## 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`;列表中不返回 | ### 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" } ] ``` --- # 添加内容来源 `POST /sites/{site}/sources` 需要 `editor` 角色。`document` 是一份 Markdown,`website` 从 `url` 开始抓取一个公开网站(遵守 robots.txt)。每个站点最多 20 个来源。 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 | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `kind` | enum | yes | Allowed: `document`, `website`. | | `title` | string | no | 标题;`document` 必填,`website` 默认为主机名 | | `url` | string | yes | 文档的引用地址,或抓取的起始地址 | | `document` | string | no | Markdown 正文,仅 `document` | | `paths` | list of strings | no | 只抓取这些路径开头的页面,默认是起始地址所在的目录,仅 `website` | | `exclude` | list of strings | no | 不抓取这些路径开头的页面,仅 `website` | | `maxPages` | integer | no | 页数上限,仅 `website` | | `refresh` | enum | no | 重新抓取的周期,仅 `website` 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 新的内容来源;网站在后台抓取 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 (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" } ``` --- # 获取内容来源 `GET /sites/{site}/sources/{id}` 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 | ## Example request ```bash curl https://api.butterix.com/v1/sites/acme-payments/sources/src_01jd8x2k7q \ -H "Authorization: Bearer <token>" ``` ## 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`;列表中不返回 | ### 404 资源不存在,或你没有访问权限 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" } ``` --- # 更新内容来源 `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" } ``` --- # 删除内容来源 `DELETE /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 | ## Example request ```bash curl -X DELETE https://api.butterix.com/v1/sites/acme-payments/sources/src_01jd8x2k7q \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 成功 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `ok` | true | no | Allowed: `true`. | ### Example response (200) ```json { "ok": true } ``` --- # 重新抓取网站 `POST /sites/{site}/sources/{id}/refresh` 需要 `editor` 角色。只适用于 `website`,在后台进行。 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 | ## Example request ```bash curl -X POST https://api.butterix.com/v1/sites/acme-payments/sources/src_01jd8x2k7q/refresh \ -H "Authorization: Bearer <token>" ``` ## Responses ### 202 已排队 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 (202) ```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" } ``` --- # 获取嵌入设置 `GET /sites/{site}/embed` 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 | ## Example request ```bash curl https://api.butterix.com/v1/sites/acme-payments/embed \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 允许嵌入助手的网站、皮肤,以及文档站自己的两套强调色 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `skin` | enum | no | 皮肤:`classic` 经典,`aurora` 极光(毛玻璃、边缘流光发光)。网页上的 `data-skin` 优先 Allowed: `classic`, `aurora`. | | `trigger` | enum | no | 入口样式:`button` 悬浮按钮,`bar` 底部输入框。网页上的 `data-trigger` 优先 Allowed: `button`, `bar`. | | `theme` | enum | no | 颜色模式,`auto` 跟随访客的系统设置。网页上的 `data-theme` 优先 Allowed: `dark`, `light`, `auto`. | | `color` | string | no | 亮色模式的强调色;null 表示用文档站自己的。网页上的 `data-color` 优先 May be null. | | `colorDark` | string | no | 暗色模式的强调色;null 时由 `color` 推出,或用文档站自己的。网页上的 `data-color-dark` 优先 May be null. | | `origins` | list of strings | no | 允许的来源;`*.` 表示任意子域名,http 只允许 localhost | | `accent` | object | no | 文档站亮色与暗色模式的强调色,嵌入时不指定颜色就用它们;还没发布过时为 null May be null. | | `accent.light` | string | no | | | `accent.dark` | string | no | | ### Example response (200) ```json { "skin": "classic", "trigger": "button", "theme": "dark", "color": "#7c5cff", "colorDark": "#9e8aff", "origins": [ "https://app.acme.com", "https://*.acme.com" ], "accent": { "light": "#a86200", "dark": "#ffc823" } } ``` --- # 更新嵌入设置 `PUT /sites/{site}/embed` 需要 `admin` 角色。只修改请求里给出的字段:`origins` 整体替换允许的来源(空列表表示关闭嵌入);外观字段(`skin`、`trigger`、`theme`、`color`、`colorDark`)立即生效,写 `null` 恢复默认。 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 | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `skin` | enum | no | 皮肤:`classic` 经典,`aurora` 极光(毛玻璃、边缘流光发光)。网页上的 `data-skin` 优先 Allowed: `classic`, `aurora`. | | `trigger` | enum | no | 入口样式:`button` 悬浮按钮,`bar` 底部输入框。网页上的 `data-trigger` 优先 Allowed: `button`, `bar`. | | `theme` | enum | no | 颜色模式,`auto` 跟随访客的系统设置。网页上的 `data-theme` 优先 Allowed: `dark`, `light`, `auto`. | | `color` | string | no | 亮色模式的强调色;null 表示用文档站自己的。网页上的 `data-color` 优先 May be null. | | `colorDark` | string | no | 暗色模式的强调色;null 时由 `color` 推出,或用文档站自己的。网页上的 `data-color-dark` 优先 May be null. | | `origins` | list of strings | no | 允许的来源;`*.` 表示任意子域名,http 只允许 localhost | ## Example request ```bash curl -X PUT https://api.butterix.com/v1/sites/acme-payments/embed \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{}' ``` ## Responses ### 200 更新后的设置 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `skin` | enum | no | 皮肤:`classic` 经典,`aurora` 极光(毛玻璃、边缘流光发光)。网页上的 `data-skin` 优先 Allowed: `classic`, `aurora`. | | `trigger` | enum | no | 入口样式:`button` 悬浮按钮,`bar` 底部输入框。网页上的 `data-trigger` 优先 Allowed: `button`, `bar`. | | `theme` | enum | no | 颜色模式,`auto` 跟随访客的系统设置。网页上的 `data-theme` 优先 Allowed: `dark`, `light`, `auto`. | | `color` | string | no | 亮色模式的强调色;null 表示用文档站自己的。网页上的 `data-color` 优先 May be null. | | `colorDark` | string | no | 暗色模式的强调色;null 时由 `color` 推出,或用文档站自己的。网页上的 `data-color-dark` 优先 May be null. | | `origins` | list of strings | no | 允许的来源;`*.` 表示任意子域名,http 只允许 localhost | ### 400 请求参数无效 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "skin": "classic", "trigger": "button", "theme": "dark", "color": "#7c5cff", "colorDark": "#9e8aff", "origins": [ "https://app.acme.com", "https://*.acme.com" ] } ``` --- # 文档考卷成绩 `GET /sites/{site}/evals` 最近 100 次[文档考卷](https://docs.butterix.com/guides/features/evals.md)的成绩,从新到旧。 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 | ## Example request ```bash curl https://api.butterix.com/v1/sites/acme-payments/evals \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 成绩列表 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `[].id` | string | no | | | `[].createdAt` | integer | no | | | `[].score` | integer | no | 答对的百分比 | | `[].passed` | integer | no | | | `[].total` | integer | no | | | `[].min` | integer | no | 及格线 | | `[].ok` | boolean | no | | | `[].model` | string | no | | | `[].judge` | string | no | | | `[].commit` | string | no | | ### Example response (200) ```json [ { "id": "eval_k2m9", "createdAt": 1764115200000, "score": 85, "passed": 17, "total": 20, "min": 80, "ok": true, "model": "deepseek-flash", "judge": "deepseek-flash", "commit": "0123abcd" } ] ``` --- # 上传文档考卷成绩 `POST /sites/{site}/evals` 需要 `editor` 角色,一般由 `biti eval --site` 调用。得分由 `results` 算出。 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 | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `min` | integer | no | 及格线(百分比) | | `model` | string | no | 作答的模型 | | `judge` | string | no | 评分的模型 | | `commit` | string | no | 文档的提交号 | | `results` | list of objects | yes | | | `results[].id` | string | no | | | `results[].question` | string | yes | | | `results[].pass` | boolean | no | | | `results[].met` | list of booleans | no | 每个要点是否说到 | | `results[].missing` | list of strings | no | 缺少的要点 | | `results[].said` | list of strings | no | 不该说却说了的内容 | | `results[].unseen` | list of strings | no | 没检索到的页面 | | `results[].sources` | list of strings | no | | | `results[].answer` | string | no | | | `results[].note` | string | no | 评分的说明 | | `results[].error` | string | no | 无法作答或评分的原因 | ## Example request ```bash curl -X POST https://api.butterix.com/v1/sites/acme-payments/evals \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "results": [ { "question": "退款多久到账?" } ] }' ``` ## Responses ### 201 已保存 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `id` | string | no | | | `createdAt` | integer | no | | | `score` | integer | no | 答对的百分比 | | `passed` | integer | no | | | `total` | integer | no | | | `min` | integer | no | 及格线 | | `ok` | boolean | no | | | `model` | string | no | | | `judge` | string | no | | | `commit` | string | no | | ### Example response (201) ```json { "id": "eval_k2m9", "createdAt": 1764115200000, "score": 85, "passed": 17, "total": 20, "min": 80, "ok": true, "model": "deepseek-flash", "judge": "deepseek-flash", "commit": "0123abcd" } ``` --- # 文档考卷详情 `GET /sites/{site}/evals/{id}` 一次成绩与每道题的结果。 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 | | ## Example request ```bash curl https://api.butterix.com/v1/sites/acme-payments/evals/eval_k2m9 \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 成绩与每道题的结果 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `id` | string | no | | | `createdAt` | integer | no | | | `score` | integer | no | 答对的百分比 | | `passed` | integer | no | | | `total` | integer | no | | | `min` | integer | no | 及格线 | | `ok` | boolean | no | | | `model` | string | no | | | `judge` | string | no | | | `commit` | string | no | | | `results` | list of objects | no | | | `results[].id` | string | no | | | `results[].question` | string | yes | | | `results[].pass` | boolean | no | | | `results[].met` | list of booleans | no | 每个要点是否说到 | | `results[].missing` | list of strings | no | 缺少的要点 | | `results[].said` | list of strings | no | 不该说却说了的内容 | | `results[].unseen` | list of strings | no | 没检索到的页面 | | `results[].sources` | list of strings | no | | | `results[].answer` | string | no | | | `results[].note` | string | no | 评分的说明 | | `results[].error` | string | no | 无法作答或评分的原因 | ### Example response (200) ```json { "id": "eval_k2m9", "createdAt": 1764115200000, "score": 85, "passed": 17, "total": 20, "min": 80, "ok": true, "model": "deepseek-flash", "judge": "deepseek-flash", "commit": "0123abcd", "results": [ { "id": "refund-time", "question": "退款多久到账?", "pass": true, "met": [ true ], "missing": [ "string" ], "said": [ "string" ], "unseen": [ "string" ], "sources": [ "/guides/refund" ], "answer": "三个工作日内到账,原路退回。", "note": "string", "error": "string" } ] } ``` --- # 删除文档考卷成绩 `DELETE /sites/{site}/evals/{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 | | ## Example request ```bash curl -X DELETE https://api.butterix.com/v1/sites/acme-payments/evals/eval_k2m9 \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 已删除 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `ok` | boolean | no | | ### Example response (200) ```json { "ok": true } ``` --- # 访问统计 `GET /sites/{site}/analytics` 按 User-Agent 把访问分为人类、AI(训练爬虫与 AI 助手)与其他爬虫。`.md` 请求、索引与规范文件的请求和 MCP 调用单独计数。 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 | ## Query parameters | Name | Type | Required | Description | |---|---|---|---| | `days` | integer | no | | ## Example request ```bash curl https://api.butterix.com/v1/sites/acme-payments/analytics \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 统计数据 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `totals` | object | no | | | `totals.views` | integer | no | 页面与 .md 访问总数 | | `totals.humanViews` | integer | no | | | `totals.visitors` | integer | no | 访客数,按天去重后累计,真人、AI 与爬虫都算 | | `totals.aiViews` | integer | no | AI 爬虫与 AI 助手 | | `totals.botViews` | integer | no | 搜索引擎与其他爬虫 | | `totals.markdownRequests` | integer | no | | | `totals.agentFileRequests` | integer | no | 索引(llms.txt、llms-full.txt)与 API 规范文件的请求,不计入以上各项 | | `totals.mcpCalls` | integer | no | | | `totals.searches` | integer | no | | | `totals.questions` | integer | no | | | `totals.feedbackUp` | integer | no | | | `totals.feedbackDown` | integer | no | | | `daily` | list of objects | no | | | `daily[].date` | date | no | | | `daily[].human` | integer | no | | | `daily[].ai` | integer | no | | | `daily[].bot` | integer | no | | | `daily[].visitors` | object | no | 当天按类型去重的访客 | | `daily[].visitors.human` | integer | no | | | `daily[].visitors.ai` | integer | no | | | `daily[].visitors.bot` | integer | no | | | `topPages` | list of objects | no | | | `topPages[].path` | string | no | | | `topPages[].views` | integer | no | | | `aiAgents` | list of objects | no | | | `aiAgents[].name` | string | no | | | `aiAgents[].count` | integer | no | | | `referrers` | list of objects | no | | | `referrers[].host` | string | no | | | `referrers[].count` | integer | no | | | `countries` | list of objects | no | | | `countries[].code` | string | no | | | `countries[].count` | integer | no | | | `notFound` | list of objects | no | | | `notFound[].path` | string | no | | | `notFound[].count` | integer | no | | | `agentFiles` | list of objects | no | 请求最多的索引与规范文件 | | `agentFiles[].path` | string | no | | | `agentFiles[].type` | enum | no | Allowed: `index`, `spec`. | | `agentFiles[].agents` | integer | no | | | `agentFiles[].humans` | integer | no | | | `agentFiles[].count` | integer | no | | | `topSearches` | list of objects | no | | | `topSearches[].q` | string | no | | | `topSearches[].count` | integer | no | | ### Example response (200) ```json { "totals": { "views": 1, "humanViews": 1, "visitors": 1, "aiViews": 1, "botViews": 1, "markdownRequests": 1, "agentFileRequests": 1, "mcpCalls": 1, "searches": 1, "questions": 1, "feedbackUp": 1, "feedbackDown": 1 }, "daily": [ { "date": "2026-11-20", "human": 1, "ai": 1, "bot": 1, "visitors": { "human": 1, "ai": 1, "bot": 1 } } ], "topPages": [ { "path": "string", "views": 1 } ], "aiAgents": [ { "name": "ClaudeBot", "count": 1 } ], "referrers": [ { "host": "github.com", "count": 1 } ], "countries": [ { "code": "CN", "count": 1 } ], "notFound": [ { "path": "string", "count": 1 } ], "agentFiles": [ { "path": "/llms.txt", "type": "index", "agents": 1, "humans": 1, "count": 1 } ], "topSearches": [ { "q": "自定义域名", "count": 1 } ] } ``` --- # AI 提问记录 `GET /sites/{site}/questions` 按时间倒序。条件可以组合;翻页时把上一页最后一条的 `ts` 作为 `before`。 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 | ## Query parameters | Name | Type | Required | Description | |---|---|---|---| | `days` | integer | no | 最近多少天,默认不限 | | `before` | integer | no | 只要早于这个时间(Unix 毫秒)的 | | `outcome` | string | no | 结果,多个用逗号分隔 | | `rating` | enum | no | 读者的评价;`none` 为没有评价的 Allowed: `up`, `down`, `none`. | | `sources` | enum | no | `none` 只返回没有引用任何来源的 Allowed: `none`. | | `page` | string | no | 提问时所在的页面 | | `limit` | integer | no | 返回条数,最大 500 | ## Example request ```bash curl https://api.butterix.com/v1/sites/acme-payments/questions \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 读者在 Ask AI 中的提问与回答 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `[].id` | integer | no | | | `[].ts` | integer | no | | | `[].question` | string | no | | | `[].answer` | string | no | | | `[].model` | string | no | | | `[].provider` | enum | no | Allowed: `anthropic`, `deepseek`, `openrouter`. | | `[].sources` | list of strings | no | | | `[].outcome` | enum | no | 有没有答上来:`answered` 已解决,`partial` 部分解决,`missing` 文档缺失,`declined` 与站点无关,`stray` 回答越出站点主题,`failed` 未完成 Allowed: `answered`, `partial`, `missing`, `declined`, `stray`, `failed`. | | `[].rating` | enum | no | 读者的评价 May be null. Allowed: `up`, `down`. | | `[].page` | string | no | 提问时所在的页面 May be null. | | `[].country` | string | no | 国家代码(按 IP 识别) May be null. | | `[].net` | string | no | 打码的网段(只保留 IP 前三段) May be null. | | `[].agent` | string | no | 浏览器与系统 May be null. | | `[].visitor` | string | no | 匿名访客编号(每天更换) May be null. | ### Example response (200) ```json [ { "id": 1, "ts": 1, "question": "怎样配置自定义域名?", "answer": "string", "model": "deepseek-flash", "provider": "anthropic", "sources": [ "/guides/deploy/custom-domains" ], "outcome": "answered", "rating": "up", "page": "/guides/deploy/platform", "country": "CN", "net": "203.0.113.*", "agent": "Chrome 158 · macOS", "visitor": "string" } ] ``` --- # 导出 AI 提问记录 `GET /sites/{site}/questions.csv` 条件与提问记录相同,最多导出 10000 条。 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 | ## Query parameters | Name | Type | Required | Description | |---|---|---|---| | `days` | integer | no | 最近多少天,默认不限 | | `before` | integer | no | 只要早于这个时间(Unix 毫秒)的 | | `outcome` | string | no | 结果,多个用逗号分隔 | | `rating` | enum | no | 读者的评价;`none` 为没有评价的 Allowed: `up`, `down`, `none`. | | `sources` | enum | no | `none` 只返回没有引用任何来源的 Allowed: `none`. | | `page` | string | no | 提问时所在的页面 | ## Example request ```bash curl https://api.butterix.com/v1/sites/acme-payments/questions.csv \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 CSV 文件 Content type: `text/csv` Type: string ### Example response (200) ```json "string" ``` --- # 页面核验 `GET /sites/{site}/page-reviews` 默认分支上每个页面的负责人、核验日期、复核日期与状态,可能过时与到期的在前。见[页面核验](https://docs.butterix.com/guides/features/page-review.md)。 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 | ## Query parameters | Name | Type | Required | Description | |---|---|---|---| | `today` | date | no | 判断是否到期用的日期(YYYY-MM-DD),默认是 UTC 的今天 | ## Example request ```bash curl https://api.butterix.com/v1/sites/acme-payments/page-reviews \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 页面列表 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `pages` | list of objects | no | 站点在平台上还没有内容时为 `null` May be null. | | `pages[].path` | string | no | | | `pages[].title` | string | no | | | `pages[].slug` | string | no | | | `pages[].owners` | list of strings | no | | | `pages[].verified` | date | no | | | `pages[].due` | date | no | 下次复核的日期 | | `pages[].outdated` | boolean | no | 被标为可能过时 | | `pages[].status` | enum | no | Allowed: `verified`, `due`, `outdated`, `none`. | ### Example response (200) ```json { "pages": [ { "path": "pages/quickstart.mdx", "title": "快速开始", "slug": "/guides/quickstart", "owners": [ "alice" ], "verified": "2026-11-01", "due": "2027-01-30", "outdated": false, "status": "verified" } ] } ``` --- # 解决率 `GET /sites/{site}/questions/summary` 各结果的数量、解决率与读者评价。与站点无关和未完成的提问不计入解决率。 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 | ## Query parameters | Name | Type | Required | Description | |---|---|---|---| | `days` | integer | no | | ## Example request ```bash curl https://api.butterix.com/v1/sites/acme-payments/questions/summary \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 汇总 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `days` | integer | no | | | `counts` | object | no | | | `counts.answered` | integer | no | | | `counts.partial` | integer | no | | | `counts.missing` | integer | no | | | `counts.declined` | integer | no | | | `counts.stray` | integer | no | | | `counts.failed` | integer | no | | | `resolutionRate` | number | no | 0–1;没有可计入的提问时为 `null` May be null. | | `rating` | object | no | | | `rating.up` | integer | no | | | `rating.down` | integer | no | | ### Example response (200) ```json { "days": 30, "counts": { "answered": 180, "partial": 20, "missing": 25, "declined": 12, "stray": 1, "failed": 3 }, "resolutionRate": 0.8, "rating": { "up": 42, "down": 5 } } ``` --- # 页面反馈 `GET /sites/{site}/feedback` 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 | ## Query parameters | Name | Type | Required | Description | |---|---|---|---| | `limit` | integer | no | | ## Example request ```bash curl https://api.butterix.com/v1/sites/acme-payments/feedback \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 读者的「这页有帮助吗?」、代码块问题与 AI 工具提交的反馈 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `[].id` | integer | no | | | `[].ts` | integer | no | | | `[].path` | string | no | | | `[].helpful` | boolean | no | | | `[].comment` | string | no | | | `[].source` | enum | no | `agent`:AI 工具经 MCP 或 Markdown 里的地址提交,内容由 AI 生成 Allowed: `reader`, `agent`. | | `[].code` | object | no | 针对的代码块(只有代码块问题有) | | `[].code.index` | integer | no | 页面上的第几个代码块,从 0 开始 | | `[].code.lang` | string | no | | | `[].code.line` | string | no | 第一行 | ### Example response (200) ```json [ { "id": 1, "ts": 1, "path": "/guides/get-started/quickstart", "helpful": true, "comment": "希望补充 Windows 下的安装说明", "source": "reader", "code": { "index": 1, "lang": "bash", "line": "npm install -g bitidocs" } } ] ``` --- # 列出定时任务 `GET /sites/{site}/automations` 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 | ## Example request ```bash curl https://api.butterix.com/v1/sites/acme-payments/automations \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 定时任务,按创建时间倒序 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `[].id` | string | no | | | `[].name` | string | no | | | `[].prompt` | string | no | | | `[].schedule` | object | no | | | `[].schedule.every` | enum | yes | Allowed: `day`, `week`. | | `[].schedule.weekday` | integer | no | 1(周一)到 7(周日),`every` 为 `week` 时必填 | | `[].schedule.hour` | integer | yes | | | `[].schedule.minute` | integer | no | | | `[].schedule.timezone` | string | no | IANA 时区 | | `[].canEdit` | boolean | no | 允许修改文档 | | `[].enabled` | boolean | no | | | `[].createdBy` | object | no | | | `[].createdBy.id` | string | no | | | `[].createdBy.name` | string | no | | | `[].createdAt` | integer | no | | | `[].nextAt` | integer | no | 下一次运行的时间 May be null. | | `[].lastRun` | union | no | 最近一次运行(不含报告);还没有运行过时为 `null` | | _Variant 1_ | variant | | | | `[].lastRun.id` | string | no | | | `[].lastRun.automationId` | string | no | | | `[].lastRun.cause` | enum | no | Allowed: `schedule`, `manual`. | | `[].lastRun.status` | enum | no | Allowed: `running`, `done`, `failed`. | | `[].lastRun.report` | string | no | 报告(Markdown) | | `[].lastRun.branch` | string | no | 有改动时的草稿分支 | | `[].lastRun.files` | list of strings | no | 修改的文件 | | `[].lastRun.error` | string | no | 失败原因 | | `[].lastRun.usage` | object | no | token 用量 | | `[].lastRun.usage.input` | integer | no | | | `[].lastRun.usage.output` | integer | no | | | `[].lastRun.startedAt` | integer | no | | | `[].lastRun.finishedAt` | integer | no | May be null. | ### Example response (200) ```json [ { "id": "auto_01jd8x2k7q", "name": "每周文档缺口", "prompt": "string", "schedule": { "every": "day", "weekday": 1, "hour": 0, "minute": 0, "timezone": "Asia/Shanghai" }, "canEdit": true, "enabled": true, "createdBy": { "id": "string", "name": "string" }, "createdAt": 1, "nextAt": 1, "lastRun": { "id": "run_01jd8x2k7q", "automationId": "string", "cause": "schedule", "status": "running", "report": "string", "branch": "automation/2k7q9x1a", "files": [ "string" ], "error": "string", "usage": { "input": 1, "output": 1 }, "startedAt": 1, "finishedAt": 1 } } ] ``` --- # 创建定时任务 `POST /sites/{site}/automations` 需要 `editor` 角色。每个站点最多 20 个。 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 | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `name` | string | yes | | | `prompt` | string | yes | 要做什么 | | `schedule` | object | yes | | | `schedule.every` | enum | yes | Allowed: `day`, `week`. | | `schedule.weekday` | integer | no | 1(周一)到 7(周日),`every` 为 `week` 时必填 | | `schedule.hour` | integer | yes | | | `schedule.minute` | integer | no | | | `schedule.timezone` | string | no | IANA 时区 | | `canEdit` | boolean | no | 允许修改文档;改动提交到新的草稿分支 | | `enabled` | boolean | no | | ## Example request ```bash curl -X POST https://api.butterix.com/v1/sites/acme-payments/automations \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "name": "每周文档缺口", "prompt": "查看最近 7 天没有答上来的提问,列出最值得补写的 5 处。", "schedule": { "every": "week", "weekday": 1, "hour": 9, "minute": 0, "timezone": "Asia/Shanghai" } }' ``` ## Responses ### 201 新的定时任务 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `id` | string | no | | | `name` | string | no | | | `prompt` | string | no | | | `schedule` | object | no | | | `schedule.every` | enum | yes | Allowed: `day`, `week`. | | `schedule.weekday` | integer | no | 1(周一)到 7(周日),`every` 为 `week` 时必填 | | `schedule.hour` | integer | yes | | | `schedule.minute` | integer | no | | | `schedule.timezone` | string | no | IANA 时区 | | `canEdit` | boolean | no | 允许修改文档 | | `enabled` | boolean | no | | | `createdBy` | object | no | | | `createdBy.id` | string | no | | | `createdBy.name` | string | no | | | `createdAt` | integer | no | | | `nextAt` | integer | no | 下一次运行的时间 May be null. | | `lastRun` | union | no | 最近一次运行(不含报告);还没有运行过时为 `null` | | _Variant 1_ | variant | | | | `lastRun.id` | string | no | | | `lastRun.automationId` | string | no | | | `lastRun.cause` | enum | no | Allowed: `schedule`, `manual`. | | `lastRun.status` | enum | no | Allowed: `running`, `done`, `failed`. | | `lastRun.report` | string | no | 报告(Markdown) | | `lastRun.branch` | string | no | 有改动时的草稿分支 | | `lastRun.files` | list of strings | no | 修改的文件 | | `lastRun.error` | string | no | 失败原因 | | `lastRun.usage` | object | no | token 用量 | | `lastRun.usage.input` | integer | no | | | `lastRun.usage.output` | integer | no | | | `lastRun.startedAt` | integer | no | | | `lastRun.finishedAt` | integer | no | May be null. | ### 400 请求参数无效 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (201) ```json { "id": "auto_01jd8x2k7q", "name": "每周文档缺口", "prompt": "string", "schedule": { "every": "day", "weekday": 1, "hour": 0, "minute": 0, "timezone": "Asia/Shanghai" }, "canEdit": true, "enabled": true, "createdBy": { "id": "string", "name": "string" }, "createdAt": 1, "nextAt": 1, "lastRun": { "id": "run_01jd8x2k7q", "automationId": "string", "cause": "schedule", "status": "running", "report": "string", "branch": "automation/2k7q9x1a", "files": [ "string" ], "error": "string", "usage": { "input": 1, "output": 1 }, "startedAt": 1, "finishedAt": 1 } } ``` --- # 获取定时任务 `GET /sites/{site}/automations/{id}` 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 | ## Example request ```bash curl https://api.butterix.com/v1/sites/acme-payments/automations/auto_01jd8x2k7q \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 定时任务 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `id` | string | no | | | `name` | string | no | | | `prompt` | string | no | | | `schedule` | object | no | | | `schedule.every` | enum | yes | Allowed: `day`, `week`. | | `schedule.weekday` | integer | no | 1(周一)到 7(周日),`every` 为 `week` 时必填 | | `schedule.hour` | integer | yes | | | `schedule.minute` | integer | no | | | `schedule.timezone` | string | no | IANA 时区 | | `canEdit` | boolean | no | 允许修改文档 | | `enabled` | boolean | no | | | `createdBy` | object | no | | | `createdBy.id` | string | no | | | `createdBy.name` | string | no | | | `createdAt` | integer | no | | | `nextAt` | integer | no | 下一次运行的时间 May be null. | | `lastRun` | union | no | 最近一次运行(不含报告);还没有运行过时为 `null` | | _Variant 1_ | variant | | | | `lastRun.id` | string | no | | | `lastRun.automationId` | string | no | | | `lastRun.cause` | enum | no | Allowed: `schedule`, `manual`. | | `lastRun.status` | enum | no | Allowed: `running`, `done`, `failed`. | | `lastRun.report` | string | no | 报告(Markdown) | | `lastRun.branch` | string | no | 有改动时的草稿分支 | | `lastRun.files` | list of strings | no | 修改的文件 | | `lastRun.error` | string | no | 失败原因 | | `lastRun.usage` | object | no | token 用量 | | `lastRun.usage.input` | integer | no | | | `lastRun.usage.output` | integer | no | | | `lastRun.startedAt` | integer | no | | | `lastRun.finishedAt` | integer | no | May be null. | ### 404 资源不存在,或你没有访问权限 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "id": "auto_01jd8x2k7q", "name": "每周文档缺口", "prompt": "string", "schedule": { "every": "day", "weekday": 1, "hour": 0, "minute": 0, "timezone": "Asia/Shanghai" }, "canEdit": true, "enabled": true, "createdBy": { "id": "string", "name": "string" }, "createdAt": 1, "nextAt": 1, "lastRun": { "id": "run_01jd8x2k7q", "automationId": "string", "cause": "schedule", "status": "running", "report": "string", "branch": "automation/2k7q9x1a", "files": [ "string" ], "error": "string", "usage": { "input": 1, "output": 1 }, "startedAt": 1, "finishedAt": 1 } } ``` --- # 更新定时任务 `PATCH /sites/{site}/automations/{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 | |---|---|---|---| | `name` | string | no | | | `prompt` | string | no | | | `schedule` | object | no | | | `schedule.every` | enum | yes | Allowed: `day`, `week`. | | `schedule.weekday` | integer | no | 1(周一)到 7(周日),`every` 为 `week` 时必填 | | `schedule.hour` | integer | yes | | | `schedule.minute` | integer | no | | | `schedule.timezone` | string | no | IANA 时区 | | `canEdit` | boolean | no | | | `enabled` | boolean | no | | ## Example request ```bash curl -X PATCH https://api.butterix.com/v1/sites/acme-payments/automations/auto_01jd8x2k7q \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{}' ``` ## Responses ### 200 更新后的定时任务 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `id` | string | no | | | `name` | string | no | | | `prompt` | string | no | | | `schedule` | object | no | | | `schedule.every` | enum | yes | Allowed: `day`, `week`. | | `schedule.weekday` | integer | no | 1(周一)到 7(周日),`every` 为 `week` 时必填 | | `schedule.hour` | integer | yes | | | `schedule.minute` | integer | no | | | `schedule.timezone` | string | no | IANA 时区 | | `canEdit` | boolean | no | 允许修改文档 | | `enabled` | boolean | no | | | `createdBy` | object | no | | | `createdBy.id` | string | no | | | `createdBy.name` | string | no | | | `createdAt` | integer | no | | | `nextAt` | integer | no | 下一次运行的时间 May be null. | | `lastRun` | union | no | 最近一次运行(不含报告);还没有运行过时为 `null` | | _Variant 1_ | variant | | | | `lastRun.id` | string | no | | | `lastRun.automationId` | string | no | | | `lastRun.cause` | enum | no | Allowed: `schedule`, `manual`. | | `lastRun.status` | enum | no | Allowed: `running`, `done`, `failed`. | | `lastRun.report` | string | no | 报告(Markdown) | | `lastRun.branch` | string | no | 有改动时的草稿分支 | | `lastRun.files` | list of strings | no | 修改的文件 | | `lastRun.error` | string | no | 失败原因 | | `lastRun.usage` | object | no | token 用量 | | `lastRun.usage.input` | integer | no | | | `lastRun.usage.output` | integer | no | | | `lastRun.startedAt` | integer | no | | | `lastRun.finishedAt` | integer | no | May be null. | ### 400 请求参数无效 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "id": "auto_01jd8x2k7q", "name": "每周文档缺口", "prompt": "string", "schedule": { "every": "day", "weekday": 1, "hour": 0, "minute": 0, "timezone": "Asia/Shanghai" }, "canEdit": true, "enabled": true, "createdBy": { "id": "string", "name": "string" }, "createdAt": 1, "nextAt": 1, "lastRun": { "id": "run_01jd8x2k7q", "automationId": "string", "cause": "schedule", "status": "running", "report": "string", "branch": "automation/2k7q9x1a", "files": [ "string" ], "error": "string", "usage": { "input": 1, "output": 1 }, "startedAt": 1, "finishedAt": 1 } } ``` --- # 删除定时任务 `DELETE /sites/{site}/automations/{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 | ## Example request ```bash curl -X DELETE https://api.butterix.com/v1/sites/acme-payments/automations/auto_01jd8x2k7q \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 成功 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `ok` | true | no | Allowed: `true`. | ### Example response (200) ```json { "ok": true } ``` --- # 立即运行 `POST /sites/{site}/automations/{id}/run` 需要 `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 | ## Example request ```bash curl -X POST https://api.butterix.com/v1/sites/acme-payments/automations/auto_01jd8x2k7q/run \ -H "Authorization: Bearer <token>" ``` ## Responses ### 202 已开始 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `id` | string | no | 运行 id | ### 409 正在运行 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### 429 启动过于频繁,或有其他任务正在运行 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (202) ```json { "id": "run_01jd8x2k7q" } ``` --- # 运行记录 `GET /sites/{site}/automations/{id}/runs` 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 | ## Example request ```bash curl https://api.butterix.com/v1/sites/acme-payments/automations/auto_01jd8x2k7q/runs \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 最近 30 天的运行,最多 100 条,按开始时间倒序 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `[].id` | string | no | | | `[].automationId` | string | no | | | `[].cause` | enum | no | Allowed: `schedule`, `manual`. | | `[].status` | enum | no | Allowed: `running`, `done`, `failed`. | | `[].report` | string | no | 报告(Markdown) | | `[].branch` | string | no | 有改动时的草稿分支 | | `[].files` | list of strings | no | 修改的文件 | | `[].error` | string | no | 失败原因 | | `[].usage` | object | no | token 用量 | | `[].usage.input` | integer | no | | | `[].usage.output` | integer | no | | | `[].startedAt` | integer | no | | | `[].finishedAt` | integer | no | May be null. | ### Example response (200) ```json [ { "id": "run_01jd8x2k7q", "automationId": "string", "cause": "schedule", "status": "running", "report": "string", "branch": "automation/2k7q9x1a", "files": [ "string" ], "error": "string", "usage": { "input": 1, "output": 1 }, "startedAt": 1, "finishedAt": 1 } ] ``` --- # 列出草稿分支 `GET /sites/{site}/editor/branches` 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 | ## Example request ```bash curl https://api.butterix.com/v1/sites/acme-payments/editor/branches \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 分支列表 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `[].name` | string | no | | | `[].isDefault` | boolean | no | | | `[].updatedAt` | integer | no | | | `[].author` | string | no | | | `[].ahead` | integer | no | 领先生产分支的提交数 | ### Example response (200) ```json [ { "name": "draft/3k9d2a1b-mf2x8k", "isDefault": true, "updatedAt": 1, "author": "林晓", "ahead": 1 } ] ``` --- # 新建草稿 `POST /sites/{site}/editor/branches` 从 `from`(默认生产分支)创建草稿分支 `draft/<用户 id 后 8 位>-<时间>`。 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 | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `from` | string | no | | ## Example request ```bash curl -X POST https://api.butterix.com/v1/sites/acme-payments/editor/branches \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{}' ``` ## Responses ### 201 新分支名 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `name` | string | no | | ### Example response (201) ```json { "name": "draft/3k9d2a1b-mf2x8k" } ``` --- # 丢弃草稿 `DELETE /sites/{site}/editor/branches/{name}` 不能删除生产分支。 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 | | `name` | string | yes | | ## Example request ```bash curl -X DELETE https://api.butterix.com/v1/sites/acme-payments/editor/branches/draft%2F3k9d2a1b-mf2x8k \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 成功 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `ok` | true | no | Allowed: `true`. | ### Example response (200) ```json { "ok": true } ``` --- # 文件树与导航 `GET /sites/{site}/editor/tree` 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 | ## Query parameters | Name | Type | Required | Description | |---|---|---|---| | `branch` | string | no | 分支名,默认生产分支 | ## Example request ```bash curl https://api.butterix.com/v1/sites/acme-payments/editor/tree \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 分支上的文件、解析后的导航(默认语言与版本)与 docs.yml 原文 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `branch` | string | no | | | `files` | list of objects | no | | | `files[].path` | string | no | | | `files[].size` | integer | no | | | `nav` | list of objects | no | | | `nav[].type` | enum | no | Allowed: `tab`, `section`, `page`, `link`, `api`. | | `nav[].title` | string | no | | | `nav[].slug` | string | no | | | `nav[].path` | string | no | 源文件 | | `nav[].children` | list of objects | no | | | `nav[].children[].type` | enum | no | Allowed: `tab`, `section`, `page`, `link`, `api`. | | `nav[].children[].title` | string | no | | | `nav[].children[].slug` | string | no | | | `nav[].children[].path` | string | no | 源文件 | | `nav[].children[].children` | object | no | | | `config` | string | no | 配置文件原文 | Some nested fields are left out. ### Example response (200) ```json { "branch": "string", "files": [ { "path": "pages/introduction.mdx", "size": 1834 } ], "nav": [ { "type": "tab", "title": "string", "slug": "string", "path": "string", "children": [ { "type": "tab", "title": "string", "slug": "string", "path": "string", "children": null } ] } ], "config": "string" } ``` --- # 读取文件 `GET /sites/{site}/editor/file` 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 | ## Query parameters | Name | Type | Required | Description | |---|---|---|---| | `branch` | string | no | 分支名,默认生产分支 | | `path` | string | yes | 项目内路径 | ## Example request ```bash curl https://api.butterix.com/v1/sites/acme-payments/editor/file?path=pages%2Fintroduction.mdx \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 文件内容 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `path` | string | no | | | `content` | string | no | | | `sha` | string | no | 用于乐观并发控制 | ### 404 资源不存在,或你没有访问权限 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "path": "string", "content": "string", "sha": "string" } ``` --- # 保存文件 `PUT /sites/{site}/editor/file` 把文件提交到草稿分支(一次保存 = 一次提交)。传入打开文件时的 `baseSha`,若文件已被他人修改,返回 409 与最新内容,便于合并。 已连接 Git 的站点不能直接写生产分支。 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 | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `branch` | string | yes | | | `path` | string | yes | | | `content` | string | yes | | | `message` | string | no | | | `baseSha` | string | no | | ## Example request ```bash curl -X PUT https://api.butterix.com/v1/sites/acme-payments/editor/file \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "branch": "draft/3k9d2a1b-mf2x8k", "path": "pages/quickstart.mdx", "content": "string" }' ``` ## Responses ### 200 新的 sha Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `sha` | string | no | | ### 409 文件已被修改 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | no | | | `current` | object | no | | | `current.content` | string | no | | | `current.sha` | string | no | | ### Example response (200) ```json { "sha": "string" } ``` --- # 删除文件 `DELETE /sites/{site}/editor/file` 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 | ## Query parameters | Name | Type | Required | Description | |---|---|---|---| | `branch` | string | no | 分支名,默认生产分支 | | `path` | string | yes | 项目内路径 | ## Example request ```bash curl -X DELETE https://api.butterix.com/v1/sites/acme-payments/editor/file?path=pages%2Fintroduction.mdx \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 成功 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `ok` | true | no | Allowed: `true`. | ### Example response (200) ```json { "ok": true } ``` --- # 移动或重命名文件 `POST /sites/{site}/editor/move` 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 | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `branch` | string | yes | | | `from` | string | yes | | | `to` | string | yes | | ## Example request ```bash curl -X POST https://api.butterix.com/v1/sites/acme-payments/editor/move \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "branch": "string", "from": "pages/old.mdx", "to": "pages/guides/new.mdx" }' ``` ## Responses ### 200 成功 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `ok` | true | no | Allowed: `true`. | ### Example response (200) ```json { "ok": true } ``` --- # 上传图片、媒体或字体 `POST /sites/{site}/editor/upload` 上传图片、视频、PDF 或字体(WOFF2、WOFF、TTF、OTF,最大 20 MB),保存到草稿分支的 `assets/` 下(字体在 `assets/fonts/`)并提交。返回可直接写进 Markdown 的地址。 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 | ## Query parameters | Name | Type | Required | Description | |---|---|---|---| | `branch` | string | yes | | ## Request body Content type: `multipart/form-data` | Field | Type | Required | Description | |---|---|---|---| | `file` | file | yes | | ## Example request ```bash curl -X POST https://api.butterix.com/v1/sites/acme-payments/editor/upload?branch=string \ -H "Authorization: Bearer <token>" \ -H "Content-Type: multipart/form-data" \ -d '{ "file": "<file>" }' ``` ## Responses ### 201 已保存 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `path` | string | no | | | `url` | string | no | | ### 413 超过 20 MB Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (201) ```json { "path": "assets/mf2x8k-diagram.png", "url": "/assets/mf2x8k-diagram.png" } ``` --- # 实时渲染 `POST /sites/{site}/editor/render` 用未保存的内容渲染完整页面 HTML(含样式,适合放进 iframe 的 `srcdoc`),同时返回诊断。预览以安全模式渲染,不加载站点自定义脚本。 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 | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `branch` | string | yes | | | `path` | string | yes | | | `content` | string | yes | 编辑器中当前(可能未保存)的内容 | ## Example request ```bash curl -X POST https://api.butterix.com/v1/sites/acme-payments/editor/render \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "branch": "string", "path": "pages/quickstart.mdx", "content": "string" }' ``` ## Responses ### 200 渲染结果 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `html` | string | no | | | `diagnostics` | list of objects | no | | | `diagnostics[].severity` | enum | no | Allowed: `error`, `warning`, `info`. | | `diagnostics[].code` | string | no | | | `diagnostics[].message` | string | no | | | `diagnostics[].file` | string | no | | | `diagnostics[].line` | integer | no | | | `diagnostics[].column` | integer | no | | | `diagnostics[].hint` | string | no | | ### Example response (200) ```json { "html": "string", "diagnostics": [ { "severity": "error", "code": "mdx/unknown-component", "message": "string", "file": "string", "line": 1, "column": 1, "hint": "string" } ] } ``` --- # 校验内容 `POST /sites/{site}/editor/check` 与实时渲染相同,但只返回诊断(等价于对单个文件运行 `biti check`)。 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 | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `branch` | string | yes | | | `path` | string | yes | | | `content` | string | yes | 编辑器中当前(可能未保存)的内容 | ## Example request ```bash curl -X POST https://api.butterix.com/v1/sites/acme-payments/editor/check \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "branch": "string", "path": "pages/quickstart.mdx", "content": "string" }' ``` ## Responses ### 200 诊断 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `diagnostics` | list of objects | no | | | `diagnostics[].severity` | enum | no | Allowed: `error`, `warning`, `info`. | | `diagnostics[].code` | string | no | | | `diagnostics[].message` | string | no | | | `diagnostics[].file` | string | no | | | `diagnostics[].line` | integer | no | | | `diagnostics[].column` | integer | no | | | `diagnostics[].hint` | string | no | | ### Example response (200) ```json { "diagnostics": [ { "severity": "error", "code": "mdx/unknown-component", "message": "string", "file": "string", "line": 1, "column": 1, "hint": "string" } ] } ``` --- # 预览草稿 `POST /sites/{site}/editor/preview` 为草稿分支创建预览部署,得到 `<site>--<短 id>` 形式的独立地址。 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 | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `branch` | string | no | | ## Example request ```bash curl -X POST https://api.butterix.com/v1/sites/acme-payments/editor/preview \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{}' ``` ## Responses ### 202 已排队的预览部署 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `id` | string | no | | | `siteId` | string | no | | | `kind` | enum | no | Allowed: `production`, `preview`. | | `status` | enum | no | Allowed: `queued`, `building`, `ready`, `failed`, `canceled`. | | `source` | string | no | `cli`(上传)、`hosted`(托管仓库)或 `git` | | `branch` | string | no | | | `commitSha` | string | no | | | `message` | string | no | | | `createdBy` | object | no | 触发者;用 API Key 触发时是创建密钥的人 | | `createdBy.id` | string | no | | | `createdBy.name` | string | no | | | `apiKey` | object | no | 用 API Key(CLI / CI)触发时,密钥的名称与首尾 | | `apiKey.name` | string | no | | | `apiKey.prefix` | string | no | 密钥前 10 个字符 | | `apiKey.suffix` | string | no | 密钥末尾 10 个字符 | | `error` | string | no | 失败原因 | | `pageCount` | integer | no | | | `sizeBytes` | integer | no | | | `durationMs` | integer | no | | | `url` | URL | no | 成功后才有。生产部署是站点地址,预览部署是 `<site>--<id 后 8 位>` 子域名 | | `isCurrent` | boolean | no | 是否为当前生产部署 | | `createdAt` | integer | no | | | `finishedAt` | integer | no | | ### Example response (202) ```json { "id": "dpl_01jd8x2k7q", "siteId": "site_2m4k8p", "kind": "production", "status": "queued", "source": "git", "branch": "main", "commitSha": "9fceb02d0ae598e95dc970b74767f19372d61af8", "message": "docs: 更新快速开始", "createdBy": { "id": "string", "name": "string" }, "apiKey": { "name": "GitHub Actions", "prefix": "biti_a1B2c", "suffix": "Kd82mQx0Zt" }, "error": "string", "pageCount": 94, "sizeBytes": 5832110, "durationMs": 6120, "url": "https://acme-payments--8x2k7q-sites.butterix.com", "isCurrent": true, "createdAt": 1, "finishedAt": 1 } ``` --- # 发布草稿 `POST /sites/{site}/editor/publish` 把草稿分支合并到生产分支(已连接 Git 时同时推送到远程),并触发生产部署。合并冲突时返回 409。 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 | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `branch` | string | yes | | | `message` | string | no | | ## Example request ```bash curl -X POST https://api.butterix.com/v1/sites/acme-payments/editor/publish \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "branch": "draft/3k9d2a1b-mf2x8k" }' ``` ## Responses ### 202 已触发生产部署 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `deploymentId` | string | no | | ### 409 冲突(名称已被占用、重复添加或合并冲突) Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (202) ```json { "deploymentId": "string" } ``` --- # AI 翻译整站 `POST /sites/{site}/editor/translate` Availability: beta 用站点的 Ask AI 配置把全部页面增量翻译到新分支 `translate/…`(包括导航标签、API 规范与翻译记忆),完成后可在编辑器中审阅再发布。 以后台任务运行,返回任务 id。 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 | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `to` | list of strings | no | 目标语言,默认是 docs.yml 中原文以外的全部语言 | | `from` | string | no | 基于哪个分支,默认生产分支 | ## Example request ```bash curl -X POST https://api.butterix.com/v1/sites/acme-payments/editor/translate \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{}' ``` ## Responses ### 202 任务已开始 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `id` | string | no | | ### 400 请求参数无效 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (202) ```json { "id": "job_4n7q2w" } ``` --- # 组件清单 `GET /components` 全部 MDX 组件及其属性,与 `biti components --json` 的输出相同。可视化编辑器用它生成属性面板。 Base URL: https://api.butterix.com/v1 Authentication: bearer token in Authorization header or API key in cookie `biti_session` ## Example request ```bash curl https://api.butterix.com/v1/components \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 组件清单 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `[].name` | string | no | | | `[].aliases` | list of strings | no | | | `[].category` | string | no | | | `[].description` | string | no | | | `[].children` | enum | no | Allowed: `none`, `inline`, `block`. | | `[].parent` | string | no | | | `[].props` | list of objects | no | | | `[].props[].name` | string | no | | | `[].props[].type` | string | no | | | `[].props[].required` | boolean | no | | | `[].props[].options` | list of strings | no | | | `[].props[].default` | any | no | | | `[].props[].description` | string | no | | ### Example response (200) ```json [ { "name": "Callout", "aliases": [ "Note", "Info", "Warning" ], "category": "callout", "description": "string", "children": "none", "parent": "string", "props": [ { "name": "string", "type": "string", "required": true, "options": [ "string" ], "default": "string", "description": "string" } ] } ] ``` --- # 查询任务 `GET /jobs/{id}` 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 | |---|---|---|---| | `id` | string | yes | | ## Example request ```bash curl https://api.butterix.com/v1/jobs/job_4n7q2w \ -H "Authorization: Bearer <token>" ``` ## Responses ### 200 任务状态与最近 200 行日志 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `id` | string | no | | | `kind` | string | no | | | `status` | enum | no | Allowed: `running`, `done`, `failed`. | | `log` | list of strings | no | | | `result` | object | no | | | `result.branch` | string | no | | | `result.stats` | map from strings to objects | no | | | `result.stats.<key>.pages` | integer | no | | | `result.stats.<key>.translated` | integer | no | | | `result.stats.<key>.reused` | integer | no | | | `error` | string | no | | ### 404 资源不存在,或你没有访问权限 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "id": "string", "kind": "translate", "status": "running", "log": [ "string" ], "result": { "branch": "translate/3k9d2a-mf2x8k", "stats": { "key": { "pages": 1, "translated": 1, "reused": 1 } } }, "error": "string" } ``` --- # Ask AI 对话(SSE) `POST /_biti/ai/chat` 检索站点文档并流式生成带引用编号的回答,响应是 `text/event-stream`,事件依次为: | 事件 | 数据 | |---|---| | `sources` | `[{ n, title, heading?, url }]` 引用来源 | | `text` | `{ t }` 一段增量文本(多次) | | `done` | `{ model, sig?, notice? }` | | `error` | `{ message, code? }` | `done.sig` 是服务端对这一轮问答的签名,追问时把它放在对应的 `assistant` 消息里回传;没有有效签名的那一轮问答不会作为上下文交给模型。 问题与文档明显无关时不生成回答,`text` 是一句固定说明,`done` 为 `{ model: null, notice: "offtopic" }`; 站点达到每日上限时只返回相关文档,`done` 为 `{ model: null, notice: "budget" }`。 托管平台上的调用要求: - 请求来自站点自身的页面(`Origin` 与站点一致,`Sec-Fetch-Site` 为 `same-origin`),否则返回 403; - 新版本构建的站点还需要在 `X-Biti-AI-Token` 头中携带 [会话令牌](https://docs.butterix.com/api-reference/runtime/ask-ai-token.md),缺失或过期时返回 401(`code: "ai_token"`),重新获取后重试即可。 限流:每个 IP(IPv6 按 /64)每分钟 12 次、每天 200 次;每个网段(IPv4 /24、IPv6 /48)每分钟 60 次、每天 1000 次;同一 IP 最多同时 2 个回答。 站点关闭 Ask AI 时返回 404,未配置密钥或月度配额用完时返回 503。因为要求同源,API 参考页面中的「试调」无法调用这个端点。 Base URL: https://butterix-sites.butterix.com ## Header parameters | Name | Type | Required | Description | |---|---|---|---| | `X-Biti-AI-Token` | string | no | 会话令牌(托管平台上新版本构建的站点必填) | ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `messages` | list of objects | yes | 对话历史,最后一条必须是 `user` | | `messages[].role` | enum | yes | Allowed: `user`, `assistant`. | | `messages[].content` | string | yes | `user` 消息最多 512 字符 | | `messages[].sig` | string | no | `assistant` 消息:该轮 `done` 事件返回的签名 | | `locale` | string | no | 回答语言,默认站点第一种语言 | ## Example request ```bash curl -X POST https://butterix-sites.butterix.com/_biti/ai/chat \ -H "Content-Type: application/json" \ -d '{ "messages": [ { "role": "user", "content": "如何给站点添加英文版?" } ], "locale": "zh" }' ``` ## Responses ### 200 事件流 Content type: `text/event-stream` (stream; each event has these fields) Type: string ### 400 最后一条不是问题,或问题超过 512 字符(`code: "too_long"`) Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### 401 缺少会话令牌或令牌已过期(`code: "ai_token"`) Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### 403 不是来自站点自身页面的请求(`code: "origin"`) Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### 413 请求体超过 256 KB(`code: "too_large"`) Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### 429 提问过于频繁(`code: "rate_limited"`)或同时进行的回答过多(`code: "busy"`) Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### 503 未配置 AI 提供商 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json "event: sources\ndata: [{\"n\":1,\"title\":\"多语言\",\"url\":\"/guides/features/i18n\"}]\n\nevent: text\ndata: {\"t\":\"在 docs.yml 的 languages 中加入 en [1],\"}\n\nevent: text\ndata: {\"t\":\"然后把译文放到 translations/en/ 下。\"}\n\nevent: done\ndata: {\"model\":\"claude-opus-5-5\",\"unanswered\":true}\n" ``` --- # Ask AI 会话令牌 `GET /_biti/ai/token` 领取调用 [Ask AI 对话](https://docs.butterix.com/api-reference/runtime/ask-ai.md) 所需的会话令牌,30 分钟有效,绑定站点、客户端网段与浏览器标识(换了网络或浏览器需要重新领取)。 跨站请求返回 403;每个 IP 每分钟最多 30 次。 Base URL: https://butterix-sites.butterix.com ## Example request ```bash curl https://butterix-sites.butterix.com/_biti/ai/token ``` ## Responses ### 200 会话令牌 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `token` | string | yes | | | `expiresAt` | integer | yes | 过期时间(毫秒时间戳) | ### 403 跨站请求 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### 429 请求过于频繁 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "token": "1795435200000.Zm9vYmFyYmF6cXV4cXV1eGNvcmdl", "expiresAt": 1 } ``` --- # MCP 服务器 `POST /_mcp/server` 站点 MCP 服务器(Streamable HTTP 传输,JSON 响应)。支持 `initialize`、`ping`、`tools/list`、`tools/call`,也接受批量消息。 工具:`search_docs`(检索)、`get_page`(获取页面 Markdown)、`list_pages`(列出页面)。多语言站点的 `search_docs` 与 `list_pages` 可以传 `locale`。`GET` 请求返回 405;站点关闭 MCP 时返回 404。 受密码保护的站点需要访问令牌或 OAuth 登录,未授权时返回 401。 Base URL: https://butterix-sites.butterix.com ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `jsonrpc` | "2.0" | yes | Allowed: `2.0`. | | `id` | string | no | | | `method` | enum | yes | Allowed: `initialize`, `ping`, `tools/list`, `tools/call`. | | `params` | object | no | | ## Example request ```bash curl -X POST https://butterix-sites.butterix.com/_mcp/server \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "search_docs", "arguments": { "query": "自定义域名", "limit": 3 } } }' ``` ## Responses ### 200 JSON-RPC 响应 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `jsonrpc` | string | no | | | `id` | string | no | | | `result` | object | no | | | `error` | object | no | | | `error.code` | integer | no | | | `error.message` | string | no | | ### 202 通知类消息,无响应体 ### Example response (200) ```json { "jsonrpc": "2.0", "id": 1, "result": { "content": [ { "type": "text", "text": "## 1. 自定义域名 › 配置 DNS\nURL: https://docs.butterix.com/guides/deploy/custom-domains\n\n添加 TXT 记录……" } ] } } ``` --- # API 试调代理 `POST /_biti/proxy` API 参考页的「试一试」通过它转发请求,避免浏览器跨域限制。为防止被滥用为开放代理: - 只允许站点 OpenAPI 规范中声明过的 `servers` 源站,其他地址返回 403; - 托管平台上拒绝解析到内网、回环地址的主机; - 剥离 `Cookie`、`Host` 等头,不跟随重定向,响应体最多 2 MB,30 秒超时; - 每个 IP 每分钟最多 60 次。 Base URL: https://butterix-sites.butterix.com ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `url` | string | yes | | | `method` | string | yes | | | `headers` | map from strings to strings | no | | | `body` | string | no | | ## Example request ```bash curl -X POST https://butterix-sites.butterix.com/_biti/proxy \ -H "Content-Type: application/json" \ -d '{ "url": "https://api.butterix.com/v1/whoami", "method": "GET" }' ``` ## Responses ### 200 目标服务的响应(无论其状态码如何) Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `status` | integer | no | | | `statusText` | string | no | | | `headers` | map from strings to strings | no | | | `body` | string | no | | | `truncated` | boolean | no | | | `size` | integer | no | | | `timeMs` | integer | no | | ### 403 目标主机未在规范中声明,或解析到内网地址 Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `error` | string | yes | 人类可读的错误信息 | | `code` | string | no | 机器可读的错误码(部分接口提供) | ### Example response (200) ```json { "status": 200, "statusText": "OK", "headers": { "key": "string" }, "body": "string", "truncated": true, "size": 1, "timeMs": 84 } ``` --- # 提交页面反馈 `POST /_biti/feedback` 页面底部「这页有帮助吗?」使用的端点。评论最多 2000 字符。 Base URL: https://butterix-sites.butterix.com ## Request body Content type: `application/json` | Field | Type | Required | Description | |---|---|---|---| | `path` | string | yes | | | `helpful` | boolean | yes | | | `comment` | string | no | | ## Example request ```bash curl -X POST https://butterix-sites.butterix.com/_biti/feedback \ -H "Content-Type: application/json" \ -d '{ "path": "/guides/get-started/quickstart", "helpful": true }' ``` ## Responses ### 204 已记录 --- # 更新日志 ButterIX 的新功能、改进与修复按日期列在下面。可以按标签筛选、搜索,也可以通过 [RSS](https://docs.butterix.com/changelog.rss)、[Atom](https://docs.butterix.com/changelog.atom) 或 [JSON Feed](https://docs.butterix.com/changelog.json) 订阅。 > Showing the latest 20 of 29 entries. > Index of every entry: https://docs.butterix.com/changelog/llms.txt > Feeds: https://docs.butterix.com/changelog.rss (RSS), https://docs.butterix.com/changelog.atom (Atom), https://docs.butterix.com/changelog.json (JSON Feed) ## [导航图标可以放进图标框](https://docs.butterix.com/changelog/2026/12/02.md#2026-12-02-导航图标可以放进图标框) _2026年12月2日 · Tags: 导航_ 导航条目写 `icon-style: tile`,图标就放进一个带细边的小方块,悬停或当前页时方块填上强调色、图标变白,适合把几个重要入口和普通页面区分开: ```yaml - page: 快速开始 path: pages/quickstart.mdx icon: lucide:rocket icon-style: tile ``` 分区、页面、链接、文件夹、更新日志、API 分区与放在侧栏的标签页都可以写,页面也可以写在 frontmatter 里。[侧栏链接](https://docs.butterix.com/guides/configuration/docs-yml.md#侧栏链接)默认就是这种样式,尺寸、描边与深色下的效果也一并调整;写 `icon-style: plain` 可以改成普通链接。 详见[图标样式](https://docs.butterix.com/guides/configuration/navigation.md#图标样式)。 ## [页面地址加 .mdx 返回源文件](https://docs.butterix.com/changelog/2026/11/30.md#2026-11-30-页面地址加-mdx-返回源文件) _2026年11月30日 · Tags: AI_ 在任意页面地址后加 `.mdx`,返回这一页的源文件,和作者写的一样,组件保持 MDX 原样,AI 工具可以照着学写法: ```bash curl https://docs.butterix.com/components/live-photo.mdx ``` `.md` 后缀跳转到 `.mdx`。接口页、更新日志这类自动生成的页面没有源文件,两个地址都返回干净的 Markdown;要拿到写成的页面的干净 Markdown,请求时带上 `Accept: text/markdown`。 详见[每页的 Markdown](https://docs.butterix.com/guides/features/agents.md#每页的-markdown)。 ## [新组件:实况照片与图片对比](https://docs.butterix.com/changelog/2026/11/30.md#2026-11-30-新组件-实况照片与图片对比) _2026年11月30日 · Tags: 内容_ - **实况照片**:`<LivePhoto>` 给照片配一段短视频,左上角显示实况徽标;按住照片播放、松手停止,点徽标完整播放一遍,与 iPhone 的实况照片一样。 - **图片对比**:`<ImageCompare>` 把两张图叠在一起,左右拖动中间的拉杆对比,适合展示处理前后、改版前后的差异。 ```mdx <LivePhoto src="/assets/live.jpg" video="/assets/live.mp4" /> <ImageCompare before="/assets/before.jpg" after="/assets/after.jpg" beforeLabel="之前" afterLabel="之后" /> ``` 详见[实况照片](https://docs.butterix.com/components/live-photo.md)与[图片对比](https://docs.butterix.com/components/image-compare.md)。 ## [Ask AI:回答里可以直接显示图片](https://docs.butterix.com/changelog/2026/11/29.md#2026-11-29-ask-ai-回答里可以直接显示图片) _2026年11月29日 · Tags: AI_ 给图片加上 `askAi`,Ask AI 就可以在回答里直接显示它,例如客服群二维码或架构图: ```mdx <img src="/assets/support-qr.png" alt="用户群二维码" width="240" askAi /> ``` Markdown 写法的图片把它写在标题的位置:`![用户群二维码](/assets/support-qr.png 'askAi')`。 没有这个标记的图片不会显示;网页嵌入的助手同样生效。在可视化编辑器里点图片即可勾选。 详见[在回答里显示图片](https://docs.butterix.com/guides/features/ask-ai.md#在回答里显示图片)。 ## [页面核验、迁移工具与转人工](https://docs.butterix.com/changelog/2026/11/26.md#2026-11-26-页面核验-迁移工具与转人工) _2026年11月26日 · Tags: 内容, CLI, AI_ - **页面核验**:为页面写明负责人、核验日期与复核周期;控制台列出待复核的页面,编辑器里一键「今天已核验」,也可以在页面底部给读者看。 - **迁移工具**:`biti migrate` 输出给编程 Agent 的迁移步骤,并对照新旧项目的页面、正文、代码、图片、地址、重定向与接口,列出没带过来的内容。 - **答不上时转人工**:在站点设置里开启并填写联系方式,Ask AI 没有答案、出错或被点踩时,读者可以联系你;邮件由读者自己确认发送。 - **图框里的内容直接编辑**:编辑器里可以直接选中、替换、删除 Frame 中的图片、视频与组件,说明文字也能原地修改;只有一张图的提示框、更新条目同样可以。图框里放多张图时并排显示,不再被裁掉。 - `biti check --review` 列出待复核的页面;控制台 Agent 与定时任务可以查看页面核验。 详见[页面核验](https://docs.butterix.com/guides/features/page-review.md)、[迁移工具](https://docs.butterix.com/guides/reference/migrate.md)与 [Ask AI](https://docs.butterix.com/guides/features/ask-ai.md#答不上时转人工)。 ## [代码块与 AI 工具的反馈、404 推荐重定向、页面事件](https://docs.butterix.com/changelog/2026/11/26.md#2026-11-26-代码块与-ai-工具的反馈-404-推荐重定向-页面事件) _2026年11月26日 · Tags: AI, 内容_ - **代码块反馈**:正文里的代码块旁多了一面旗子,读者可以报告「跑不通」「写错了」或「过时了」,控制台记下是哪一块。 - **AI 工具的反馈**:AI 工具读文档时发现错误,可以经站点 MCP 的 `send_feedback`,或每页 Markdown 开头写明的地址提交,在控制台与读者的反馈分开显示。 - **404 推荐重定向**:「内容检查 → 404 重定向」列出读者访问过的不存在地址与最像的页面,一键加上、立即生效;整段搬家合并成一条通配规则,原地址有了页面就不再跳转。 - **页面事件**:自定义脚本可以监听 `bd:page`、`bd:search`、`bd:ask`、`bd:theme`,在每次换页、打开搜索时做事。 - **llms.txt**:列出接口规范的下载地址;`noindex` 的页面不再收录;支持 `?excludeSpec=true`、`?excludeChangelog=true`。接口页 Markdown 的请求示例带上请求头与认证,Webhook 给出示例负载。 - CLI 默认就连 ButterIX 托管平台,文档里的 `--api` 只在自托管时需要。 详见[分析 › 反馈](https://docs.butterix.com/guides/features/analytics.md#反馈)、[页面事件](https://docs.butterix.com/guides/configuration/docs-yml.md#页面事件)与 [llms.txt](https://docs.butterix.com/guides/features/agents.md#只取需要的部分)。 ## [导出 PDF 与 Markdown](https://docs.butterix.com/changelog/2026/11/26.md#2026-11-26-导出-pdf-与-markdown) _2026年11月26日 · Tags: 内容, CLI_ - **打印一页**:「更多操作」里新增「打印 / 存为 PDF」,折叠与切换的内容全部展开,代码不截断,深色页面按浅色打印。 - **导出栏目与整站**:在控制台的站点概览里选范围,导出带封面、目录的 PDF,或带图片、可以离线打开的 Markdown 压缩包。 - **`biti export`**:从命令行导出 Markdown 或 PDF。 - **搜索框放进标签栏**:`layout.searchbar-placement: header-tabs` 现在把搜索框放在页头标签栏的右端。 - 编辑器设置里,侧栏链接移到了「导航」;很长的导航默认只露出开头,可以展开全部。 - **地址用主域名**:控制台给出的嵌入代码、MCP 地址与打印页改用主域名;已有的嵌入代码照常可用。域名页把主域名排在最前,已验证的域名默认收起 DNS 记录。 - 受密码保护的站点,输完密码会回到原来要看的页面。 详见[导出与打印](https://docs.butterix.com/guides/features/export.md)。 ## [文档考卷,AsyncAPI 给出提示](https://docs.butterix.com/changelog/2026/11/26.md#2026-11-26-文档考卷-asyncapi-给出提示) _2026年11月26日 · Tags: AI, CLI_ - **文档考卷**:把读者会问的问题和正确答案的要点写进 `evals.yml`,`biti eval` 用你自己的模型密钥,让 AI 只看文档作答并逐条评分。可以在 CI 里设及格线,用 `--site` 上传后在控制台查看历次成绩。 - **从读者提问出题**:`biti eval --import` 把问得最多的问题加成草稿;控制台的对话里可以「复制为考题」。 - **规范检查**:引用了 AsyncAPI、OpenRPC 等还不支持的规范时,`biti check`、部署日志与编辑器会给出 `api/unsupported` 警告,不再悄悄留下空的一节。 - 接口调试面板弹出与收起走同一条轨迹,滑动更流畅。 详见[文档考卷](https://docs.butterix.com/guides/features/evals.md)。 ## [定时任务、组织 MCP 与受保护站点的访问令牌](https://docs.butterix.com/changelog/2026/11/25.md#2026-11-25-定时任务-组织-mcp-与受保护站点的访问令牌) _2026年11月25日 · Tags: AI, 平台_ - **定时任务**:每天或每周让 AI 检查文档与读者反馈并写出报告;允许改文档时,改动放进草稿分支等你审阅。 - **组织 MCP 服务器**:把 `https://api.butterix.com/v1/mcp` 接入编码助手,查询站点、部署、分析、提问与反馈,全部只读。 - **访问令牌**:AI 工具与脚本用令牌读取受密码保护的站点;支持 OAuth 的 MCP 客户端可以直接登录。 - 以上功能与指定问答、内容来源、嵌入、提问记录的筛选与导出都有对应的 API。 详见[定时任务](https://docs.butterix.com/guides/features/automations.md)、[托管平台](https://docs.butterix.com/guides/deploy/platform.md#组织-mcp-服务器)与[访问控制](https://docs.butterix.com/guides/deploy/access-control.md#ai-工具与程序的访问)。 ## [图表缩放与平移,侧栏常驻链接](https://docs.butterix.com/changelog/2026/11/25.md#2026-11-25-图表缩放与平移-侧栏常驻链接) _2026年11月25日 · Tags: 内容, 外观_ - **图表控制**:Mermaid 图表在页面里就能缩放、平移、复位,或打开全屏窗口;`controls` 与 `placement` 参数调整单个图表。 - **侧栏链接**:`sidebar-links` 在侧栏顶部显示社区、博客、路线图等入口,每个标签页都在;可以设图标与颜色,也可以在控制台里编辑。 - 从 Mintlify 导入时,全局锚点会转成侧栏链接。 详见[缩放与平移](https://docs.butterix.com/guides/writing/math-and-diagrams.md#缩放与平移)与[侧栏链接](https://docs.butterix.com/guides/configuration/docs-yml.md#侧栏链接)。 ## [控制台 Agent 与文档缺口](https://docs.butterix.com/changelog/2026/11/25.md#2026-11-25-控制台-agent-与文档缺口) _2026年11月25日 · Tags: AI, 控制台_ - **控制台 Agent**:在控制台里查流量、提问与反馈,写文档、改导航;改动进草稿分支,由你审阅后发布。 - **需要确认的改动**:外部地址、脚本、站点设置与删除页面,先列出来等你确认。 - **建议**:指定问答与定时任务,确认后才执行。 - **文档缺口**:没答上来的提问、没有结果的搜索、差评与 404 按主题归并,一键起草修改。 - **对话记录**:按站点保存,编辑器与控制台都能接着用。 - **独立开关**:控制台 AI 与读者的 Ask AI 分开开关;读者的 Ask AI 没有任何管理能力。 详见[控制台 Agent](https://docs.butterix.com/guides/features/console-agent.md)。 ## [Ask AI:指定问答、内容来源与网页嵌入](https://docs.butterix.com/changelog/2026/11/25.md#2026-11-25-ask-ai-指定问答-内容来源与网页嵌入) _2026年11月25日 · Tags: AI_ - **指定问答**:为某类问题写好答案,AI 优先按它回答。 - **内容来源**:上传 Markdown 或抓取公开网站,让 AI 同时参考文档以外的内容。 - **网页嵌入**:一行脚本,把助手放进你的官网或产品。 - **隐藏个人信息**:`ai.mask-pii` 在发送前隐藏邮箱、电话、证件号、银行卡号与密钥,并请读者确认。 - **提问记录**:读者可以赞或踩;按结果、评价与有无来源筛选,查看解决率,导出 CSV。 - **链接直达**:`?ask-ai=问题` 预先写好问题,`?search=关键词` 打开搜索。 - 面板的提示文字可以自定义(`ai.disclaimer`)。 详见 [Ask AI](https://docs.butterix.com/guides/features/ask-ai.md)与[网页嵌入](https://docs.butterix.com/guides/features/ask-ai-embed.md)。 ## [API 规范直接可用,接口的 Markdown 更完整](https://docs.butterix.com/changelog/2026/11/25.md#2026-11-25-api-规范直接可用-接口的-markdown-更完整) _2026年11月25日 · Tags: API, Agent_ - **规范地址**:`/openapi.json`、`/openapi.yaml` 与 `/openapi/<api-name>.json`;多个 API 时根地址是清单,隐藏的接口不在其中。 - **API 目录**:`/.well-known/api-catalog` 列出每个 API 的规范与参考页。 - **接口页的 Markdown** 列出每个状态码的响应字段,接口片段组件输出真实的代码与字段表。 详见[下载规范](https://docs.butterix.com/guides/api/openapi.md#下载规范)。 ## [Agent 更容易读懂文档,也能用上你的 skills](https://docs.butterix.com/changelog/2026/11/25.md#2026-11-25-agent-更容易读懂文档-也能用上你的-skills) _2026年11月25日 · Tags: AI, Agent_ - **一键连接**:页面的「更多」菜单可以连接 Claude Code、Cursor、VS Code 或复制 MCP 地址;在 ChatGPT、Claude 中打开时带上完整地址。 - **托管 skills**:放进 `.well-known/agent-skills/` 的 skill 随站点发布,读者用 `npx skills add` 加你的域名安装。 - **编写技能包**:`biti init --skill`,让编码 Agent 按规范编写 ButterIX 文档。 - **页面指令**:每个 `.md` 开头告诉 Agent 索引与 MCP 在哪里,多版本站点还会注明本页的版本;可以自定义或关闭。 - **Markdown 地址**:`.mdx` 与 `.md` 等效,重定向保留后缀与查询参数,缺页返回 Markdown 404 与相近页面。 - **站点 MCP**:多语言站点可以指定语言,默认按问题的语言;`agents.mcp: false` 关闭。 - **robots.txt**:可以用 `Content-Signal` 声明内容用途,或换成自己的文件。 - 分析单独统计索引与规范文件的请求。 详见 [Agent 友好](https://docs.butterix.com/guides/features/agents.md)与 [SEO](https://docs.butterix.com/guides/features/seo.md#robotstxt-与-ai-爬虫)。 ## [API 参考与更新日志也能翻译](https://docs.butterix.com/changelog/2026/11/24.md#2026-11-24-api-参考与更新日志也能翻译) _2026年11月24日 · Tags: 多语言_ - **API 参考**:译文规范放在 `translations/<lang>/` 的同一路径,可以只写一部分;结构与地址不变。 - **更新日志与博客**:条目与标签都可以有译文,订阅源按语言输出。 - **默认语言与原文语言可以不同**:默认语言决定地址与首页,文件仍按原文语言组织。 - **缺译文时依次回退**到默认语言和原文;以 `/` 开头的链接留在读者当前的语言与版本。 - 外部链接、logo、通知条、页脚等可以按语言替换;AI 翻译覆盖全部站点文字。 - 编辑器里可以管理语言与版本:添加、排序、改名、设为默认。 详见[多语言](https://docs.butterix.com/guides/features/i18n.md)与[多版本](https://docs.butterix.com/guides/features/versions.md)。 ## [编辑器:图标选择、块间插入与图片注释](https://docs.butterix.com/changelog/2026/11/24.md#2026-11-24-编辑器-图标选择-块间插入与图片注释) _2026年11月24日 · Tags: 编辑器, 内容_ - **图标选择器**:4200 多个 Lucide 与 Font Awesome 图标,按英文或常用中文词搜索、按来源筛选,也可以粘贴图片地址或 SVG。 - **在块之间插入**:按住 `⌘`(Windows 为 `Ctrl`)移动鼠标,可插入的位置出现横线,单击插入——块之间、列表项之间、单元格里、表格的行之间都可以;点两个块之间的空隙也能直接输入。 - **图片注释**:`<img caption="…" />` 在图片下方显示一行居中的灰色小字,表格里也能用。 - **合并单元格**写成 `|>>|` 与 `|^^|`,用反斜杠可以显示这些符号本身。 - **拖动表格的行与列**:按住列的 “…” 或行的 “⋮” 拖动,落点有提示线。 - **上传字体**:正文、标题与代码可以各用一种字体文件。 - **图片更安全**:紧挨图片按退格先选中,再按一次才删除。 - 步骤组件换了新样式;超宽表格两侧的阴影更干净,固定的表头与首列不再透出后面的内容;容器里相邻的组件有了间距。 详见[可视化编辑器](https://docs.butterix.com/guides/deploy/editor.md#在块之间插入)、[图标](https://docs.butterix.com/components/icon.md#可用的图标)、[图片与媒体](https://docs.butterix.com/guides/writing/media.md#注释)与[合并单元格](https://docs.butterix.com/guides/writing/markdown.md#合并单元格)。 ## [更快的构建,更省心的命令行](https://docs.butterix.com/changelog/2026/11/24.md#2026-11-24-更快的构建-更省心的命令行) _2026年11月24日 · Tags: CLI, 平台_ - **增量构建**:只重新渲染变化的页面,结果与从头构建逐字节相同。 - **对 CDN 友好**:资源按内容命名,没变的资源不会重新上传;启用 CDN 的站点缓存页面。 - **合并线上改动**:`biti deploy` 会把编辑器里发布的改动按行合并到本地再部署,冲突时标出文件、发布人与时间。 - **API 主机**:脚本与 CI 可以使用 `https://api.butterix.com`。 - API Key 显示开头与末尾,部署列表显示是哪个 Key 触发的。 详见[CLI 部署与 API Key](https://docs.butterix.com/guides/deploy/cli-deploy.md)与[CLI 参考](https://docs.butterix.com/guides/reference/cli.md)。 ## [Ask AI:推理强度、链接直达与防滥用](https://docs.butterix.com/changelog/2026/11/24.md#2026-11-24-ask-ai-推理强度-链接直达与防滥用) _2026年11月24日 · Tags: AI_ - **推理强度**按所选模型显示可用档位,Anthropic、DeepSeek 与 OpenRouter 都已接入。 - **链接直达**:任意页面地址后加 `?ask-ai`,打开时就展开提问面板。 - **防滥用**:主题门槛、多维限流、来源校验、会话令牌、历史签名与站点每日上限,平台的回答不会被当成免费的通用 AI 来刷。 - 保存时向提供商验证密钥;没有可用的 AI 时,站点上的入口自动隐藏。 详见 [Ask AI](https://docs.butterix.com/guides/features/ask-ai.md)。 ## [接口页:点字就改,示例更多](https://docs.butterix.com/changelog/2026/11/24.md#2026-11-24-接口页-点字就改-示例更多) _2026年11月24日 · Tags: API_ - 在编辑器里直接点接口页上的文字修改,内容写回规范文件;预览其他语言时写进译文。 - 全站或单个接口的显示都可以调整:布局、示例栏与内容宽度、试一试、示例与错误说明。 - 调试台与接口页共用 9 种语言的请求示例,语言偏好全站同步,参数按各语言正确转义。 - 参数说明改为悬停气泡,响应状态用下拉切换。 详见[导入 OpenAPI](https://docs.butterix.com/guides/api/openapi.md)与[在线调试与代理](https://docs.butterix.com/guides/api/try-it.md)。 ## [实时访客,更准的浏览量](https://docs.butterix.com/changelog/2026/11/23.md#2026-11-23-实时访客-更准的浏览量) _2026年11月23日 · Tags: 分析_ - **实时访客**:最近 30 分钟的逐条请求,每 10 秒刷新,显示国旗与国家、打码网段、浏览器与系统、来源,并标明是否计为一次浏览。 - **浏览量**:真人浏览在页面脚本回报之后才计数,无头浏览器与扫描器归为爬虫,控制台访问与 404 页不计入。 - **国家 / 地区**:按访客 IP 识别,国家库自动更新。 详见[分析](https://docs.butterix.com/guides/features/analytics.md#实时访客)。 --- # ButterIX 文档(v0) > ButterIX v0(旧版)文档简介。v0 已不再维护,请阅读 v1 文档。 > **你正在阅读旧版文档** > > v0 已不再维护。请通过页头的版本选择器切换到 **v1**,或直接阅读 [v1 的简介](https://docs.butterix.com/guides/get-started/introduction.md)。 v0 是 ButterIX 的早期预览版,提供了最核心的能力:用 `docs.yml` 描述导航,用 MDX 写页面,用 `biti dev` 预览。 ## v0 包含什么 - `docs.yml` 配置与导航(分区、页面、链接) - MDX 页面与常用组件(提示框、卡片、代码块) - `biti dev` 预览与 `biti deploy` 发布 多版本、多语言、Ask AI 与 MCP 服务器都在 v1 中提供。 ## 这个页面演示了什么 ### 版本前缀 本页地址以 `/v0` 开头:非默认版本使用 `/<slug>` 前缀,默认版本(v1)没有前缀。 ### 同页跳转 在版本选择器中切换到 v1,会直接打开 v1 中**同名的**「简介」页面,因为两者的标签页、分区标题与页面标题相同。 ### canonical 查看页面源码,`<link rel="canonical" />` 指向 v1 的同一页面,搜索引擎因此只收录当前版本。 详见 [v1 › 多版本](https://docs.butterix.com/guides/features/versions.md)。 --- # 快速开始(v0) > ButterIX v0(旧版)快速开始。请优先阅读 v1 的快速开始。 > **Warning** > > 旧版文档。当前版本的步骤见 [v1 › 快速开始](https://docs.butterix.com/guides/get-started/quickstart.md)。 ### 安装 ```bash npm install -g bitidocs ``` ### 初始化 ```bash biti init my-docs ``` ### 预览与发布 ```bash cd my-docs biti login biti dev biti deploy ``` `biti dev` 在本机预览,`biti deploy` 发布到托管平台。 --- # docs.yml 参考(v0) > ButterIX v0(旧版)的 docs.yml 字段。完整的字段说明见 v1。 > **Warning** > > 旧版文档。完整、最新的字段说明见 [v1 › docs.yml 参考](https://docs.butterix.com/guides/configuration/docs-yml.md)。 v0 中常用的字段: ```yaml title="docs.yml" title: Acme 文档 logo: light: assets/logo.svg colors: accent-primary: "#7C5CFF" navigation: - section: 开始 slug: start contents: - page: 简介 path: pages/introduction.mdx slug: introduction - link: 官网 href: https://example.com ``` - `title` (string): 站点名称。 - `logo` (object): 页头 logo(`light`、`dark`、`height`)。 - `colors.accent-primary` (color): 强调色。 - `navigation` (NavItem[]): 侧栏导航:`section`、`page`、`link`。 这些字段在 v1 中保持兼容,v1 在此基础上增加了标签页、版本、产品、语言、重定向、SEO、AI 等配置。