---
title: "Open a community direct message"
---

> 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.

# Open a community direct message

Path: Nicer API › Community

`POST /community/dm`

URL: `https://api.nicer.travel/community/dm`

Answers the direct-message conversation between the caller and the people in userIds, creating it when it does not exist yet: the same people always get the same conversation, so calling again never makes a second one. Every participant must be an active member of the agency the request acts for. Any member of the agency may call it. Errors: 400 ERROR_BODY_VALIDATION for a conversation with nobody but the caller; 400 ERROR_UNAUTHORIZED for a participant who is not an active member of the agency; 400 ERROR_COMPANY_REQUIRED and 403 ERROR_DO_NOT_HAVE_PERMISSION as on every community route.

## Authentication

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

## Request body

_Required._

- `userIds` (`community.dm.create.userIds`; array of string, required)
  - minLength: `1`

## Example request

```json
{
  "userIds": [
    "string"
  ]
}
```

## 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.community.dm.create({
  "userIds": [
    "string"
  ]
});
```

### Nicer CLI

```bash
nicer community dm create --input - <<'JSON'
{
  "userIds": [
    "string"
  ]
}
JSON
```

### cURL

```bash
curl --request POST \
  --url https://api.nicer.travel/community/dm \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "userIds": [
    "string"
  ]
}
'
```

### TypeScript

```typescript
const url = 'https://api.nicer.travel/community/dm';
const options = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    Authorization: 'Bearer <token>'
  },
  body: JSON.stringify({userIds: ['string']})
};

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/community/dm"

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

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

print(response.text)
```

## Responses

### 200

OK

#### Example

```json
{
  "dmId": "string",
  "companyName": "string",
  "participants": [
    "string"
  ],
  "createdAt": "string"
}
```

- `dmId` (`community.dm.create.response.200.dmId`; string, required) — The conversation's id, the same whenever the same people talk.
- `companyName` (`community.dm.create.response.200.companyName`; string, required) — The agency the conversation belongs to.
- `participants` (`community.dm.create.response.200.participants`; array of string, required) — The userIds of everyone in the conversation, the caller among them.
- `createdAt` (`community.dm.create.response.200.createdAt`; string, required) — When the conversation was created, as ISO 8601 text.

### 400

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

#### Example

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

- `errorCode` (`community.dm.create.response.400.errorCode`; string, required)
- `errorMessage` (`community.dm.create.response.400.errorMessage`; string, required)

### 401

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

#### Example

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

- `errorCode` (`community.dm.create.response.401.errorCode`; string, required)
- `errorMessage` (`community.dm.create.response.401.errorMessage`; string, required)

### 403

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

#### Example

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

- `errorCode` (`community.dm.create.response.403.errorCode`; string, required)
- `errorMessage` (`community.dm.create.response.403.errorMessage`; string, required)


Source: https://docs.nicer.travel/api/Community/community.dm.create/index.md
