---
title: "Upload an itinerary PDF for import"
---

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

# Upload an itinerary PDF for import

Path: Nicer API › Trip itinerary

`POST /trip-itinerary/{tripItineraryId}/documents`

URL: `https://api.nicer.travel/trip-itinerary/{tripItineraryId}/documents`

Starts importing an itinerary PDF: returns a presigned S3 form that the browser posts one PDF of up to 25 MB to. Once it is uploaded, the segments read from the PDF are added to the itinerary (mode merge) or replace its segments (mode replace). Requires the trip's advisor or an admin.

## Authentication

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

## Path parameters

- `tripItineraryId` (`tripItinerary.documents.create.path.tripItineraryId`; string, required)

## Request body

_Required._

- `mode` (`tripItinerary.documents.create.mode`; string, optional)
  - one of `"merge"`, `"replace"` · default: `"merge"`

## Example request

```json
{
  "mode": "merge"
}
```

## 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.tripItinerary.documents.create({
  "tripItineraryId": "string"
});
```

### Nicer CLI

```bash
nicer trip-itinerary documents create --trip-itinerary-id 'string' --input - <<'JSON'
{}
JSON
```

### cURL

```bash
curl --request POST \
  --url 'https://api.nicer.travel/trip-itinerary/<tripItineraryId>/documents' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "mode": "merge"
}
'
```

### TypeScript

```typescript
const url = 'https://api.nicer.travel/trip-itinerary/<tripItineraryId>/documents';
const options = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    Authorization: 'Bearer <token>'
  },
  body: JSON.stringify({mode: 'merge'})
};

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/trip-itinerary/<tripItineraryId>/documents"

payload = { "mode": "merge" }
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

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

print(response.text)
```

## Responses

### 200

OK

#### Example

```json
{
  "key": "string",
  "presignedPost": {
    "url": "string",
    "fields": {
      "property1": "string",
      "property2": "string"
    }
  }
}
```

- `key` (`tripItinerary.documents.create.response.200.key`; string, required)
- `presignedPost` (`tripItinerary.documents.create.response.200.presignedPost`; object, required)
  - `url` (`tripItinerary.documents.create.response.200.presignedPost.url`; string, required) — Where to post the form.
  - `fields` (`tripItinerary.documents.create.response.200.presignedPost.fields`; map of string, required) — The form fields to send, as they are, before the file.

### 400

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

#### Example

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

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

### 401

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

#### Example

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

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

### 403

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

#### Example

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

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


Source: https://docs.nicer.travel/api/Trip-itinerary/tripItinerary.documents.create/index.md
