---
title: "Archive or unarchive 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.

# Archive or unarchive a chat

Path: Nicer API › Chat

`POST /chat/{chatId}/toggle-archive`

URL: `https://api.nicer.travel/chat/{chatId}/toggle-archive`

Sets the caller's own archive flag: on a trip chat it updates the caller's trip membership row, on a direct chat it adds or removes the caller in the archived-by set. Other participants are unaffected. The caller must be a participant. Echoes the requested state back.

## Authentication

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

## Path parameters

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

## Request body

_Required._

- `isArchived` (`chat.toggleArchive.isArchived`; boolean, required)

## Example request

```json
{
  "isArchived": 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.toggleArchive({
  "chatId": "string",
  "isArchived": true
});
```

### Nicer CLI

```bash
nicer chat toggle-archive --chat-id 'string' --input - <<'JSON'
{
  "isArchived": true
}
JSON
```

### cURL

```bash
curl --request POST \
  --url 'https://api.nicer.travel/chat/<chatId>/toggle-archive' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "isArchived": true
}
'
```

### TypeScript

```typescript
const url = 'https://api.nicer.travel/chat/<chatId>/toggle-archive';
const options = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    Authorization: 'Bearer <token>'
  },
  body: JSON.stringify({isArchived: 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>/toggle-archive"

payload = { "isArchived": 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
{
  "isArchived": true
}
```

- `isArchived` (`chat.toggleArchive.response.200.isArchived`; boolean, required)

### 400

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

#### Example

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

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

### 401

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

#### Example

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

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

### 403

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

#### Example

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

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


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