---
title: "Create a private downloadable document"
---

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

# Create a private downloadable document

Path: Nicer API › Assistant

`POST /agent/documents`

URL: `https://api.nicer.travel/agent/documents`

Renders the given content as a PDF, Markdown, text or CSV file in the caller's private document storage and returns its name, key and media type. Only the caller can open it, through `POST /agent/documents/download`. Any signed-in person may call it.

## Authentication

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

## Request body

_Required._

- `name` (`agent.documents.create.name`; string, required)
  - maxLength: `120` · minLength: `1`
- `content` (`agent.documents.create.content`; string, required)
  - maxLength: `100000` · minLength: `1`
- `format` (`agent.documents.create.format`; string, required)
  - one of `"pdf"`, `"markdown"`, `"text"`, `"csv"`

## Example request

```json
{
  "name": "string",
  "content": "string",
  "format": "pdf"
}
```

## 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.agent.documents.create({
  "name": "string",
  "content": "string",
  "format": "pdf"
});
```

### Nicer CLI

```bash
nicer agent documents create --input - <<'JSON'
{
  "name": "string",
  "content": "string",
  "format": "pdf"
}
JSON
```

### cURL

```bash
curl --request POST \
  --url https://api.nicer.travel/agent/documents \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "string",
  "content": "string",
  "format": "pdf"
}
'
```

### TypeScript

```typescript
const url = 'https://api.nicer.travel/agent/documents';
const options = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    Authorization: 'Bearer <token>'
  },
  body: JSON.stringify({name: 'string', content: 'string', format: 'pdf'})
};

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/agent/documents"

payload = {
    "name": "string",
    "content": "string",
    "format": "pdf"
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

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

print(response.text)
```

## Responses

### 200

OK

#### Example

```json
{
  "documents": [
    {
      "name": "string",
      "mediaType": "application/pdf",
      "key": "string"
    }
  ]
}
```

- `documents` (`agent.documents.create.response.200.documents`; array of object, required)
  - `name` (`agent.documents.create.response.200.documents.name`; string, required)
    - maxLength: `160` · minLength: `1`
  - `mediaType` (`agent.documents.create.response.200.documents.mediaType`; string, required)
    - one of `"application/pdf"`, `"application/vnd.openxmlformats-officedocument.wordprocessingml.document"`, `"text/plain"`, `"text/markdown"`, `"text/csv"`, `"text/html"`, `"image/png"`, `"image/jpeg"`
  - `key` (`agent.documents.create.response.200.documents.key`; string, required)
    - maxLength: `512` · minLength: `1` · pattern: `^agentAttachment\/[^/]+\/[^/]+\/[^/]+$`

### 400

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

#### Example

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

- `errorCode` (`agent.documents.create.response.400.errorCode`; string, required)
- `errorMessage` (`agent.documents.create.response.400.errorMessage`; string, required)

### 401

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

#### Example

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

- `errorCode` (`agent.documents.create.response.401.errorCode`; string, required)
- `errorMessage` (`agent.documents.create.response.401.errorMessage`; string, required)

### 403

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

#### Example

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

- `errorCode` (`agent.documents.create.response.403.errorCode`; string, required)
- `errorMessage` (`agent.documents.create.response.403.errorMessage`; string, required)


Source: https://docs.nicer.travel/api/Assistant/agent.documents.create/index.md
