组织
复制一个包含安装步骤和本插件完整 Markdown 指南的配置提示。
组织是 Capgo 的顶级实体。它们允许您将应用程序、团队成员和资源都归类在一个单一的组织下。每个组织都可以有多个成员,具有不同的角色和权限。
常见用例
常见用例- 为您的公司创建新组织
- 管理组织设置
- 更新组织信息
- 获取组织详细信息
API
GETGET
APIhttps://api.capgo.app/organization/
获取组织信息。如果 orgId 在参数中提供,则返回单个组织。否则,返回所有可访问的组织。
查询参数
标题:查询参数orgId(可选):要检索的特定组织的 ID
响应类型
标题:响应类型interface Organization { id: string created_by: string created_at: string updated_at: string logo: string | null name: string management_email: string customer_id: string | null}示例请求
标题:示例请求# Get all organizationscurl -H "x-api-key: YOUR_API_KEY" https://api.capgo.app/organization/
# Get specific organizationcurl -H "x-api-key: YOUR_API_KEY" https://api.capgo.app/organization/?orgId=org_123示例响应
示例响应部分{ "data": { "id": "org_123", "name": "My Company", "created_at": "2024-01-01T00:00:00Z", "updated_at": "2024-01-01T00:00:00Z", "logo": "https://example.com/logo.png", "management_email": "admin@example.com", "customer_id": "cus_123" }}POST
POST部分https://api.capgo.app/organization/
创建一个新组织。
当使用一个API密钥时,密钥必须具有全局权限和当前组织范围的 org.create 或 org_admin 绑定。这是必要的,因为目标组织尚未存在,因此正常的组织范围RBAC无法检查它。 org_super_admin 当请求成功时,__CAPGO_KEEP_0__自动将同样的__CAPGO_KEEP_1__密钥 assignments
When the request succeeds, Capgo automatically assigns the same API key as org_super_admin 创建一个新组织
标题:请求体
复制到剪贴板interface OrganizationCreate { name: string email?: string estimatedMau?: number website?: string}标题:示例请求
终端窗口curl -X POST \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "New Organization", "email": "admin@example.com", "website": "https://example.com" }' \ https://api.capgo.app/organization/示例响应
标题:示例响应{ "id": "org_456"}权限错误
标题:权限错误如果API键没有 org.create,则API返回:
{ "error": "permission_denied"}PUT
标题:PUThttps://api.capgo.app/organization/
更新现有组织。需要在目标组织上拥有管理员角色。
Request Body
请求体interface OrganizationUpdate { orgId: string logo?: string name?: string management_email?: string}示例请求
示例请求curl -X PUT \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "orgId": "org_123", "name": "New Company Name", "management_email": "newemail@example.com" }' \ https://api.capgo.app/organization/示例响应
示例响应{ "status": "Organization updated", "data": { "id": "org_123", "name": "New Company Name", "management_email": "newemail@example.com" }}删除
删除https://api.capgo.app/organization/
删除现有的组织。需要在目标组织上删除权限,通常通过 org_super_admin 角色。这个动作是不可逆的,并且会移除所有关联的应用、捆绑包(版本)和资源。
全局权限不允许删除组织。 org.create 查询参数
Section titled “Query Parameters”
: 需要删除的组织的 IDorgId示例请求
Section titled “Example Request”
终端窗口curl -X DELETE \ -H "x-api-key: YOUR_API_KEY" \ https://api.capgo.app/organization/?orgId=org_123__CAPGO_KEEP_0__
Section titled “示例响应”{ "status": "ok"}常见错误场景和响应:
// Invalid API key{ "error": "Invalid API key", "status": "KO"}
// Missing required field{ "error": "Name is required", "status": "KO"}
// Insufficient permissions{ "error": "Admin role required", "status": "KO"}- 命名: 给组织使用清晰、描述性的名称
- : 为团队成员分配适当的角色Roles
- 邮箱: 为管理_email避免因个人邮箱变更而产生问题使用组邮箱
- Logo: 将Logo托管在可靠的CDN上并使用HTTPS URL
继续从组织
: 组织如果您正在使用 组织 来规划仪表板和API操作,连接它与 API概览 为了在API概览中获取API操作的实施细节 介绍 为《介绍》中的实现细节 API Keys 为《API Keys》中的实现细节 设备 为《设备》中的实现细节 包 为《包》中的实现细节