组织
复制一个带有安装步骤和完整 Markdown 指南的设置提示。
组织是Capgo中的顶级实体。它们允许您将应用程序、团队成员和资源都归类到一个单一的组织下。每个组织都可以有多个成员,具有不同的角色和权限。
常见用例
标题为“常见用例”的部分- 为您的公司创建一个新的组织
- 管理组织设置
- 更新组织信息
- 获取组织详细信息
API端点
API端点GET
获取组织信息。如果https://api.capgo.app/organization/
在参数中提供,则返回单个组织。否则,返回所有可访问的组织。 orgId 查询参数
API端点
(可选): 要检索的特定组织的 IDorgId__CAPGO_KEEP_0__
响应类型
响应类型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
POSThttps://api.capgo.app/organization/
创建一个新组织。
当使用一个 API 密钥时,密钥必须具有全局权限和一个当前组织范围的绑定。 org.create 因为目标组织还不存在,所以不能使用正常的组织范围的RBAC检查它。 org_admin 当请求成功时,__CAPGO_KEEP_0__ 会自动将同一个 __CAPGO_KEEP_1__ 密钥赋予新组织。 org_super_admin 注意
When the request succeeds, Capgo automatically assigns the same API key as org_super_admin 新 __CAPGO_KEEP_0__ 密钥默认不授予创建组织的权限。
请求体
标题:请求体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"}https://api.capgo.app/organization/
更新现有组织。需要在目标组织上拥有管理员角色
Request Body
Section titled “Request Body”interface OrganizationUpdate { orgId: string logo?: string name?: string management_email?: string}Example Request
Section titled “Example Request”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" }}DELETE
删除现有组织。需要在目标组织上删除权限,通常通过https://api.capgo.app/organization/
角色。该操作不可逆转,会删除所有关联的应用、捆绑包(版本)和资源。 org_super_admin 全局权限不允许删除组织。
查询参数 org.create __CAPGO_KEEP_0__
__CAPGO_KEEP_0__
参数查询部分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"}最佳实践
名为“最佳实践”的部分- 命名: 为组织使用清晰、描述性的名称
- 角色: 为团队成员分配适当的角色
- 电子邮件: 使用群组电子邮件来避免因个人电子邮件更改而产生的问题
- Logo: 将Logo托管在可靠的CDN上并使用HTTPS URL
__CAPGO_KEEP_0__
继续从组织中进行如果您正在使用 组织 来规划仪表板和API操作,连接它与 API概览 查看API概览中的实施细节 介绍 查看介绍中的实施细节 API密钥 查看API密钥中的实施细节 设备 查看设备中的实施细节 Bundles for the implementation detail in Bundles.