---
title: "Post a message to a chat"
---

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

# Post a message to a chat

Path: Nicer API › Chat

`POST /chat/{chatId}/reply`

URL: `https://api.nicer.travel/chat/{chatId}/reply`

Appends a message, text and/or attachment URLs, to the chat, updates the channel's last-message time and the author's read mark, and emits a conversation-created event. Requires message text or at least one asset; assets must be reachable HTTPS URLs and text is capped at 10,000 characters. Returns the stored row with HTML stripped from the plain text and a rendered HTML copy.

## Authentication

- `bearerAuth`, http bearer, header `Authorization`, format `JWT`

## Path parameters

- `chatId` (`chat.reply.path.chatId`; string, required)

## Request body

_Required._

- `assetsUrls` (`chat.reply.assetsUrls`; array of string, optional)
- `message` (`chat.reply.message`; string, optional)
- `needsAiResponse` (`chat.reply.needsAiResponse`; boolean, optional)

## Example request

```json
{
  "assetsUrls": [
    "string"
  ],
  "message": "string",
  "needsAiResponse": true
}
```

## Code samples

### JavaScript SDK

```javascript
import { createClient } from "@nicertravel/sdk";

const nicer = createClient({
  baseUrl: "https://api.nicer.travel",
  token: process.env.NICER_TOKEN,
});

await nicer.chat.reply({
  "chatId": "string"
});
```

### Nicer CLI

```bash
nicer chat reply --chat-id 'string' --input - <<'JSON'
{}
JSON
```

### cURL

```bash
curl --request POST \
  --url 'https://api.nicer.travel/chat/<chatId>/reply' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "assetsUrls": [
    "string"
  ],
  "message": "string",
  "needsAiResponse": true
}
'
```

### TypeScript

```typescript
const url = 'https://api.nicer.travel/chat/<chatId>/reply';
const options = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    Authorization: 'Bearer <token>'
  },
  body: JSON.stringify({assetsUrls: ['string'], message: 'string', needsAiResponse: true})
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.nicer.travel/chat/<chatId>/reply"

payload = {
    "assetsUrls": ["string"],
    "message": "string",
    "needsAiResponse": True
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 200

OK

#### Example

```json
{
  "attachmentUrls": [
    "string"
  ],
  "authorId": "string",
  "chatId": "string",
  "createdBy": "string",
  "lastModifiedBy": "string",
  "message": "string",
  "messageHtml": "string",
  "needsAiResponse": true,
  "conversationId": "string",
  "createdAt": "string",
  "updatedAt": "string",
  "type": "ChatConversation"
}
```

- `attachmentUrls` (`chat.reply.response.200.attachmentUrls`; array of string, required)
- `authorId` (`chat.reply.response.200.authorId`; string, required)
- `chatId` (`chat.reply.response.200.chatId`; string, required)
- `createdBy` (`chat.reply.response.200.createdBy`; string, required)
- `lastModifiedBy` (`chat.reply.response.200.lastModifiedBy`; string, required)
- `message` (`chat.reply.response.200.message`; string, required)
- `conversationId` (`chat.reply.response.200.conversationId`; string, required)
- `createdAt` (`chat.reply.response.200.createdAt`; string, required)
- `updatedAt` (`chat.reply.response.200.updatedAt`; string, required)
- `type` (`chat.reply.response.200.type`; string, required)
- `messageHtml` (`chat.reply.response.200.messageHtml`; string, optional) — The text as HTML.
- `needsAiResponse` (`chat.reply.response.200.needsAiResponse`; boolean, optional)

### 400

Request failed. `errorCode` is stable; `errorMessage` is for humans.

#### Example

```json
{
  "errorCode": "string",
  "errorMessage": "string"
}
```

- `errorCode` (`chat.reply.response.400.errorCode`; string, required)
- `errorMessage` (`chat.reply.response.400.errorMessage`; string, required)

### 401

Request failed. `errorCode` is stable; `errorMessage` is for humans.

#### Example

```json
{
  "errorCode": "string",
  "errorMessage": "string"
}
```

- `errorCode` (`chat.reply.response.401.errorCode`; string, required)
- `errorMessage` (`chat.reply.response.401.errorMessage`; string, required)

### 403

Request failed. `errorCode` is stable; `errorMessage` is for humans.

#### Example

```json
{
  "errorCode": "string",
  "errorMessage": "string"
}
```

- `errorCode` (`chat.reply.response.403.errorCode`; string, required)
- `errorMessage` (`chat.reply.response.403.errorMessage`; string, required)


Source: https://docs.nicer.travel/api/Chat/chat.reply/index.md
