Coda API Skill
Interact with the Coda REST API v1 to manage docs, tables, rows, pages, and automations.
When to Use
Use this skill when the user wants to:
- - List, search, create, or delete Coda docs
- Read from or write to tables (insert, upsert, update, delete rows)
- Explore doc structure (pages, tables, columns, formulas, controls)
- Trigger automations (push buttons)
- Export doc content or analytics
When NOT to Use
- - Do NOT use for general document editing advice unrelated to the API
- Do NOT use for Pack development (this skill covers Doc management, not Pack creation)
- Do NOT use for operations requiring Doc Maker permissions unless confirmed the user has them
Prerequisites
- 1. API Token: Set environment variable
CODA_API_TOKEN with your Coda API token
- Get token at: https://coda.io/account -> API Settings
- 2. Python 3.7+ with
requests library installed - Permissions: Some operations (create doc, update doc title, create page) require Doc Maker role in the workspace
CLI Tool Usage
The skill includes a Python CLI tool at scripts/coda_cli.py:
CODEBLOCK0
Workflow Guidelines
1. Doc ID Extraction
Coda doc IDs can be extracted from browser URLs:
- - URL: INLINECODE3
- Doc ID:
AbCDeFGH (remove _d prefix)
The CLI tool accepts both full URLs and raw IDs.
2. Rate Limit Handling
The API has strict rate limits:
- - Read: 100 requests per 6 seconds
- Write (POST/PUT/PATCH): 10 requests per 6 seconds
- Write doc content: 5 requests per 10 seconds
- List docs: 4 requests per 6 seconds
The CLI tool automatically implements exponential backoff for 429 responses.
3. Asynchronous Operations
Write operations return HTTP 202 with a
requestId. The CLI tool optionally polls for completion using
--wait flag.
4. Safety Guardrails
Delete Operations (rows, docs, pages, folders):
- - Always requires explicit user confirmation in interactive mode
- Use
--force flag only in automation/scripts - Shows preview of what will be deleted
Publishing (docs publish):
- - Requires explicit
--confirm-publish flag - Cannot be combined with INLINECODE11
Permissions (acl commands):
- - Requires explicit
--confirm-permissions flag for any changes - Read operations (list permissions) are always allowed
Automation Triggers:
- - Allowed without special flags but logged
- User should be aware that automations may trigger notifications or external actions
5. Pagination
List commands support:
- -
--limit: Maximum results (default 25, max varies by endpoint) - INLINECODE15 : For fetching subsequent pages
- CLI auto-follows pages with
--all flag
Common Patterns
Batch Row Operations
CODEBLOCK1
Sync Between Docs
CODEBLOCK2
Explore Structure
CODEBLOCK3
Error Handling
Common HTTP status codes:
- -
400: Bad request (invalid parameters) - INLINECODE18 : Invalid/expired API token
- INLINECODE19 : Insufficient permissions (need Doc Maker role)
- INLINECODE20 : Resource not found
- INLINECODE21 : Rate limited (implement backoff)
- INLINECODE22 : Accepted but not yet processed (async operation)
Security Considerations
- 1. Token Storage: Never commit
CODA_API_TOKEN to version control - Token Scope: The token has full access to all docs the user can access
- Workspace Restrictions: Creating docs requires Doc Maker role in target workspace
- Data Exposure: Row data may contain sensitive information; handle exports carefully
Examples
List and Filter Docs
CODEBLOCK4
Create Doc from Template
CODEBLOCK5
Update Row Status
CODEBLOCK6
Delete Multiple Rows (with confirmation)
CODEBLOCK7
Export Table to CSV
CODEBLOCK8
Reference
- - API Documentation: https://coda.io/developers/apis/v1
- OpenAPI Spec: https://coda.io/apis/v1/openapi.yaml
- Rate Limits: https://coda.io/developers/apis/v1#section/Rate-Limiting
Coda API 技能
与 Coda REST API v1 交互,管理文档、表格、行、页面和自动化。
使用场景
当用户想要执行以下操作时使用此技能:
- - 列出、搜索、创建或删除 Coda 文档
- 读取或写入表格(插入、更新插入、更新、删除行)
- 探索文档结构(页面、表格、列、公式、控件)
- 触发自动化(按钮推送)
- 导出文档内容或分析数据
禁止使用场景
- - 请勿用于与 API 无关的常规文档编辑建议
- 请勿用于 Pack 开发(此技能涵盖文档管理,而非 Pack 创建)
- 请勿用于需要文档制作者权限的操作,除非确认用户拥有该权限
前提条件
- 1. API 令牌:将环境变量 CODAAPITOKEN 设置为你的 Coda API 令牌
- 获取令牌:https://coda.io/account -> API 设置
- 2. Python 3.7+ 并安装 requests 库
- 权限:某些操作(创建文档、更新文档标题、创建页面)需要在工作区中拥有文档制作者角色
CLI 工具使用
该技能包含位于 scripts/coda_cli.py 的 Python CLI 工具:
bash
设置
export CODA
APITOKEN=your
tokenhere
列出文档
python scripts/coda_cli.py docs list --query Project
获取文档信息
python scripts/coda_cli.py docs get
创建文档
python scripts/coda_cli.py docs create --title 我的新文档
列出文档中的表格
python scripts/coda_cli.py tables list
列出表格中的行
python scripts/coda_cli.py rows list
插入行
python scripts/coda_cli.py rows insert --data {名称: 任务1, 状态: 已完成}
更新行
python scripts/coda_cli.py rows update --data {状态: 进行中}
删除行(需要确认)
python scripts/coda_cli.py rows delete
列出页面
python scripts/coda_cli.py pages list
触发自动化(按钮推送)
python scripts/coda_cli.py automations trigger
强制删除无需确认(谨慎使用)
python scripts/coda_cli.py docs delete --force
工作流程指南
1. 文档 ID 提取
Coda 文档 ID 可以从浏览器 URL 中提取:
- - URL:https://coda.io/d/dAbCDeFGH/Project-Tracker
- 文档 ID:AbCDeFGH(移除 d 前缀)
CLI 工具接受完整 URL 和原始 ID。
2. 速率限制处理
API 有严格的速率限制:
- - 读取:每 6 秒 100 次请求
- 写入(POST/PUT/PATCH):每 6 秒 10 次请求
- 写入文档内容:每 10 秒 5 次请求
- 列出文档:每 6 秒 4 次请求
CLI 工具自动对 429 响应实现指数退避。
3. 异步操作
写入操作返回带有 requestId 的 HTTP 202。CLI 工具可选择使用 --wait 标志轮询完成状态。
4. 安全防护
删除操作(行、文档、页面、文件夹):
- - 在交互模式下始终需要明确的用户确认
- 仅在自动化/脚本中使用 --force 标志
- 显示将要删除的内容预览
发布(docs publish):
- - 需要明确的 --confirm-publish 标志
- 不能与 --force 结合使用
权限(acl 命令):
- - 任何更改都需要明确的 --confirm-permissions 标志
- 读取操作(列出权限)始终允许
自动化触发:
- - 允许无需特殊标志但会记录日志
- 用户应知晓自动化可能触发通知或外部操作
5. 分页
列表命令支持:
- - --limit:最大结果数(默认 25,最大值因端点而异)
- --page-token:用于获取后续页面
- CLI 使用 --all 标志自动跟随页面
常见模式
批量行操作
bash
从 JSON 文件插入多行
python scripts/coda_cli.py rows insert-batch --file rows.json
更新插入行(存在则更新,不存在则插入)使用关键列
python scripts/coda_cli.py rows upsert --file rows.json --keys 邮箱
文档间同步
bash
从源文档导出
python scripts/coda_cli.py rows list --format json > export.json
导入到目标文档
python scripts/coda_cli.py rows insert-batch --file export.json
探索结构
bash
获取完整文档结构
python scripts/coda_cli.py docs structure
列出所有公式
python scripts/coda_cli.py formulas list
列出所有控件
python scripts/coda_cli.py controls list
错误处理
常见 HTTP 状态码:
- - 400:错误请求(参数无效)
- 401:API 令牌无效或过期
- 403:权限不足(需要文档制作者角色)
- 404:资源未找到
- 429:速率受限(实施退避)
- 202:已接受但尚未处理(异步操作)
安全考虑
- 1. 令牌存储:切勿将 CODAAPITOKEN 提交到版本控制
- 令牌范围:令牌具有用户可访问的所有文档的完全访问权限
- 工作区限制:创建文档需要在目标工作区拥有文档制作者角色
- 数据暴露:行数据可能包含敏感信息;谨慎处理导出
示例
列出并筛选文档
bash
python scripts/coda_cli.py docs list --is-owner --query Project
从模板创建文档
bash
python scripts/coda_cli.py docs create --title Q4 规划 --source-doc template-doc-id
更新行状态
bash
python scripts/coda_cli.py rows update AbCDeFGH grid-xyz row-123 \
--data {状态: 已完成, 完成日期: 2024-01-15}
删除多行(需确认)
bash
python scripts/coda_cli.py rows delete-batch AbCDeFGH grid-xyz \
--filter {状态: 已归档} \
--confirm 删除所有已归档的行?
将表格导出为 CSV
bash
python scripts/coda_cli.py rows list AbCDeFGH grid-xyz --format csv > export.csv
参考
- - API 文档:https://coda.io/developers/apis/v1
- OpenAPI 规范:https://coda.io/apis/v1/openapi.yaml
- 速率限制:https://coda.io/developers/apis/v1#section/Rate-Limiting