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

# 创建虚拟成员

> 创建虚拟成员——一种无需登录的托管身份，会出现在成员名单中、持有角色，且仅通过为其签发的 API Key 进行操作（`POST /api-keys` 并传入 `member_principal_id`）

```
POST /openapi/memorylake/admin/v1/members
```

创建虚拟成员——一种无需登录的托管身份，会出现在成员名单中、持有角色，且仅通过为其签发的 API Key 进行操作（`POST /api-keys` 并传入 `member_principal_id`）。真人成员只能通过邀请加入。

<Note>
  **所需权限：** `member:manage_virtual`

  * 如果改动会让某人获得管理员角色，或会缩小管理员能访问的范围，还需要由团队所有者或管理员操作。
</Note>

### 请求头

<ParamField header="Idempotency-Key" type="string">
  可选。使用相同值重试会重放首次结果。
</ParamField>

### 请求体

<ParamField body="display_name" type="string" required>
  虚拟成员的显示名称
</ParamField>

<ParamField body="role" type="string" required>
  角色：`tenant_admin`、`tenant_member` 或本团队的自定义角色键。无法分配所有者角色。
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST 'https://app.memorylake.cn/openapi/memorylake/admin/v1/members' \
    -H 'Authorization: Bearer sk_xxxxxx' \
    -H 'Idempotency-Key: 7c1d2e3f-0a9b-4c8d-b7e6-f5a4d3c2b1a0' \
    -H 'Content-Type: application/json' \
    -d '{
      "display_name": "Alice",
      "role": "tenant_member"
    }'
  ```
</RequestExample>

### 响应

<ResponseField name="data" type="object">
  <Expandable title="Member 对象">
    <ResponseField name="display_name" type="string">成员的显示名称</ResponseField>
    <ResponseField name="joined_at" type="integer">此成员加入的时间，Unix 秒级时间戳</ResponseField>
    <ResponseField name="member_type" type="string">`human` 表示通过邀请加入，`virtual` 表示由所有者/管理员创建的托管身份</ResponseField>
    <ResponseField name="principal_id" type="string">此成员的稳定标识符</ResponseField>
    <ResponseField name="role" type="string">在本团队中的主角色：`tenant_owner` | `tenant_admin` | `tenant_member` | \<自定义角色></ResponseField>
    <ResponseField name="status" type="string">成员状态。可选值：`active`、`inactive`。</ResponseField>
    <ResponseField name="used_tokens" type="integer">此成员消耗的 tokens</ResponseField>
    <ResponseField name="email" type="string">仅返回给团队所有者和管理员</ResponseField>
    <ResponseField name="max_tokens" type="integer">每位成员的上限，单位 tokens。成员无上限时省略。</ResponseField>
    <ResponseField name="username" type="string">仅返回给团队所有者和管理员</ResponseField>
  </Expandable>
</ResponseField>

<ResponseExample>
  ```json Success (201) theme={null}
  {
    "success": true,
    "message": "Operation completed successfully",
    "data": {
      "display_name": "Alice",
      "joined_at": 1760000000,
      "member_type": "human",
      "principal_id": "42fbbd89934900ebbc74814c49f009d2",
      "role": "tenant_member",
      "status": "active",
      "used_tokens": 1200000,
      "email": "alice@example.com",
      "max_tokens": 1200000,
      "username": "alice"
    }
  }
  ```
</ResponseExample>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.