跳转到内容

Organizations

组织是 Capgo 中的顶级实体。它们允许您将应用程序、团队成员和资源分组到一个保护伞下。每个组织可以有多个具有不同角色和权限的成员。

  • 为您的公司创建一个新的组织
  • 管理组织设置
  • 更新组织信息
  • 检索组织详细信息

https://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
}
Terminal window
# Get all organizations
curl -H "authorization: your-api-key" https://api.capgo.app/organization/
# Get specific organization
curl -H "authorization: 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/

创建一个新的组织。

interface OrganizationCreate {
name: string
}
Terminal window
curl -X POST \
-H "authorization: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"name": "New Organization"
}' \
https://api.capgo.app/organization/
{
"status": "Organization created",
"id": "org_456"
}

https://api.capgo.app/organization/

更新现有组织。需要管理员角色。

interface OrganizationUpdate {
orgId: string
logo?: string
name?: string
management_email?: string
}
Terminal window
curl -X PUT \
-H "authorization: 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/

删除现有组织。需要管理员角色。此操作不可逆转,并将删除所有关联的应用程序、捆绑包(版本)和资源。

  • orgId:要删除的组织的ID
Terminal window
curl -X DELETE \
-H "authorization: your-api-key" \
https://api.capgo.app/organization/?orgId=org_123
{
"status": "Organization deleted",
"id": "org_123"
}

常见错误场景及其应对措施:

// 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"
}
  1. 命名:为组织使用清晰、描述性的名称
  2. 角色:为团队成员分配适当的角色
  3. 电子邮件:使用群组电子邮件作为management_email,以避免个人电子邮件更改出现问题
  4. 徽标:在可靠的 CDN 上托管徽标并使用 HTTPS URL