<span id="添加团队成员"></span>

# Add a team member

```{raw} html
<div class="mo-api-page-show-toc" aria-hidden="true"></div>
```

Add an agent to a team and validate the membership version.


```http
PUT https://api.moi.matrixorigin.cn/v5/workspaces/{workspace_id}/agent-teams/{team_id}/members/{agent_workspace_id}/{agent_id}
```

<span id="调用前准备"></span>

## Before you call this API

Set `BASE_URL` to the product API prefix `https://api.moi.matrixorigin.cn/v5`; use the corresponding product API URL for a dedicated deployment.

[Prepare product identity and object identifiers in the same environment](objects.md#prepare).

<span id="请求"></span>

## Request

:::::::{div} mo-api-tabs
::::::{tab-set}
:::::{tab-item} Request example

```bash
curl --request PUT \
  "$BASE_URL/workspaces/$WORKSPACE_ID/agent-teams/$TEAM_ID/members/$AGENT_WORKSPACE_ID/$AGENT_ID?expected_membership_version=2" \
  --header "X-API-Key: $MOI_KEY" \
  --header "X-Workspace-ID: $WORKSPACE_ID"
```

:::::
:::::{tab-item} Parameters

| Parameter | Location | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `workspace_id` | Path | string | Yes | Current workspace ID; keep the product identity and headers in the same environment. |
| `team_id` | Path | string | Yes | Team ID from the team list or creation response. |
| `agent_workspace_id` | Path | string | Yes | Definition workspace ID of the member agent. |
| `agent_id` | Path | string | Yes | Member agent ID. |
| `expected_membership_version` | Queries | integer | Yes | Current team membership_version, a positive integer. |

List members first and choose a reference not already added. Use membership_version, not team version. Retain the member's definition workspace. Only eligible agents in the current or system workspace are allowed, not arbitrary tenants. Reread the team and members after writing.

:::::
::::::
:::::::

<span id="成功响应"></span>

## Successful response

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} Response example

```json
{
  "code": 0,
  "data": {
    "id": "team-example",
    "workspace_id": "workspace-example",
    "owner_user_id": "user-example",
    "name": "资料整理团队",
    "status": "active",
    "version": 1,
    "membership_version": 3,
    "created_at": "2026-11-12T01:00:00Z",
    "updated_at": "2026-11-12T01:00:00Z",
    "description": "整理与核对资料"
  }
}
```

:::::
:::::{tab-item} Fields

| Field | Type | Description |
| --- | --- | --- |
| `code` | integer | 0 on success. |
| `data` | object | [Corresponding response object](objects.md#responses). |

HTTP 200. Returns the [corresponding object](objects.md#responses). Confirm writes with the corresponding read action.

:::::
::::::
:::::::

<span id="错误响应"></span>

## Error responses

[Errors and concurrency handling](lifecycle.md#errors) distinguishes parameter, version, member/session state, and admission failures.
