> 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

## Introduction

Please use this endpoint only if you don't want to automatically link the files to properties, units, tenants. For example this endpoint could be used for:

* creating a listing via API (currently only possible with restricted access and not yet documented)
* updating a user profile image via API
* submit candidate / applicant information, with files via API (currently only possible with restricted access and not yet documented)

## Endpoints

#### Upload a file

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

#### Request Body

| Name                                           | Type      | Description                           |
| ---------------------------------------------- | --------- | ------------------------------------- |
| file<mark style="color:red;">\*</mark>         | Form file | The file                              |
| resourcePath<mark style="color:red;">\*</mark> | String    | The virtual folder path               |
| name                                           | String    | Override the display name of the file |

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

{% endtab %}

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

{% endtab %}
{% endtabs %}

#### Delete a file

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

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

{% endtab %}

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

{% endtab %}
{% endtabs %}

#### Example flow for creating a listing

* upload `image1.jpeg` , `image2.jpeg` , `floorPlan.pdf`&#x20;
* pass the responses to the create listing payload

Step 1 - upload images

```typescript
// Do this for every image
const myHeaders = new Headers();
myHeaders.append('Accept', 'application/json');
myHeaders.append(
  'Authorization',
  'Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIwZTY1Y2ViYi1lNDI4LTQ4YTktOTY4MS03NmRkYTM0ZDIyOTkiLCJzdWIiOiJkNWY4ZmI5My1kYTIxLTQwNTktYjhjOC0wN2M0MjE0OTczMTkiLCJleHAiOjE2ODUwMTAyMjEsImlhdCI6MTY4NTAwNjYyMX0.byF0tReLQOYRXwvgssQG1HFfrxWOPm1WdA4ZcLyJMX6LDxg586pjebiyBtE7cJvFAHhDxIdXGlp6LLDs-HaGmk10H-HMmRdLG4gHzs-QRz4goQIVgUv3kikG5YseXMgqmRCssXtBVbo-XjS_bHFSLkMV5zNESByliYLFJReXXpQTC_LP3PUdA7qvnL4PZAwbcoa6aPKyPtuur9gCXvcVDgvFdzQQ5WMnr9u0CiXMeqk3ybAMUTD9RdXYBpTDoJChemFDq0E1-GYDBbC-WuwOsw5sYPokCjuD-7ARsm6UaBxNExJWYUz5erpVhewNZHiGhOyUqARomV8QcbatiL-RNw',
);

const formdata = new FormData();
formdata.append('file', fileInput, { filename: 'Living Room', contentType: 'image/png' });
formdata.append('resourcePath', 'listings/117ff3a1-6f1b-4da8-a3da-208d2e6f5ac4/pictures');
formdata.append('name', 'Floor plans');

const requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: formdata,
  redirect: 'follow',
};

fetch('https://{subdomain}.everreal.co/api/file-storage/company/files', requestOptions)
  .then((response) => response.json())
  .then((result) => console.log(result))
  .catch((error) => console.log('error', error));
```

Response will be something like

```json
{
    "name": "Floor plans",
    "resourcePath": "subdomain/116aeae1-615a-11e7-97db-257f422c12345/listings/117ff3a1-6f1b-4da8-a3da-208d2e6f5ac4/pictures",
    "size": 389417,
    "type": "image/png"
}
```

Step 2 - pass payload during create listing

```typescript
const body = {
   /// other data
   pictures: [{
      ...responsePicture1,
      order: 0,
   }, {
      ...responsePicture2,
      order: 1,
   }],
   floorPlans: [{
      ...responseFloorPlanPdf,
      order: 0
   }]
};

const requestOptions = {
  method: 'POST',
  headers: {....},
  body
};

fetch('https://{subdomain}.everreal.co/api/create-listing-endpoint', requestOptions)
  .then((response) => response.json())
  .then((result) => console.log(result))
  .catch((error) => console.log('error', error));
```
