组织
复制一个包含安装步骤和本插件的完整Markdown指南的设置提示
Capgo 的顶级实体是组织。它们允许您将应用程序、团队成员和资源组合在一个单独的帆布下。每个组织可以有多个具有不同角色和权限的成员。
常见用例
标题:常见用例- 为您的公司创建新组织
- 管理组织设置
- 更新组织信息
- 检索组织详细信息
https://api.capgo.app/organization/
获取组织信息。如果 orgId 在参数中提供,则返回单个组织;否则,返回所有可访问的组织。
Query Parameters
Section titled “Query Parameters”orgId(可选): 要检索的特定组织的 ID
Response Type
Section titled “Response Type”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}Example Request
示例请求# 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" }}https://api.capgo.app/organization/
或
使用API密钥时,密钥必须具有全局权限并且具有当前组织范围的 org.create 或 org_admin 创建新组织 org_super_admin 绑定。由于目标组织尚未存在,因此无法使用正常的组织范围RBAC检查它。
当请求成功时,Capgo会自动为新组织分配相同的API密钥。 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/
更新现有组织。需要在目标组织上拥有管理员角色。
请求体
请求体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/Section titled “PUT”
Section titled “Request Body”{ "status": "Organization updated", "data": { "id": "org_123", "name": "New Company Name", "management_email": "newemail@example.com" }}DELETE
标题:DELETEhttps://api.capgo.app/organization/
删除一个现有的组织。需要在目标组织上删除权限,通常通过 org_super_admin 角色。这个动作是不可逆的,会移除所有相关的应用、版本包(版本)和资源。
The org.create global permission does not allow deleting organizations.
查询参数
标题:查询参数orgId: 要删除的组织 ID
示例请求
标题:示例请求curl -X DELETE \ -H "x-api-key: YOUR_API_KEY" \ https://api.capgo.app/organization/?orgId=org_123示例响应
标题:示例响应{ "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"}最佳实践
标题:最佳实践- 命名规则使用清晰、描述性的组织名称
- 角色组织成员分配适当的角色
- 邮箱使用一个群组邮箱来管理管理_email,避免因个人邮箱变更而产生问题
- Logo将Logo托管在可靠的CDN上并使用HTTPS URL
继续从组织
继续从组织如果您正在使用 组织 来规划仪表板和API操作,连接它 API 介绍 为 API 介绍 中的实现细节 简介 为简介 中的实现细节 API 密钥 为 API 密钥 中的实现细节 设备 为设备 中的实现细节, 捆绑包 为捆绑包 中的实现细节。