# Submit a team message

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

Submit one message turn to a team conversation and obtain a task identifier.


```http
POST https://api.moi.matrixorigin.cn/v5/workspaces/{workspace_id}/agent-teams/{team_id}/sessions/{context_id}/messages
```

## Before you call this API

Set `BASE_URL` to the product API prefix `https://api.moi.matrixorigin.cn/v5`. For private deployments, use the corresponding product API URL.

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

## Request

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

```bash
curl --request POST \
  "$BASE_URL/workspaces/$WORKSPACE_ID/agent-teams/$TEAM_ID/sessions/$CONTEXT_ID/messages" \
  --header "X-API-Key: $MOI_KEY" \
  --header "X-Workspace-ID: $WORKSPACE_ID" \
  --header "Content-Type: application/json" \
  --data '{"message_id":"message-example","parts":[{"kind":"text","text":"整理资料"}],"requested_member":{"agent_workspace_id":"workspace-example","agent_id":"agent-example"},"idempotency_key":"team-turn-example"}'
```

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

| Parameter | Location | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `workspace_id` | Path | string | Yes | Current Workspace ID, consistent with the product identity and request headers in the same environment. |
| `team_id` | Path | string | Yes | Team ID from the team list or creation response. |
| `context_id` | Path | string | Yes | Team conversation ID from creation or the list. |
| `message_id` | Body | string | Yes | Nonempty message identifier with no surrounding whitespace. |
| `parts` | Body | array (message parts) | Yes | Nonempty array; see the [Text part](objects.md#parts) example. |
| `requested_member` | Body | object | No | Explicitly selected member reference. |
| `idempotency_key` | Body | string | Yes | Unique key for this submission. Retain it on retries; use a new key for new content. |
| `metadata` | Body | object | No | Business metadata. Runtime-reserved keys cannot be supplied. |

202 means accepted. Save task_id and read the final state through [Confirm task results](lifecycle.md#task). selection is the frozen choice for this turn, not an answer. requested_member must be a currently valid member; if omitted, selection depends on members/the selector.

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

## Successful response

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

```json
{
  "code": 0,
  "data": {
    "task_id": "task-example",
    "selection": {
      "member": {
        "agent_workspace_id": "workspace-example",
        "agent_id": "agent-example"
      },
      "reason": "explicit",
      "membership_version": 2,
      "snapshot": {
        "strategy": "explicit"
      }
    }
  }
}
```

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

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

HTTP202. Returns the [corresponding object](objects.md#responses); confirm writes with the corresponding read operation.

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

## Error responses

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