---
title: Create a share link (POST /api/v2/files/{file_id}/links) | HelpRange API
description: POST /api/v2/files/{file_id}/links: A new tracked share link for a document with its own settings.
url: https://www.helprange.com/developers/api/create-link
---

POST

# Create a share link

`https://www.helprange.com/api/v2/files/{file_id}/links`

A new tracked share link for a document with its own settings. A setting your plan does not include is refused with the plan that has it. Counts towards the daily cap of 2,000 links created through the API.

**Plans:** Pro, Max, Unlimited, Deal Room Pass, trial. **Auth:** `Authorization: Bearer hr_live_…` (team key), `X-API-Key`, `Authorization: Api-Key <key>` or an OAuth `Bearer` token. **Scope:** `links:write`. **Operation id:** `createLink`

## Parameters

| Name | In | Type | Description |
|---|---|---|---|
| `file_id` required | path | integer | Document id (from List documents). (min 1) |

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

Content types: `application/json`, `application/x-www-form-urlencoded`.

| Field | Type | Description |
|---|---|---|
| `label` | string | Who the link is for, e.g. "ACME - Anna" (shown in statistics). Unique per document: a label the document already has is refused with 400. Default: a label with the date and time. |
| `allow_download` | boolean or integer or string | Allow download & print. Default: blocked on Pro and up, allowed on Free. true / false (also 1 / 0 or "true" / "false"). |
| `passcode` | string | Password the viewer must enter (Pro and higher). Surrounding spaces are dropped; only spaces = no passcode. At most 30 characters. |
| `expires_on` | string (date) | Last day the link works, YYYY-MM-DD (Pro and higher). Today or later – a day in the past or an unreadable date is refused with 400. |
| `views_limit` | integer or null | Maximum number of views. 0, null or empty = no limit; a negative or non-whole number is refused with 400. (min 0) |
| `watermark` | boolean or integer or string | Watermark pages with the viewer's e-mail and date (Pro and higher). true / false (also 1 / 0 or "true" / "false"). |
| `require_email` | boolean or integer or string | Ask for the viewer's e-mail before opening (Pro and higher). true / false (also 1 / 0 or "true" / "false"). |
| `disallow_forwarding` | boolean or integer or string | Only the first person who opens it can use it. true / false (also 1 / 0 or "true" / "false"). |
| `one_viewer_at_a_time` | boolean or integer or string | Only one person can view at the same time. true / false (also 1 / 0 or "true" / "false"). |

## Example request

```
curl -X POST https://www.helprange.com/api/v2/files/250/links \
  -H "X-API-Key: $HELPRANGE_API_KEY" \
  -H 'Content-Type: application/json' \
  --data-binary '{"label": "ACME - Anna", "passcode": "oak-41", "expires_on": "2026-12-31", "watermark": true, "require_email": true}'
```

```
const res = await fetch('https://www.helprange.com/api/v2/files/250/links', {
  method: 'POST',
  headers: {'X-API-Key': process.env.HELPRANGE_API_KEY, 'Content-Type': 'application/json'},
  body: JSON.stringify({
    "label": "ACME - Anna",
    "passcode": "oak-41",
    "expires_on": "2026-12-31",
    "watermark": true,
    "require_email": true
  }),
});
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

r = requests.post(
    'https://www.helprange.com/api/v2/files/250/links',
    headers={'X-API-Key': os.environ['HELPRANGE_API_KEY']},
    json={
        "label": "ACME - Anna",
        "passcode": "oak-41",
        "expires_on": "2026-12-31",
        "watermark": True,
        "require_email": True,
    },
    timeout=60,
)
r.raise_for_status()
print(r.json())
```

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

## Responses

| Status | Description |
|---|---|
| `201` | Created |
| `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` | The team API key lacks the scope this endpoint needs. |
| `404` | Not found – or not yours (the API never says which). |
| `405` | Wrong HTTP method for this endpoint. |
| `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. |

Example response · 201

```
{
  "id": 264,
  "url": "https://www.helprange.com/view/8956d1e7b91b47e196a8040b1d4894f8/proposal.pdf",
  "label": "ACME - Anna",
  "allow_download": false,
  "passcode": true,
  "expires_on": "2026-12-31",
  "views_limit": null,
  "watermark": true,
  "require_email": true,
  "disallow_forwarding": false,
  "one_viewer_at_a_time": false,
  "document_id": 250,
  "document": "proposal.pdf"
}
```

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

file_id (path, required)  JSON body { "label": "ACME - Anna", "passcode": "oak-41", "expires_on": "2026-12-31", "watermark": true, "require_email": true }

```

```
