revision-external-api
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRevision External API
Revision External API
REST API for managing architecture documentation in Revision workspaces.
用于管理Revision工作区中架构文档的REST API。
Prerequisites
前提条件
Before making any API calls, the user must provide two things:
- Organization URL: Each organization has its own subdomain, e.g. . This is the base URL for all API requests. Always ask the user for their organization URL — there is no default.
https://acme-company.revision.app/ - API key: A Bearer token from the workspace settings.
在发出任何API调用之前,用户必须提供两项信息:
- 组织URL:每个组织都有自己的子域名,例如 。这是所有API请求的基础URL。务必向用户索要他们的组织URL——没有默认值。
https://acme-company.revision.app/ - API密钥:来自工作区设置的Bearer令牌。
Authentication
身份验证
All requests require a Bearer token (API key from workspace settings):
Authorization: Bearer <api-key>所有请求都需要Bearer令牌(来自工作区设置的API密钥):
Authorization: Bearer <api-key>Base URL
基础URL
The base URL is the organization's own Revision URL. Every organization has a unique subdomain:
https://{organization}.revision.appFor example:
https://acme-company.revision.appImportant: Do not use a generic URL. Always use the organization-specific subdomain provided by the user.
基础URL是组织专属的Revision URL。每个组织都有唯一的子域名:
https://{organization}.revision.app例如:
https://acme-company.revision.app重要提示:不要使用通用URL。务必使用用户提供的组织专属子域名。
Resources
资源
| Resource | Endpoints | Description |
|---|---|---|
| Components | CRUD + batch upsert + filter | Architecture components (services, databases, etc.) |
| Diagrams | CRUD + batch upsert + filter | Architecture diagrams with component instances, relations, textareas |
| Attributes | CRUD + batch upsert | Custom attribute definitions on components |
| Tags | CRUD + batch upsert | Tags for categorizing diagrams |
| Types | Read-only | Component type definitions |
| Template | POST | Bulk sync of components + diagrams in a single transaction |
| 资源 | 端点 | 描述 |
|---|---|---|
| 组件 | CRUD + 批量插入更新 + 过滤 | 架构组件(服务、数据库等) |
| 图表 | CRUD + 批量插入更新 + 过滤 | 包含组件实例、关系、文本区域的架构图表 |
| 属性 | CRUD + 批量插入更新 | 组件上的自定义属性定义 |
| 标签 | CRUD + 批量插入更新 | 用于分类图表的标签 |
| 类型 | 只读 | 组件类型定义 |
| 模板 | POST | 在单个事务中批量同步组件和图表 |
Quick Start
快速开始
List components
列出组件
bash
curl -H "Authorization: Bearer $API_KEY" \
https://acme-company.revision.app/api/external/componentsbash
curl -H "Authorization: Bearer $API_KEY" \
https://acme-company.revision.app/api/external/componentsCreate a component
创建组件
bash
curl -X POST -H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "User Service", "state": "ACTIVE"}' \
https://acme-company.revision.app/api/external/componentsbash
curl -X POST -H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "User Service", "state": "ACTIVE"}' \
https://acme-company.revision.app/api/external/componentsCreate a component with a predictable ID
创建带可预测ID的组件
bash
curl -X POST -H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"id": "user-service", "name": "User Service", "state": "ACTIVE"}' \
https://acme-company.revision.app/api/external/componentsbash
curl -X POST -H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"id": "user-service", "name": "User Service", "state": "ACTIVE"}' \
https://acme-company.revision.app/api/external/componentsUpdate a component
更新组件
bash
curl -X PATCH -H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "User Service", "state": "ACTIVE", "desc": "Handles user auth"}' \
https://acme-company.revision.app/api/external/components/component-idbash
curl -X PATCH -H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "User Service", "state": "ACTIVE", "desc": "Handles user auth"}' \
https://acme-company.revision.app/api/external/components/component-idStandard CRUD Pattern
标准CRUD模式
Every resource (components, diagrams, attributes, tags) follows the same pattern:
| Method | Path | Action |
|---|---|---|
| GET | | List all (with optional query filters on components, diagrams, types) |
| POST | | Create (single item) |
| GET | | Get by ID |
| PATCH | | Update by ID |
| PATCH | | Batch upsert (items with |
Note: DELETE endpoints exist but are not yet implemented (return 501).
ID behavior: If you provide an when creating, that exact ID is used (predictable). If you omit , one is auto-generated. Providing a predictable is useful when you need to reference the resource elsewhere (e.g. a component's in a component instance's ).
ididididcomponentIdCreate requests accept a single object (not an array). Returns 201 on success.
Batch upsert is the most powerful pattern: send items with to update, without to create, all in one request.
idid所有资源(组件、图表、属性、标签)都遵循相同的模式:
| 方法 | 路径 | 操作 |
|---|---|---|
| GET | | 列出所有资源(组件、图表、类型支持可选查询过滤) |
| POST | | 创建(单个项目) |
| GET | | 根据ID获取资源 |
| PATCH | | 根据ID更新资源 |
| PATCH | | 批量插入更新(带 |
注意:DELETE端点存在但尚未实现**(返回501)。**
ID行为:如果在创建时提供,则会使用该确切ID(可预测)。如果省略,则会自动生成一个。当你需要在其他地方引用该资源时(例如组件实例的中引用组件的),提供可预测的会很有用。
ididcomponentIdidid创建请求接受单个对象(而非数组)。成功时返回201。
批量插入更新是最强大的模式:发送带的项目进行更新,不带的项目进行创建,所有操作在一个请求中完成。
ididComponent Schema
组件Schema
json
{
"id": "string",
"name": "string",
"state": "DRAFT | ACTIVE | ARCHIVED",
"desc": "string | null",
"inlineDesc": false,
"typeId": "string | null",
"apiContext": "string",
"attributes": [{ "id": "string", "value": "boolean | number | string | null" }],
"linksTo": ["diagram-id-1", "diagram-id-2"]
}- : Optional on create — provide it for a predictable ID, omit for auto-generated
id - : Optional label to group related imports (defaults to current UTC timestamp if omitted)
apiContext - : Array of diagram IDs this component links to
linksTo - : Component attribute values (reference attribute definitions by
attributes)id
json
{
"id": "string",
"name": "string",
"state": "DRAFT | ACTIVE | ARCHIVED",
"desc": "string | null",
"inlineDesc": false,
"typeId": "string | null",
"apiContext": "string",
"attributes": [{ "id": "string", "value": "boolean | number | string | null" }],
"linksTo": ["diagram-id-1", "diagram-id-2"]
}- :创建时可选——提供它以使用可预测的ID,省略则自动生成
id - :用于分组相关导入的可选标签(如果省略,默认为当前UTC时间戳)
apiContext - :此组件链接到的图表ID数组
linksTo - :组件属性值(通过
attributes引用属性定义)id
Diagram Schema
图表Schema
json
{
"id": "string",
"name": "string",
"state": "DRAFT | ACTIVE | ARCHIVED",
"url": "string",
"desc": "string | null",
"level": "C0 | C1 | C2 | C3 | C4 | D1 | P0 | null",
"tags": ["tag-id-1"],
"apiContext": "string",
"componentInstances": [],
"relations": [],
"textareas": []
}json
{
"id": "string",
"name": "string",
"state": "DRAFT | ACTIVE | ARCHIVED",
"url": "string",
"desc": "string | null",
"level": "C0 | C1 | C2 | C3 | C4 | D1 | P0 | null",
"tags": ["tag-id-1"],
"apiContext": "string",
"componentInstances": [],
"relations": [],
"textareas": []
}Diagram Levels
图表层级
| Level | Meaning |
|---|---|
| C0 | Landscape |
| C1 | System Context |
| C2 | Container |
| C3 | Component |
| C4 | Code |
| D1 | Deployment |
| P0 | Process |
| 层级 | 含义 |
|---|---|
| C0 | 全景图 |
| C1 | 系统上下文 |
| C2 | 容器 |
| C3 | 组件 |
| C4 | 代码 |
| D1 | 部署 |
| P0 | 流程 |
Component Instances
组件实例
A component is part of the architecture model — a reusable entity that can be referenced across many diagrams. A component instance is a visual placeholder on a diagram. It can optionally link to a component via , but it doesn't have to — unlinked instances are just standalone placeholders with a name and type.
componentIdTwo types:
Important: , , and are all optional. When omitted, Revision will automatically lay out and size the instances. Prefer omitting them unless the user explicitly asks for specific positioning or sizing — auto-layout produces better results.
positionwidthheightNon-container (default):
json
{
"ref": "unique-ref",
"componentId": "component-id | null",
"parent": "container-ref",
"isContainer": false,
"placeholder": { "text": "Name", "typeId": "type-id" }
}Container (groups other instances):
json
{
"ref": "unique-ref",
"componentId": "component-id | null",
"isContainer": true,
"placeholder": { "text": "Name", "typeId": "type-id" }
}- is required and must be unique within the diagram
ref - links the instance to a component definition (null for placeholders)
componentId - Non-containers can reference a container via the container's
parentref - Containers cannot have a parent
- ,
position,widthare optional — omit them to let Revision auto-layout and auto-sizeheight
组件是架构模型的一部分——可在多个图表中引用的可重用实体。组件实例是图表上的可视化占位符。它可以通过可选地链接到组件,但不是必须的——未链接的实例只是带有名称和类型的独立占位符。
componentId两种类型:
重要提示:、和都是可选的。省略时,Revision会自动布局和调整实例大小。除非用户明确要求特定的位置或大小,否则建议省略这些参数——自动布局的效果更好。
positionwidthheight非容器(默认):
json
{
"ref": "unique-ref",
"componentId": "component-id | null",
"parent": "container-ref",
"isContainer": false,
"placeholder": { "text": "Name", "typeId": "type-id" }
}容器(用于分组其他实例):
json
{
"ref": "unique-ref",
"componentId": "component-id | null",
"isContainer": true,
"placeholder": { "text": "Name", "typeId": "type-id" }
}- 是必填项,且在图表内必须唯一
ref - 将实例链接到组件定义(占位符为null)
componentId - 非容器可以通过容器的引用
ref容器parent - 容器不能有父容器
- 、
position、width是可选的——省略这些参数让Revision自动布局和调整大小height
Relations
关系
Directed edges between component instances:
json
{
"fromRef": "instance-ref-1",
"toRef": "instance-ref-2",
"label": "string | null",
"desc": "string | null",
"linksTo": ["diagram-id"]
}组件实例之间的有向边:
json
{
"fromRef": "instance-ref-1",
"toRef": "instance-ref-2",
"label": "string | null",
"desc": "string | null",
"linksTo": ["diagram-id"]
}Textareas
文本区域
Free text on diagrams:
json
{
"position": { "x": 100, "y": 100 },
"width": 300,
"text": "string | null"
}图表上的自由文本:
json
{
"position": { "x": 100, "y": 100 },
"width": 300,
"text": "string | null"
}Attribute Schema
属性Schema
Custom fields on components:
json
{
"id": "string",
"name": "string",
"desc": "string | null",
"type": "STRING | NUMBER | BOOLEAN | LINK | USERLIST | LIST",
"list": ["option1", "option2"],
"forTypes": ["type-id-1"],
"required": false,
"apiContext": "string"
}- is only valid when
lististype(and required for LIST)LIST - : Restrict attribute to specific component types
forTypes
组件上的自定义字段:
json
{
"id": "string",
"name": "string",
"desc": "string | null",
"type": "STRING | NUMBER | BOOLEAN | LINK | USERLIST | LIST",
"list": ["option1", "option2"],
"forTypes": ["type-id-1"],
"required": false,
"apiContext": "string"
}- 仅在
list为type时有效(且是LIST类型的必填项)LIST - :将属性限制为特定组件类型
forTypes
Tag Schema
标签Schema
json
{
"id": "string",
"name": "string",
"desc": "string | null",
"color": "gray | red | orange | yellow | green | blue | purple",
"apiContext": "string"
}json
{
"id": "string",
"name": "string",
"desc": "string | null",
"color": "gray | red | orange | yellow | green | blue | purple",
"apiContext": "string"
}Type Schema (Read-Only)
类型Schema(只读)
json
{
"id": "string",
"name": "string"
}Types are managed in the Revision UI. List via . Supports optional query parameter for filtering.
GET /api/external/typesnamejson
{
"id": "string",
"name": "string"
}类型在Revision UI中管理。通过列出。支持可选的查询参数进行过滤。
GET /api/external/typesnameTemplate Sync
模板同步
Bulk sync components and diagrams in a single transaction:
bash
curl -X POST -H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"components": [...], "diagrams": [...]}' \
https://acme-company.revision.app/api/external/templateAccepts both JSON and YAML. Components and diagrams follow their standard schemas.
在单个事务中批量同步组件和图表:
bash
curl -X POST -H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"components": [...], "diagrams": [...]}' \
https://acme-company.revision.app/api/external/template接受JSON和YAML格式。组件和图表遵循其标准Schema。
Filtering & Dependencies
过滤与依赖
Filtering Components
过滤组件
GET /api/external/components?name=...&typeId=...&tagId=...&attributeId=...&attributeValue=...&state=...All filters optional. requires .
attributeValueattributeIdGET /api/external/components?name=...&typeId=...&tagId=...&attributeId=...&attributeValue=...&state=...所有过滤器都是可选的。需要配合使用。
attributeValueattributeIdFiltering Diagrams
过滤图表
GET /api/external/diagrams?componentId=...&tagId=...&name=...&level=...&state=...All filters optional.
GET /api/external/diagrams?componentId=...&tagId=...&name=...&level=...&state=...所有过滤器都是可选的。
Filtering Types
过滤类型
GET /api/external/types?name=...GET /api/external/types?name=...Component Dependencies
组件依赖
GET /api/external/components/{id}/dependenciesReturns — upstream and downstream direct dependencies for a component.
DependencySearchResult[]GET /api/external/components/{id}/dependencies返回——组件的上游和下游直接依赖。
DependencySearchResult[]Workflow: Create a Diagram with Components
工作流:创建包含组件的图表
A typical end-to-end flow: search for duplicates, create components, then create a diagram that references them.
-
Search for existing duplicates — MUST do this before creating anything:
- For each component you plan to create, search by name:
GET /api/external/components?name=<name> - For the diagram, search by name:
GET /api/external/diagrams?name=<name> - If matches are found → ask the user whether to reuse the existing resource or create a new one
- If the user chooses to reuse → use the existing resource's instead of creating a new one
id - If no matches → proceed to create
- Skip ONLY when the user explicitly says "create a new..." or "update the existing..."
- For each component you plan to create, search by name:
-
List types to find the rightvalues:
typeId
bash
curl -H "Authorization: Bearer $API_KEY" \
https://acme-company.revision.app/api/external/types- Create components (skip any that the user chose to reuse from step 1):
bash
curl -X POST -H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"id": "user-service", "name": "User Service", "state": "ACTIVE"}' \
https://acme-company.revision.app/api/external/componentsbash
curl -X POST -H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"id": "user-db", "name": "User Database", "state": "ACTIVE"}' \
https://acme-company.revision.app/api/external/components- Create a diagram with component instances and a relation:
bash
curl -X POST -H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "User Service Context",
"level": "C2",
"state": "ACTIVE",
"componentInstances": [
{ "ref": "us", "componentId": "user-service" },
{ "ref": "udb", "componentId": "user-db" }
],
"relations": [
{ "fromRef": "us", "toRef": "udb", "label": "Reads/writes" }
]
}' \
https://acme-company.revision.app/api/external/diagrams- Verify by fetching the diagram back:
bash
curl -H "Authorization: Bearer $API_KEY" \
https://acme-company.revision.app/api/external/diagrams/<returned-id>For bulk operations, use the template endpoint to sync everything in a single transaction instead.
典型的端到端流程:搜索重复项,创建组件,然后创建引用这些组件的图表。
-
搜索现有重复项——创建任何资源前必须执行此步骤:
- 对于每个计划创建的组件,按名称搜索:
GET /api/external/components?name=<name> - 对于图表,按名称搜索:
GET /api/external/diagrams?name=<name> - 如果找到匹配项→询问用户是重用现有资源还是创建新资源
- 如果用户选择重用→使用现有资源的而不是创建新资源
id - 如果没有匹配项→继续创建
- 仅当用户明确说“创建新的...”或“更新现有的...”时,才跳过此步骤
- 对于每个计划创建的组件,按名称搜索:
-
列出类型以找到正确的值:
typeId
bash
curl -H "Authorization: Bearer $API_KEY" \
https://acme-company.revision.app/api/external/types- 创建组件(跳过用户在步骤1中选择重用的组件):
bash
curl -X POST -H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"id": "user-service", "name": "User Service", "state": "ACTIVE"}' \
https://acme-company.revision.app/api/external/componentsbash
curl -X POST -H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"id": "user-db", "name": "User Database", "state": "ACTIVE"}' \
https://acme-company.revision.app/api/external/components- 创建包含组件实例和关系的图表:
bash
curl -X POST -H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "User Service Context",
"level": "C2",
"state": "ACTIVE",
"componentInstances": [
{ "ref": "us", "componentId": "user-service" },
{ "ref": "udb", "componentId": "user-db" }
],
"relations": [
{ "fromRef": "us", "toRef": "udb", "label": "Reads/writes" }
]
}' \
https://acme-company.revision.app/api/external/diagrams- 验证:通过获取图表来确认:
bash
curl -H "Authorization: Bearer $API_KEY" \
https://acme-company.revision.app/api/external/diagrams/<returned-id>对于批量操作,使用模板端点在单个事务中同步所有内容,而不是分别操作。
Output Summary
输出摘要
After every mutation (create, update, batch upsert, or template sync), print a summary that clearly separates what was created from what was updated.
Format:
Created:
- Component "User Service" (id: user-service)
- Diagram "System Context" (id: system-context)
Updated:
- Component "Auth Service" (id: auth-service) — updated name, descRules:
- Use Created for POST (201) responses and batch upsert items that had no provided
id - Use Updated for PATCH (200) responses and batch upsert items that had an provided
id - Always include the resource type, name, and ID
- For updates, briefly note which fields changed
- Omit a section if it's empty (e.g. don't print "Updated:" if nothing was updated)
每次执行变更操作(创建、更新、批量插入更新或模板同步)后,打印一个摘要,明确区分创建的内容和更新的内容。
格式:
Created:
- Component "User Service" (id: user-service)
- Diagram "System Context" (id: system-context)
Updated:
- Component "Auth Service" (id: auth-service) — updated name, desc规则:
- 对于POST(201)响应和批量插入更新中未提供的项目,使用Created
id - 对于PATCH(200)响应和批量插入更新中提供了的项目,使用Updated
id - 始终包含资源类型、名称和ID
- 对于更新操作,简要说明哪些字段被修改
- 如果某个部分为空,则省略该部分(例如,如果没有更新任何内容,则不要打印“Updated:”)
Error Responses
错误响应
All errors return:
json
{ "error": "description" }| Status | Meaning |
|---|---|
| 400 | Validation error |
| 401 | Missing or invalid API key |
| 404 | Resource not found |
| 405 | Method not allowed |
| 501 | Not implemented (e.g. DELETE endpoints) |
所有错误都会返回:
json
{ "error": "description" }| 状态码 | 含义 |
|---|---|
| 400 | 验证错误 |
| 401 | API密钥缺失或无效 |
| 404 | 资源未找到 |
| 405 | 不允许使用该方法 |
| 501 | 未实现(例如DELETE端点) |
Error Recovery
错误恢复
When an API call fails:
- 401: Confirm the API key is correct and the Authorization header uses prefix.
Bearer - 400: Read the field — it describes the validation issue. Fix the request body and retry.
error - 404: Verify the resource ID. Use the list endpoint () to confirm the resource exists.
GET /api/external/{resource} - 501: DELETE is not implemented. Use PATCH to set instead.
state: "ARCHIVED"
Always verify mutations by fetching the resource back after create/update to confirm the change took effect.
当API调用失败时:
- 401:确认API密钥正确,且Authorization头使用前缀。
Bearer - 400:阅读字段——它描述了验证问题。修复请求体并重试。
error - 404:验证资源ID。使用列表端点()确认资源是否存在。
GET /api/external/{resource} - 501:DELETE未实现。使用PATCH将来替代。
state: "ARCHIVED"
创建/更新后,始终通过获取资源来验证变更是否生效。
Full OpenAPI Spec
完整OpenAPI规范
For the complete OpenAPI 3.0.3 specification with all request/response schemas, see OPENAPI.md.
如需包含所有请求/响应Schema的完整OpenAPI 3.0.3规范,请查看OPENAPI.md。