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

# Publish message

> Send a new message to an existing chat to continue the conversation

Sends a new message to an existing chat, continuing the conversation.

## Request

```
POST /api/chat/{chatId}/publish
```

### Headers

| Header          | Required | Description         |
| --------------- | -------- | ------------------- |
| `Authorization` | Yes      | `Bearer macaly_...` |
| `Content-Type`  | Yes      | `application/json`  |

### Path Parameters

| Parameter | Type   | Description |
| --------- | ------ | ----------- |
| `chatId`  | string | The chat ID |

### Body Parameters

| Field                      | Type                                                             | Required    | Default  | Description                                                          |
| -------------------------- | ---------------------------------------------------------------- | ----------- | -------- | -------------------------------------------------------------------- |
| `content`                  | string                                                           | Conditional | -        | The user's message. Required unless `resume` is `true`               |
| `stream`                   | boolean                                                          | No          | `true`   | If `false`, returns JSON instead of stream                           |
| `agentMode`                | `"auto"` \| `"fast"` \| `"smart"`                                | No          | `"auto"` | Controls the AI agent's speed/quality tradeoff                       |
| `executionMode`            | `"auto"` \| `"planning"` \| `"build"`                            | No          | `"auto"` | Controls how the AI approaches the task                              |
| `model`                    | `"sonnet-4-5"` \| `"sonnet-4-6"` \| `"opus-4-5"` \| `"opus-4-6"` | No          | -        | AI model to use. Defaults to team's configured model                 |
| `reasoningEffort`          | `"medium"` \| `"high"`                                           | No          | -        | Controls how deeply the AI reasons about the task                    |
| `resume`                   | boolean                                                          | No          | `false`  | If `true`, resumes a stopped conversation without adding new content |
| `experimental_attachments` | array                                                            | No          | `[]`     | File attachments (see [Create Chat](/en/api/create-chat) for format) |

<Note>
  When `resume` is `true`, you cannot include `content` or `experimental_attachments`. This is used to continue a conversation that was previously stopped.
</Note>

### Example Request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://www.macaly.com/api/chat/abc123def456/publish" \
    -H "Authorization: Bearer macaly_abc123..." \
    -H "Content-Type: application/json" \
    -d '{
      "content": "Add a dark mode toggle to the header",
      "stream": false
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    `https://www.macaly.com/api/chat/${chatId}/publish`,
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer macaly_abc123...',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        content: 'Add a dark mode toggle to the header',
        stream: false,
      }),
    }
  );

  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      f'https://www.macaly.com/api/chat/{chat_id}/publish',
      headers={
          'Authorization': 'Bearer macaly_abc123...',
          'Content-Type': 'application/json',
      },
      json={
          'content': 'Add a dark mode toggle to the header',
          'stream': False,
      },
  )

  data = response.json()
  ```
</CodeGroup>

## Response

### JSON Response (when `stream: false`)

```json theme={null}
{
  "chatId": "abc123def456",
  "streamId": "stream_xyz789",
  "assistantMessageId": "msg_123"
}
```

You can then poll the [Get Status](/en/api/get-status) endpoint to wait for completion.

### Streaming Response (when `stream: true`, default)

```
2:[{"chatId":"abc123def456"}]
0:"Analyzing your request..."
...
```

## Status Codes

| Status | Description                                                       |
| ------ | ----------------------------------------------------------------- |
| 200    | Success - Message sent                                            |
| 400    | Invalid request body                                              |
| 401    | Invalid or missing API key                                        |
| 402    | Insufficient credits                                              |
| 403    | Chat does not belong to this team                                 |
| 404    | Chat not found                                                    |
| 429    | Rate limited                                                      |
| 500    | Server error                                                      |
| 503    | Service unavailable - The AI workspace is busy, try again shortly |

## Workflow

For non-streaming usage, the typical workflow is:

1. **Send message** with `stream: false`
2. **Poll status** using [`GET /api/chat/{chatId}/status`](/en/api/get-status) until `completed`
3. **Repeat** for additional messages
