---
title: "Mint a shareable link to a sandbox preview."
method: POST
path: "/v1/sandboxes/{id}/preview-link"
tags: ["Sandboxes"]
---

# Mint a shareable link to a sandbox preview.

`POST /v1/sandboxes/{id}/preview-link`

## Request

- Base URL: `/api` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/v1/sandboxes/{id}/preview-link`
- Auth: HTTP bearer

`GET /domain` returns the bare preview URL, which is useless to anyone who
does not already hold the sandbox's preview password — so sharing a
protected preview meant sharing that password, which is the same secret for
every recipient and can only be withdrawn by rotating it for all of them.

This returns the same URL carrying a short-lived, sandbox-scoped grant. The
recipient's browser exchanges it for the ordinary preview cookie and lands
on `path`. The grant never reaches the sandbox, so preview application code
cannot read it and re-share it.

Anyone holding the returned URL can view the preview until it expires;
there is no per-link revocation short of rotating the preview password.

## Path parameters

- `id` string, required

## Request body

- PreviewShareLinkBody: Request body for minting a preview share link.
  - `path` string, nullable: Path the recipient lands on. Must be same-origin (start with a single `/`); anything else is replaced with `/` so a share link can never be turned into an open redirect.
  - `port` integer, required: Port inside the sandbox the preview serves on.
  - `ttl_seconds` integer, nullable: How long the link stays usable, in seconds. Clamped to 24 hours. Defaults to one hour — long enough to send to a reviewer, short enough that a link pasted in a ticket does not stay live indefinitely.

## Response `200`

Shareable preview link

- PreviewShareLinkResponse
  - `expires_at` string, date-time, required: When the link stops working, ISO 8601 in UTC.
  - `url` string, required: The full link. Its fragment contains the grant and must be treated as a credential; URL fragments are not sent to servers or in Referer headers.

## Other responses

- `400`: Invalid port
- `404`: Sandbox not found
- `409`: Sandbox has no preview password
- `500`: Preview grant minting failed

## Changes

- **2026-11-26** `e1864d950604`: 1 breaking
  - the `expires_at` response's property type changed from `integer` to `string`, and format from `int64` to `date-time` for status `200`
- **2026-08-04** `c647b6ab1d2c`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/gotempsh/apis/temps/changes/v1/sandboxes/:id/preview-link/post.md)

---

[API](https://skmtc.dev/gotempsh/apis/temps.md) - [All operations](https://skmtc.dev/gotempsh/apis/temps/llms.txt) - [OpenAPI document](https://skmtc.dev/gotempsh/apis/temps/revisions/3b040526eb43?raw)
