---
title: "Get a file upload form"
---

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

# Get a file upload form

Path: Nicer API › assets

`POST /assets/create-put-url`

URL: `https://api.nicer.travel/assets/create-put-url`

Returns a form to upload one file of the given asset type and media type straight to storage: the presigned POST (its url and the fields to send with the file, valid for an hour), the key the file will have and, for a public type, the URL it will be served at; the metadata sent comes back in the answer too. Itinerary types need a tripItineraryId the caller may edit. Any signed-in person may call it. Errors: 400 ERROR_ASSET_INVALID_TYPE for an asset type that cannot be uploaded this way; 400 ERROR_ASSET_INVALID_MEDIA_TYPE for a media type the asset type does not take.

## Authentication

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

## 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.assets.createPutUrl();
```

### Nicer CLI

```bash
nicer assets create-put-url
```

### cURL

```bash
curl --request POST \
  --url https://api.nicer.travel/assets/create-put-url \
  --header 'Authorization: Bearer <token>'
```

### TypeScript

```typescript
const url = 'https://api.nicer.travel/assets/create-put-url';
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

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/assets/create-put-url"

headers = {"Authorization": "Bearer <token>"}

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

print(response.text)
```

## Responses

### 200

OK

#### Example

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

- `key` (`assets.createPutUrl.response.200.key`; string, required) — The key the file will have in storage.
- `presignedPost` (`assets.createPutUrl.response.200.presignedPost`; object, required) — The form to post the file with, valid for an hour.
  - `url` (`assets.createPutUrl.response.200.presignedPost.url`; string, required) — Where to post the form.
  - `fields` (`assets.createPutUrl.response.200.presignedPost.fields`; map of string, required) — The form fields to send, as they are, before the file.
- `assetUrl` (`assets.createPutUrl.response.200.assetUrl`; string, optional) — The URL the file will be served at, for a public asset type; absent for a private one.
- `fileName` (`assets.createPutUrl.response.200.fileName`; string, optional) — metadata.fileName, when the request sent one.

### 400

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

#### Example

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

- `errorCode` (`assets.createPutUrl.response.400.errorCode`; string, required)
- `errorMessage` (`assets.createPutUrl.response.400.errorMessage`; string, required)

### 401

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

#### Example

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

- `errorCode` (`assets.createPutUrl.response.401.errorCode`; string, required)
- `errorMessage` (`assets.createPutUrl.response.401.errorMessage`; string, required)

### 403

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

#### Example

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

- `errorCode` (`assets.createPutUrl.response.403.errorCode`; string, required)
- `errorMessage` (`assets.createPutUrl.response.403.errorMessage`; string, required)


Source: https://docs.nicer.travel/api/assets/assets.createPutUrl/index.md
