# Share links (/docs/concepts/share-links)

> Give anyone a public, expiring link to a rendered document, without an account or an API key.

A share link is a public, unguessable URL for one rendered document. Whoever has it can open the file in a browser, with no Druckling account and no API key, until the link expires or you revoke it. Use share links to send an invoice to a customer, or to let someone outside your workspace review a contract.

Every rendered document already has a signed download [`url`](/docs/concepts/documents#download-the-file). A share link is the better choice when a person, not your code, opens the file:

|  | Signed `url` | Share link |
| --- | --- | --- |
| Lifetime | Up to 7 days | 1 to 30 days, 7 by default |
| Revocable | No | Yes, effective immediately |
| Shown | On every read of the document | Once, when you create it |
| File name | The link's path ends in the document ID | Served under the document's `filename` |

Both stop working when the document's file is deleted at the end of [retention](/docs/concepts/documents#retention).

<Callout type="info" title="REST only for now">

The SDKs don't cover share links yet. Call the endpoints below directly with the same API key.

</Callout>

## Create a share link [#create-a-share-link]

Send [`POST /v1/documents/{id}/share_links`](/docs/api-reference/share-links/create) with an optional `expires_in_days`, a whole number from 1 to 30 (default 7):

```bash
curl https://druckling-nine.vercel.app/v1/documents/pdf_8Qw2kLm3nP0aB1cD/share_links \
  -H "Authorization: Bearer $DRUCKLING_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "expires_in_days": 14 }'
```

The answer is `201 Created` with the link:

```json title="Response"
{
  "id": "shl_4Fq9LmZ2xR8tKpWc",
  "object": "share_link",
  "document": "pdf_8Qw2kLm3nP0aB1cD",
  "url": "https://druckling-nine.vercel.app/s/k3J9vQ2xLm8RtY5wP1aZc7Nf0bHdx9Qa",
  "hint": "x9Qa",
  "status": "active",
  "expires_at": "2026-11-10T10:02:17.551Z",
  "revoked_at": null,
  "test_mode": true,
  "created_at": "2026-10-27T10:02:17.551Z"
}
```

What to expect:

- **Only rendered documents can be shared.** A document that is `queued`, `rendering` or `failed` answers `409` with code `invalid_state` ("Only rendered documents can be shared"). So does an expired one ("This document's file was deleted after the retention period").
- **The link never outlives the file.** `expires_at` is the earlier of `expires_in_days` from now and the document's own `expires_at`. Asking for 30 days on a document rendered 25 days ago gives a link that works for about 5 more days, without an error, so check `expires_at` in the response.
- **Out-of-range lifetimes are rejected.** An `expires_in_days` below 1, above 30 or with a fraction fails with `400 BAD_REQUEST`.
- **A document can have up to 20 active links.** The 21st answers `409` with code `conflict`. Revoke one first.
- **Any API key works.** Both Render only and Full access keys can create, list and revoke share links.
- **Links are free.** Creating and opening share links doesn't count toward your [plan's quota](/docs/concepts/plans-and-limits).

### The link is shown once [#the-link-is-shown-once]

Druckling stores only a SHA-256 hash of each link, never the link itself, so `url` appears in the create response and nowhere else. Listing or revoking returns `url: null`. Store the link when you create it, or create a new one if you lose it.

`hint` holds the link's last four characters, so you and your users can tell links apart (the dashboard shows it as `…x9Qa`).

## What visitors see [#what-visitors-see]

Opening the link streams the file itself, with no Druckling page around it:

- A PDF or PNG opens in the browser, like any file served inline.
- An XML e-invoice is shown as XML, in a sandbox that keeps it from running anything.
- Add `?download` to the link (for example `https://druckling-nine.vercel.app/s/k3J9…x9Qa?download`) to have the browser save the file instead of showing it.

The file is served under the document's `filename`. Responses tell search engines not to index the file, tell browsers and proxies not to cache it, and send no referrer. Nothing in the response names your workspace.

When a link can't be served, the visitor gets a short HTML page instead:

| Status | Page | When |
| --- | --- | --- |
| `404` | Link not found | The link is incomplete or wrong, or it was deleted after it expired. |
| `410` | This link was revoked | You revoked the link. |
| `410` | This link has expired | The link reached its `expires_at`, or the document's file was deleted. |
| `429` | Too many requests | Too many requests from one IP address, about 120 a minute. The response has a `Retry-After` header. |

Expired links don't answer `410` forever. A daily cleanup deletes every link whose `expires_at` has passed, revoked links included. From then on the link answers `404`, and it no longer appears when you list the document's links.

## List a document's links [#list-a-documents-links]

[`GET /v1/documents/{id}/share_links`](/docs/api-reference/share-links/list) returns every link of the document that hasn't been cleaned up yet, newest first:

```bash
curl https://druckling-nine.vercel.app/v1/documents/pdf_8Qw2kLm3nP0aB1cD/share_links \
  -H "Authorization: Bearer $DRUCKLING_API_KEY"
```

```json title="Response"
{
  "object": "list",
  "data": [
    {
      "id": "shl_4Fq9LmZ2xR8tKpWc",
      "object": "share_link",
      "document": "pdf_8Qw2kLm3nP0aB1cD",
      "url": null,
      "hint": "x9Qa",
      "status": "active",
      "expires_at": "2026-11-10T10:02:17.551Z",
      "revoked_at": null,
      "test_mode": true,
      "created_at": "2026-10-27T10:02:17.551Z"
    }
  ]
}
```

A link's `status` is worked out each time you read it:

| `status` | Meaning |
| --- | --- |
| `active` | The link works. |
| `expired` | The link reached its `expires_at`. |
| `revoked` | You revoked it; `revoked_at` says when. |

## Revoke a link [#revoke-a-link]

[`DELETE /v1/documents/{id}/share_links/{share_link_id}`](/docs/api-reference/share-links/revoke) stops the link immediately. The next visit gets `410`.

```bash
curl -X DELETE https://druckling-nine.vercel.app/v1/documents/pdf_8Qw2kLm3nP0aB1cD/share_links/shl_4Fq9LmZ2xR8tKpWc \
  -H "Authorization: Bearer $DRUCKLING_API_KEY"
```

The response is the link with `status: "revoked"` and `revoked_at` set. Revoking a link twice is fine and keeps the first `revoked_at`. An unknown link, or a link that belongs to another document, answers `404`.

A revoked link can't be restored, and no link can be extended. Create a new link instead.

## In the dashboard [#in-the-dashboard]

Open a rendered document in **Documents**. Under **Share links**, pick a lifetime in **Expires after** (1, 7, 14 or 30 days) and click **Create link**. Copy the link right away with **Copy**: like the API, the dashboard shows it only once. The list below shows each link's hint, status and expiry, with **Revoke** next to the active ones.

## Test mode [#test-mode]

Share links work the same way for [test documents](/docs/concepts/test-mode). A link's `test_mode` matches the document it points to.

## Security [#security]

Treat a share link like the file itself:

- **Links can't be guessed.** The part after `/s/` is 32 random characters (192 bits), and Druckling keeps only its hash.
- **Anyone with the link can open the file.** Send it only to the person who should see the document, over a channel you trust. Forwarding the link forwards access.
- **Keep lifetimes short.** Pick the shortest expiry that works for the recipient.
- **Revoke when in doubt.** Revoke a link as soon as it's no longer needed, or if it may have leaked.
- **Keep links out of logs.** Refer to links by `id` or `hint` in your own logs and support tools, not by the full URL.

## Next steps [#next-steps]

<Cards>
  <Card title="Documents" href="/docs/concepts/documents">
    Formats, retention and signed download links.
  </Card>
  <Card title="API reference" href="/docs/api-reference/share-links/create">
    Every field of the share link endpoints.
  </Card>
</Cards>
