Developer API
V2

更新数据库

更新数据库标题、描述、图标、封面或属性 schema。

PATCH /v2/databases/:database_id

更新数据库

适用场景

当你要修改数据库标题、描述、图标、封面,或调整属性 schema 时使用这个接口。它适合做字段演进和结构修补。

接口信息

项目内容
方法PATCH
路径/v2/databases/:database_id
请求体database 局部更新参数
返回database
Scopedatabases.write

权限要求

需要 databases.write

请求参数

参数类型必填说明
database_idstring数据库 ID。
titlerich_text[]数据库标题。
descriptionrich_text[]数据库描述。
iconobject | null数据库图标。
coverobject | null数据库封面。
propertiesobject属性 schema 的局部更新。某个 schema 可以传 null 表示删除。
in_trashboolean回收站状态。

请求体示例:

{
  "title": [
    {
      "type": "text",
      "text": {
        "content": "任务看板(新版)"
      }
    }
  ],
  "description": [
    {
      "type": "text",
      "text": {
        "content": "用于管理发布流程与任务状态"
      }
    }
  ],
  "icon": {
    "type": "emoji",
    "emoji": "🗂️"
  },
  "properties": {
    "Priority": {
      "name": "Priority",
      "type": "select",
      "select": {
        "options": [
          { "name": "P0", "color": "red" },
          { "name": "P1", "color": "orange" }
        ]
      }
    },
    "Status": null
  },
  "in_trash": false
}

响应结果

{
  "object": "database",
  "id": "66666666-6666-4666-8666-666666666666",
  "title": [
    {
      "type": "text",
      "text": {
        "content": "任务看板(新版)",
        "link": null
      },
      "plain_text": "任务看板(新版)",
      "href": null
    }
  ],
  "description": [
    {
      "type": "text",
      "text": {
        "content": "用于管理发布流程与任务状态",
        "link": null
      },
      "plain_text": "用于管理发布流程与任务状态",
      "href": null
    }
  ],
  "properties": {
    "Name": {
      "id": "title",
      "type": "title",
      "name": "Name"
    }
  },
  "in_trash": false
}

行为说明或限制

  • 这是部分更新接口,不传的字段保持不变。
  • properties 中某个 schema 传 null 时,会从数据库中删除该字段。
  • properties 中传入新 schema 时,会按字段名匹配或新增。
  • titledescriptioniconcoverin_trash 都可以单独更新。

错误提示

  • 400 validation_error:目标对象不是数据库,或属性更新不合法。
  • 401 unauthorized:token 无效或已过期。
  • 403 forbidden:缺少 databases.write 或无权访问该数据库。
  • 404 not_found:数据库不存在。

相关文档

前置阅读

下一步

相关参考