---
title: v1: Upload a file to a directory (POST /public-api/directory/{directory_id}/upload/{filename}) | HelpRange API
description: POST /public-api/directory/{directory_id}/upload/{filename}: Uploads a file (multipart &quot;file&quot;) under the given name.
url: https://www.helprange.com/developers/api/v1-upload-file
---

POST

# v1: Upload a file to a directory

`https://www.helprange.com/public-api/directory/{directory_id}/upload/{filename}`

Uploads a file (multipart "file") under the given name. Uploading again with the same name replaces the file. 100 MB per file. A refused upload answers {"result": "failure", "reason": …} – 400 (too large, bad name), 429 (daily upload limit), 500 (our side).

**Plans:** Pro, Max, Unlimited, Deal Room Pass, trial. **Auth:** the API key in `Authorization` (bare, or `Bearer hr_live_…`) (v1). **Scope:** `documents:write`. **Operation id:** `v1UploadFile`

## Parameters

| Name | In | Type | Description |
|---|---|---|---|
| `directory_id` required | path | integer | Folder id. (min 1) |
| `filename` required | path | string | File name: letters, digits, "-", "_" and ".". |

**Header** `Idempotency-Key` (optional, up to 255 characters): retry with the same key and body within 24 hours and you get the first response back (`Idempotent-Replayed: true`) – the request is not run twice. Another body: `422 idempotency_key_reused`; still running: `409 idempotency_key_in_progress`. [More](https://www.helprange.com/developers/api#idempotency).

## Request body

multipart/form-data with the file. Content types: `multipart/form-data`.

| Field | Type | Description |
|---|---|---|
| `file` required | string |  |

## Example request

```
curl -X POST https://www.helprange.com/public-api/directory/38/upload/proposal.pdf \
  -H "Authorization: $HELPRANGE_API_KEY" \
  -F 'file=@proposal.pdf'
```

```
import { openAsBlob } from 'node:fs';  // Node 20+; in a browser use a file input

const form = new FormData();
form.append('file', await openAsBlob('proposal.pdf'), 'proposal.pdf');

const res = await fetch('https://www.helprange.com/public-api/directory/38/upload/proposal.pdf', {
  method: 'POST',
  headers: {'Authorization': process.env.HELPRANGE_API_KEY},
  body: form,
});
const data = await res.json();
if (!res.ok) throw new Error(`${res.status}: ${data.error || data.message || data.reason}`);
console.log(data);
```

```
import os

import requests

with open('proposal.pdf', 'rb') as f:
    r = requests.post(
        'https://www.helprange.com/public-api/directory/38/upload/proposal.pdf',
        headers={'Authorization': os.environ['HELPRANGE_API_KEY']},
        files={'file': f},
        timeout=60,
    )
r.raise_for_status()
print(r.json())
```

The samples read the key from the `HELPRANGE_API_KEY` environment variable.

## Responses

| Status | Description |
|---|---|
| `200` | OK |
| `400` | Invalid input – the message says which parameter. |
| `401` | Missing or invalid API key / OAuth token. Team keys: code invalid_key, key_revoked, key_expired or key_owner_removed. |
| `402` | Your plan does not include the REST API (the Free plan) or this feature (e.g. NDA needs Max). |
| `403` | v1: the key is invalid, or the folder / file / guest / data room is not yours (HTML page unless you send Accept: application/json). Team keys (v1 and v2): code insufficient_scope with required_scope – the key lacks the scope this endpoint needs. |
| `409` | The data room is frozen, the signed PDF is not ready yet, (webhooks) the team already has an endpoint / the endpoint is turned off, or (code idempotency_key_in_progress) a request with the same Idempotency-Key is still running – retry in a few seconds. |
| `422` | code idempotency_key_reused: this Idempotency-Key was already used in the last 24 hours with a different request (method, path or body). Use a new key for a new request. |
| `429` | A usage limit was reached – wait Retry-After seconds. |
| `500` | Upload failed on our side. |

Example response · 200

```
{
  "id": 260,
  "default_link": "/view/8956d1e7b91b47e196a8040b1d4894f8"
}
```

## Try it

**Uses your real account.** The request goes from your browser straight to `www.helprange.com` with your API key and acts as you – this POST **changes data**. The key stays in this page (in this tab's session storage only if you tick the box), is never put in a URL and is not sent to analytics. Do not paste a key on a shared computer.
 API key

  Remember in this tab

directory_id (path, required)

filename (path, required)  File

```

```
