> ## Documentation Index
> Fetch the complete documentation index at: https://docs.devinenterprise.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 快速开始：Teams

> 以团队或标准组织用户身份开始使用 Devin API

本指南将引导你为 **团队和标准组织** (非 Enterprise) 设置 API 访问权限。你将创建一个服务用户、获取凭证，并在几分钟内完成首次 API 调用。

<Note>
  如果你所在的是具有多个组织、自定义角色或 SSO 的 Enterprise 环境，请参阅 [Enterprise 快速开始](/zh/api-reference/getting-started/enterprise-quickstart)。
</Note>

<div id="step-1-create-a-service-user">
  ## 步骤 1：创建服务用户
</div>

1. 在你的组织中，进入 **Settings > Service users**
2. 点击 **Create service user**
3. 选择一个具有描述性的名称 (例如："CI Pipeline"、"Monitoring Bot")
4. 选择一个角色：
   * **Admin** — 对会话、Knowledge、playbooks、secrets 和设置拥有完整管理权限
   * **Member** — 可以创建和管理 Devin 会话，并查看资源

<Tip>
  对于大多数自动化场景，请使用 **Member** 角色。仅当你的集成需要管理组织设置或其他用户时，才使用 **Admin**。
</Tip>

<div id="step-2-generate-an-api-key">
  ## 步骤 2：生成 API key
</div>

1. 创建服务用户后，点击 **Generate API key**
2. 请立即复制该 API key —— 它以 `cog_` 开头，之后将不再显示
3. 将其以环境变量的形式安全保存：

```bash theme={null}
export DEVIN_API_KEY="cog_your_key_here"
```

<div id="step-3-make-your-first-api-call">
  ## 步骤 3：发起首次 API 调用
</div>

创建一个 Devin 会话：

```bash theme={null}
export DEVIN_ORG_ID="your_org_id"

curl -X POST "https://api.devin.ai/v3/organizations/$DEVIN_ORG_ID/sessions" \
  -H "Authorization: Bearer $DEVIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "Create a simple Python script that prints Hello World"}'
```

<Tip>
  你可以在 **Settings → Service Users** 页面中找到组织 ID。
</Tip>

<Note>
  **想让会话归属到你的用户吗？** 默认情况下，会话会归属到服务用户。要代表特定用户创建会话 (这样它们会显示在该用户的会话列表中) ，请在请求体中添加 `"create_as_user_id": "user_abc123"`。这需要 **Admin** 角色 (其中包含 `ImpersonateOrgSessions` 权限) 。详情参见 [Session attribution](/zh/api-reference/overview#session-attribution)。
</Note>

<div id="step-4-common-operations">
  ## 第 4 步：常用操作
</div>

<div id="list-your-sessions">
  ### 列出会话
</div>

```bash theme={null}
curl "https://api.devin.ai/v3/organizations/$DEVIN_ORG_ID/sessions" \
  -H "Authorization: Bearer $DEVIN_API_KEY"
```

<div id="send-a-message-to-a-running-session">
  ### 向运行中的会话发送消息
</div>

```bash theme={null}
export SESSION_ID="your_session_id"

curl -X POST "https://api.devin.ai/v3/organizations/$DEVIN_ORG_ID/sessions/$SESSION_ID/messages" \
  -H "Authorization: Bearer $DEVIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"message": "Please also add unit tests"}'
```

<div id="manage-knowledge">
  ### 管理 Knowledge
</div>

```bash theme={null}
# 列出 Knowledge 条目
curl "https://api.devin.ai/v3/organizations/$DEVIN_ORG_ID/knowledge/notes" \
  -H "Authorization: Bearer $DEVIN_API_KEY"

# 创建 Knowledge 条目
curl -X POST "https://api.devin.ai/v3/organizations/$DEVIN_ORG_ID/knowledge/notes" \
  -H "Authorization: Bearer $DEVIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Coding standards", "trigger_description": "When writing code", "body": "Use TypeScript strict mode..."}'
```

<div id="permissions-for-teams-users">
  ## Teams 用户权限
</div>

Teams 组织采用简单的权限模型：

| 角色         | 是否可以创建会话 | 是否可以管理资源              | 是否可以管理设置 |
| ---------- | -------- | --------------------- | -------- |
| **Member** | 是        | 是 (Knowledge、运行手册、密钥) | 否        |
| **Admin**  | 是        | 是                     | 是        |

如需基于角色的细粒度访问控制 (RBAC) ，请参阅 [Enterprise 快速入门](/zh/api-reference/getting-started/enterprise-quickstart)。

<div id="next-steps">
  ## 后续步骤
</div>

* 在侧边栏中浏览 **Organization API** 端点
* 查看[常见流程](/zh/api-reference/common-flows)，了解常见集成模式
* 深入了解[身份验证](/zh/api-reference/authentication)
* 为周期性任务设置[计划会话](/zh/api-reference/v3/schedules/organizations-schedules)
