---
title: "Send message to agent"
method: POST
path: "/project/{projectId}/agents/messages"
tags: ["Agent"]
---

# Send message to agent

`POST /project/{projectId}/agents/messages`

## Request

- Base URL: `https://api.takeshape.io`
- URL: `https://api.takeshape.io/project/{projectId}/agents/messages`
- Auth: HTTP bearer

Sends a message to an AI agent thread and streams the response using Server-Sent Events (SSE). The response follows the Vercel AI UI message stream format.

## Path parameters

- `projectId` string, uuid, required

## Request body

- CreateMessageBody
  - `messages` UiMessage[], required: Array of UI messages to send to the agent
    - `parts` union[], required: Array of message parts (text, file, tool, or other)
      - union
        - TextUIPart
          - `type` 'text', required
          - `text` string, required: The text content of the message part
        - FileUIPart
          - `type` 'file', required
          - `mediaType` string, required: MIME type of the file
          - `filename` string: Optional filename
          - `url` string, required: Data URL or URL to the file
        - ToolUIPart
          - `type` union, required: The type of tool part
            - string
            - 'dynamic-tool'
          - `toolName` string, required: The name of the tool
          - `toolCallId` string, required: The unique tool call ID
          - `state` 'input-streaming' | 'input-available' | 'output-available' | 'output-error', required: The state of the tool call
          - `input` unknown
          - `output` unknown
        - OtherUIPart
          - `type` string, required: The type of UI part
    - `id` string: Optional message ID
    - `role` 'system' | 'user' | 'assistant', required: The role of the message sender
  - `id` string, required: The thread/session ID
  - `trigger` string: Optional trigger for the message
  - `metadata` ThreadMetadata, required
    - `custom` object, required
      - `inputName` string, required: The name of the input field for the agent

## Response `200`

SSE stream of agent responses

## Other responses

- `400`: Invalid request - missing required message parts
- `401`: Unauthorized - invalid or missing authentication
- `404`: Agent session not found

---

[API](https://skmtc.dev/takeshape/apis/takeshape-rest-api.md) - [All operations](https://skmtc.dev/takeshape/apis/takeshape-rest-api/llms.txt) - [OpenAPI document](https://skmtc.dev/takeshape/apis/takeshape-rest-api/revisions/2e088f4d4c64?raw)
