> For the complete documentation index, see [llms.txt](https://beprepared.gitbook.io/beprepared/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://beprepared.gitbook.io/beprepared/files.md).

# Files

Upload files and documents into your client vaults.

Programmatically uploading documents and files to your clients vault on their behalf is one of the best ways to help your clients.

### <mark style="background-color:blue;">The File Object</mark>

The file object has the following attributes

<details>

<summary>The File Object</summary>

```javascript
{
    "id": "file_8f8174a5-49ee-46d4-bb08-00e635f16c44",
    "extension": "png",
    "alwaysAvailable": false,
    "fileSize": "104662",
    "fileName": "gh_white",
    "createdAt": "2022-08-11T03:35:51.328Z",
    "updatedAt": "2022-08-11T03:35:51.328Z"
}
```

**id** *<mark style="color:orange;">string</mark>*

Unique identifier of the object

**fileName** *<mark style="color:orange;">string</mark>*

The name of the uploaded file.

**extension** *<mark style="color:orange;">string</mark>*

The extension of the uploaded file.

**fileSize** *<mark style="color:orange;">string</mark>*

The size of the file in bytes.

**alwaysAvailable** *<mark style="color:blue;">boolean</mark>*

Indicates whether the file is available before death (true) or only after death (false). Default = false.

**createdAt** *<mark style="color:green;">timestamp</mark>*

A timestamp of when the file was created as UTC time.

**updatedAt** *<mark style="color:green;">timestamp</mark>*

A timestamp of when this file object was last updated as UTC time.

</details>

### <mark style="background-color:blue;">Upload a File</mark>

This route will encrypt and upload a file into your clients vault on their behalf. Your client does not need to have activated their vault yet in order for you to begin uploading files.

{% hint style="info" %}
Note: This endpoint only accepts the content type of “multipart/form-data”
{% endhint %}

#### Code Example

{% tabs %}
{% tab title="Node.js" %}

```javascript
import axios from 'axios'

axios.post('YOUR_API_URL/v1/clients/:clientId/files',
    headers: {
      'Authorization': 'Bearer API_KEY'
    }, file)
  .then(res => {
    console.log(res);
  }).catch(err => {
    console.log(err);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = 'YOUR_API_URL/v1/clients/:clientId/files'
headers = {'Authorization': 'Bearer API_KEY'}

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

if response.status_code == 200:
    print(response.json())
else:
    print(f'Error: {response.status_code}')

```

{% endtab %}

{% tab title="cURL" %}
{% code overflow="wrap" %}

```bash
curl -X POST -H "Authorization: Bearer API_KEY" -H "Content-Type: application/json" -d file "YOUR_API_URL/v1/clients/:clientId/files"

```

{% endcode %}
{% endtab %}
{% endtabs %}

#### Request Details

## Uploads a file into a client’s vault

<mark style="color:green;">`POST`</mark> `YOUR_API_URL/v1/clients/:clientId/files`

This endpoint only accepts the content type of “multipart/form-data”

#### Headers

| Name                                            | Type   | Description        |
| ----------------------------------------------- | ------ | ------------------ |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer \<API\_KEY> |

#### Request Body

| Name | Type      | Description |
| ---- | --------- | ----------- |
| file | form-data | FILE\_BLOB  |

{% tabs %}
{% tab title="200: OK Returns a File in the file property." %}

```javascript
{
    "file": {
        "id": "file_8f8174a5-49ee-46d4-bb08-00e635f16c44",
        "extension": "png",
        "alwaysAvailable": false,
        "fileSize": "104662",
        "fileName": "gh_white",
        "createdAt": "2022-08-11T03:35:51.328Z",
        "updatedAt": "2022-08-11T03:35:51.328Z"
    }
}
```

{% endtab %}
{% endtabs %}
