渠道
复制一个包含安装步骤和本插件 Markdown 指南的配置提示
Capgo 中的通道是管理应用程序更新的核心机制。它们允许您控制用户何时接收更新,启用 A/B 测试、分阶段发布和平台特定更新等功能。
了解通道
标题:了解通道通道代表应用程序更新的分发跟踪。每个通道都可以配置特定的规则和约束:
- 包(版本)控制: 指定用户接收哪个包(版本)
- 平台目标: 目标 iOS/Android/Electron 平台
- 更新策略: 控制更新的分发方式
- 设备限制: 管理哪些设备可以访问更新
频道配置选项
频道配置选项- 公共: 设为新设备的默认频道
- 禁用原生应用更新: 当设备的原生应用版本新于频道的稳定包时,防止更新
- 禁用自动更新: 控制更新行为 (
major,minor,metadata,patch, 或none). - updatePackage: 控制设备下载 zip、delta 或两者的方式 (
all,zip,delta,zip_from_builtin, 或delta_from_builtin). 请参阅 下载格式. - iOS/Android/Electron: 根据平台启用或禁用分发.
- 允许设备自行设置: 允许设备自行选择频道.
- 允许模拟器, 允许设备, 允许开发, 允许生产: 控制哪些设备和构建类型接收更新。
- 渐进式发布: 保持稳定的包同时暴露目标包给粘性群体。参见 渐进式发布.
最佳实践
最佳实践- 测试频道: 维护内部验证的测试频道
- 阶段发布: 多个渠道用于逐渐更新部署
- 平台分离: 根据需要创建 iOS、Android 和 Electron 的单独渠道
- 包(版本)控制: 使用 语义版本 以清晰的更新路径
端点
标题:端点POST
标题:POSThttps://api.capgo.app/channel/
创建或更新渠道配置
请求体
标题:请求体type DisableAutoUpdate = "major" | "minor" | "metadata" | "patch" | "none"type AutoPauseAction = "pause" | "rollback" | "notify"
interface ChannelSet { app_id: string channel: string version?: string | null // stable bundle name public?: boolean disableAutoUpdateUnderNative?: boolean disableAutoUpdate?: DisableAutoUpdate updatePackage?: "all" | "zip" | "delta" | "zip_from_builtin" | "delta_from_builtin" ios?: boolean android?: boolean electron?: boolean allow_device_self_set?: boolean allow_emulator?: boolean allow_device?: boolean allow_dev?: boolean allow_prod?: boolean
// Progressive rollout (camelCase is preferred) rolloutVersion?: string | number | null // target bundle name or ID rolloutPercentage?: number // 0–100 rolloutPercentageBps?: number // 0–10000; takes precedence when both are set rolloutEnabled?: boolean rolloutPaused?: boolean // input-only convenience flag rolloutPausedAt?: string | null // ISO timestamp or null rolloutPauseReason?: string | null rolloutCacheTtlSeconds?: number // 60–31536000 rollback?: boolean promoteToStable?: boolean
// Rollout auto-pause policy autoPauseEnabled?: boolean autoPauseWindowMinutes?: number autoPauseFailureRateBps?: number | null autoPauseConfidence?: number autoPauseMinAttempts?: number | null autoPauseMinFailures?: number | null autoPauseAction?: AutoPauseAction autoPauseCooldownMinutes?: number}对于滚动和自动暂停字段,API 也接受等效的 snake_case 表单形式,如 rollout_version 或 auto_pause_enabled. updatePackage 也接受 update_package. 如果同时提供两种形式,驼峰式值将获胜。 rollback 仅支持驼峰式。
发布目标需要一个现有的渠道。它必须有一个稳定的捆绑包已分配或通过 version 在同一个POST请求中接收。 rollback 和 promoteToStable 这些是终端操作;请勿将它们与其他操作合并。
示例请求
标题:示例请求配置一个已有的5%的滚动频率的频道,其稳定包已经设置: production 终端窗口
curl -X POST \ -H "authorization: your-api-key" \ -H "Content-Type: application/json" \ -d '{ "app_id": "com.example.app", "channel": "production", "rolloutVersion": "1.3.0", "rolloutPercentage": 5, "rolloutEnabled": true, "rolloutCacheTtlSeconds": 2592000, "autoPauseEnabled": true, "autoPauseFailureRateBps": 500, "autoPauseMinAttempts": 100, "autoPauseAction": "pause" }' \ https://api.capgo.app/channel/{ "status": "ok"}应用预览键边界
protectedTokens
App Preview key boundary为最小权限的PR预览,使用以下凭据认证此端点: authorization: $CAPGO_API_KEY 或 capgkey: $CAPGO_API_KEY. The x-api-key Channels 不接受头部 API.
An app_preview 一个 channel.update_settings密钥可以创建一个新的非公共预览频道。创建自动为该密钥分配一个频道范围的生命周期绑定,仅限于该频道。该角色不包括
Leave public 未设置(或设置为 false)以便PR预览频道。使用 bundle upload --channel 来创建和上传流程代替将POST视为一般预览频道upsert。
GET
GEThttps://api.capgo.app/channel/
获取频道信息。每页返回50个频道。没有 channel,响应是一个数组。有 channel,响应是一个频道对象。
请求参数
频道ID:必填。您的应用IDapp_id页码:可选。分页页码page频道名称:可选。具体频道名称channel示例请求
请求示例
分页参数# Get all channelscurl -H "authorization: your-api-key" \ "https://api.capgo.app/channel/?app_id=com.example.app"
# Get a specific channelcurl -H "authorization: your-api-key" \ "https://api.capgo.app/channel/?app_id=com.example.app&channel=production"
# Get the next pagecurl -H "authorization: your-api-key" \ "https://api.capgo.app/channel/?app_id=com.example.app&page=1"响应类型
响应类型interface Channel { id: number created_at: string updated_at: string name: string app_id: string created_by: string public: boolean disableAutoUpdateUnderNative: boolean disableAutoUpdate: DisableAutoUpdate updatePackage: "all" | "zip" | "delta" | "zip_from_builtin" | "delta_from_builtin" allow_device_self_set: boolean allow_emulator: boolean allow_device: boolean allow_dev: boolean allow_prod: boolean version: { id: number, name: string } | null // stable bundle
// These three response identifiers intentionally use snake_case. rollout_version: number | null rollout_id: string rollout_version_info: { id: number, name: string } | null
rolloutPercentageBps: number rolloutEnabled: boolean rolloutPausedAt: string | null rolloutPauseReason: string | null rolloutCacheTtlSeconds: number autoPauseEnabled: boolean autoPauseWindowMinutes: number autoPauseFailureRateBps: number | null autoPauseConfidence: number autoPauseMinAttempts: number | null autoPauseMinFailures: number | null autoPauseAction: AutoPauseAction autoPauseCooldownMinutes: number autoPauseLastTriggeredAt: string | null autoPauseLastCheckedAt: string | null}rolloutPaused 仅用于输入,且不会返回。暂停的发布将用非空值表示。 rolloutPausedAt.
示例响应
示例响应[ { "id": 1, "name": "production", "app_id": "com.example.app", "updatePackage": "all", "version": { "id": 1, "name": "1.2.0" }, "rollout_version": 2, "rollout_id": "e60c19c9-2e65-4e0d-bc06-d1f5b4f96276", "rollout_version_info": { "id": 2, "name": "1.3.0" }, "rolloutPercentageBps": 500, "rolloutEnabled": true, "rolloutPausedAt": null, "rolloutCacheTtlSeconds": 2592000, "autoPauseEnabled": true, "autoPauseFailureRateBps": 500, "autoPauseAction": "pause" }]https://api.capgo.app/channel/
删除频道。注意,这将影响使用此频道的所有设备。
请求体
请求体interface Channel { channel: string app_id: string delete_bundle?: boolean // also delete the linked bundle}示例请求
示例请求curl -X DELETE \ -H "authorization: your-api-key" \ -H "Content-Type: application/json" \ -d '{ "app_id": "com.example.app", "channel": "beta" }' \ https://api.capgo.app/channel/成功响应
成功响应{ "status": "ok"}应用预览清理
应用预览清理使用 delete_bundle: true, 一个 app_preview 的关键字可以原子性地清除它创建的频道及其关联的未共享包。该关键字不获得一般 bundle.delete 权限。
curl -X DELETE \ -H "capgkey: $CAPGO_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "app_id": "com.example.app", "channel": "pr-123", "delete_bundle": true }' \ https://api.capgo.app/channel/错误处理
标题:错误处理常见错误场景及其响应:
// Channel not found{ "error": "Channel not found", "status": "KO"}
// Invalid bundle (version) format{ "error": "Invalid version format. Use semantic versioning", "status": "KO"}
// Invalid update policy{ "error": "Invalid disableAutoUpdate value", "status": "KO"}
// Permission denied{ "error": "Insufficient permissions to manage channels", "status": "KO"}常见用例
标题:常见用例- Beta 测试
{ "app_id": "com.example.app", "channel": "beta", "version": "1.2.0-beta", "public": false, "allow_emulator": true, "allow_dev": true}- 生产发布
{ "app_id": "com.example.app", "channel": "production", "version": "1.2.0", "public": true, "disableAutoUpdate": "minor"}- 平台特定更新
{ "app_id": "com.example.app", "channel": "ios-hotfix", "version": "1.2.1", "ios": true, "android": false}继续从 Channels
继续从 Channels如果您正在使用 Channels 与其进行连接以规划通道路由和分阶段发布 Channels 为 Channels 的实现细节 Channels 为 Channels 的实现细节 测试 Beta Testing 解决方案 为 Beta Testing 解决方案的产品工作流 版本目标解决方案 Capgo 环境最佳实践:使用一个移动应用ID进行分阶段 Capgo 环境最佳实践:使用一个移动应用ID