> For the complete documentation index, see [llms.txt](https://api-docs.everreal.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://api-docs.everreal.co/endpoints/document-management/simple-file-upload.md).

# Simple file upload

This page describes how to upload files, so you can use them later for other purposes.

## Introduction

Use this endpoint to upload files that you want to use later, for example the pictures and floor plans of a [listing](https://api-docs.everreal.co/key-concepts.md#listing). It does not link the file to a [property](https://api-docs.everreal.co/key-concepts.md#property), [unit](https://api-docs.everreal.co/key-concepts.md#unit) or [tenant](https://api-docs.everreal.co/key-concepts.md#tenant). Use it, for example, for:

* the pictures and floor plans of a listing (see [Listing: pictures and files](https://api-docs.everreal.co/endpoints/listing/listing-pictures-and-files.md))
* updating a [user](https://api-docs.everreal.co/key-concepts.md#user-and-member) profile image via API
* submit [candidate](https://api-docs.everreal.co/key-concepts.md#candidate) / applicant information, with files via API (currently only possible with restricted access and not yet documented)

File storage is a separate API. You call it directly, and not through the reporting API.

{% hint style="info" %}
For listing pictures and floor plans, use the link import of the reporting API (`addListingPicturesFromUrls`, `addListingFloorplansFromUrls`). It downloads, uploads and links the files for you. See [Listing: pictures and files](https://api-docs.everreal.co/endpoints/listing/listing-pictures-and-files.md).
{% endhint %}

## Endpoints

#### Upload a file

<mark style="color:green;">`POST`</mark> `https://{custom_subdomain}.everreal.co/api/file-storage/v2/company/files`

#### Query parameters

| Name                                           | Type    | Description                                                         |
| ---------------------------------------------- | ------- | ------------------------------------------------------------------- |
| resourcePath<mark style="color:red;">\*</mark> | String  | The path of the file, for example `listing/{uuid}/images/front.jpg` |
| isPublicRead                                   | Boolean | Default `true`. Keep `true` for listing pictures and floor plans.   |
| name                                           | String  | Override the display name of the file                               |

#### Request body

`multipart/form-data` with the field `file`<mark style="color:red;">\*</mark> (the file).

The answer is `{ name, resourcePath, resourceId, size, type }`. Keep it. You send it to the listing mutation.

The older route `POST https://{custom_subdomain}.everreal.co/api/file-storage/company/files` (with `resourcePath` as a form field) still works. For new code, use the `v2` route above.

#### Rules for `resourcePath`

* `resourcePath` is required. Without it, the upload answers `400` (`filestorage.resourcePath.required`).
* A `resourcePath` that leaves your [company](https://api-docs.everreal.co/key-concepts.md#company) folder (`..`, encoded forms, a backslash, control characters) is refused with `400`.
* A leading, trailing or repeated `/` is cleaned.

{% tabs %}
{% tab title="200: OK " %}

```json
{
  "name": "front.jpg",
  "resourcePath": "example/2f0c6d1a-8b34-4a57-9e10-6c7d3b5a9f21/listing/7d2a9c34-1b8e-4f6a-a3c5-90e1d4b8f255/images/front.jpg",
  "resourceId": "a91d0f3c-6e42-4b8a-b7c5-2d8e1f4a6b90",
  "size": 389417,
  "type": "image/jpeg"
}
```

{% endtab %}

{% tab title="400: Bad Request " %}
`resourcePath` is missing, or it leaves your company folder.
{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}
{% endtabs %}

#### Delete a file

<mark style="color:red;">`DELETE`</mark> `https://{custom_subdomain}.everreal.co/api/file-storage/company/files?resourcePath={uploadedResourcePath}`

{% tabs %}
{% tab title="204: No Content " %}

{% endtab %}

{% tab title="401: Unauthorized " %}

{% endtab %}
{% endtabs %}

#### Create a listing with files

For a working flow, see [Listing Mutation](https://api-docs.everreal.co/endpoints/listing/listing-mutation.md) (create the listing) and [Listing: pictures and files](https://api-docs.everreal.co/endpoints/listing/listing-pictures-and-files.md) (add the pictures and floor plans).

* A listing accepts only `listing/{uuid}/images/{file}` for pictures, and `listing/{uuid}/floorplans/{file}` for floor plans.
* The listing key for floor plans is `floorplans` (all lower case).
* Send `resourceId` and `resourcePath` from the upload answer.
