# Open a hosted result page

Open a capture result, a checkout result or the request composer on a Provenance-hosted page by link, on a phone, in an email or in your app's in-app browser.

The admin embeds ([capture result](https://provenanceauth.com/docs/embeds/capture-result.md), [checkout result](https://provenanceauth.com/docs/embeds/checkout-result.md), [run result](https://provenanceauth.com/docs/embeds/run-result.md), [traffic result](https://provenanceauth.com/docs/embeds/traffic-result.md), the [request composer](https://provenanceauth.com/docs/embeds/capture-request.md), your [rules](https://provenanceauth.com/docs/embeds/rules.md)) need a web admin you control. When you don't have one, or your staff are on a phone, mint a link instead: it opens a page Provenance hosts, branded with your account's Branding, that shows the same element. There's nothing to drop into a page and no publishable key.

**Before you begin:** a secret key with the element's scope (`attest` for a capture result or the composer, `authorize` for a checkout result). Hosted pages need Pro or the Free trial, as the elements do.

```bash
export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_capture_C4pT9vQ2bW7mK3sYd8cFjLh6gAe1nR5x
```

## 1. Mint a link on your server

[`POST /v1/embed/links`](https://provenanceauth.com/docs/api/embeds.md#post-v1-embed-links) takes the same body as [`POST /v1/embed/tokens`](https://provenanceauth.com/docs/api/embeds.md#post-v1-embed-tokens) and runs the same checks. It returns the page's `url`:

In the SDK tabs, `prov` (Node, Python) and `embed` (Go) are your server-side clients, set up as in [admin results and requests](https://provenanceauth.com/docs/embeds/admin-tools.md#3-mint-a-session-for-an-embed).

**curl**

```bash
curl -s -X POST $PROVENANCE_API/v1/embed/links \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "widget": "capture_result", "object_id": "capr_01M7JDNVW9Y267T8JEKZHVYP7G", "show": ["case_id"] }'
```

**Node**

```ts
// GET /admin/provenance/link?request=capr_… (your route, behind your staff sign-in)
const link = await prov.embed.createLink({ widget: "capture_result", objectId: requestId, show: ["case_id"] });
res.json({ url: link.url });
```

**Python**

```python
url = prov.embed.create_link(widget="capture_result", object_id=request_id, show=["case_id"])["url"]
```

**Go**

```go
link, err := embed.CreateLink(ctx, pv.EmbedLinkParams{Widget: pv.WidgetCaptureResult, ObjectID: requestID, Show: []string{"case_id"}})
```

| Field | What it does |
| --- | --- |
| `widget` | `capture_result`, `checkout_result`, `run_result`, `traffic_result`, `capture_request` or `rules`. Another widget is `400` [`parameter_invalid`](https://provenanceauth.com/docs/platform/errors.md#parameter_invalid). |
| `object_id`, `show`, `author`, `request`, `mode`, `rules` | As for the element's token. A composer's `max_sends` counts every send the page makes. A rules page takes the kind, the mode and the full scope ([rules in your admin](https://provenanceauth.com/docs/embeds/rules.md#on-a-phone-the-hosted-rules-page)). |
| `ttl` | Seconds the link can be opened in, up to 900 (15 minutes, the default). |
| `session_ttl` | Seconds the opened page works for, 60 to 3600 (60 minutes, the default). |

The `url` is on the console's address, with the link in the query: `/r?t=embl_…`. Hand it to the person who needs it: open it, send it in an email or a text, or open it in your app. For a text, use `short_url` when the answer has one: the same page as a [short link](https://provenanceauth.com/docs/messaging/short-links.md).

## 2. What the page does

- **It opens once.** The first opening starts a page session; the link then stops working (`409` [`embed_link_used`](https://provenanceauth.com/docs/platform/errors.md#embed_link_used)), and one not opened within `ttl` never does (`400` [`embed_link_expired`](https://provenanceauth.com/docs/platform/errors.md#embed_link_expired)). Mint a new link each time.
- **It keeps its session for up to an hour** in the browser that opened it, renewing the element's 15-minute session on its own. A reload in the same tab keeps it.
- **It takes the link out of the address bar** as it opens, so the link isn't left in the tab's history or shared from it.
- **It shows the element as your admin would**: the same rows, one line each, the same trust chrome, your Branding, light or dark. There's no slot for your own next step; act from your own tools.

## 3. Open it from a React Native app

Phones open the hosted page in the in-app browser first; native components come later. Your server mints the link (its secret key never ships in the app) and the app opens it:

**This package isn't on npm yet.** Until then, every request in these docs runs over HTTP against the [sandbox](https://provenanceauth.com/docs/get-started/sandbox.md).

With access to the private Provenance repository, which your Provenance contact grants, install from it:

```bash
git clone https://github.com/michaelnbane-jpg/provenance.git provenance
cd provenance && pnpm install && pnpm build
node scripts/check-publishable.mjs --out ../provenance-packs
cd ../your-project
npm install ../provenance-packs/provenanceauth-sdk-1.0.0.tgz ../provenance-packs/provenanceauth-react-native-1.0.0.tgz
```

```ts
import { openHostedPage } from "@provenanceauth/react-native";

const { url } = await (await fetch(`${yourServer}/admin/provenance/link?request=${requestId}`)).json();
await openHostedPage(url);
```

`openHostedPage` opens the page in SFSafariViewController or a Custom Tab, and refuses anything that isn't a hosted page link.

## Embed, hosted page, console or your own

|  | Embed | Hosted page | The console | Your own UI on the API |
| --- | --- | --- | --- | --- |
| Where | Your web admin | A phone, an email to a manager, a reviewer without an admin seat | Every account's own pages | Anywhere |
| Plan | Pro and up | Pro and up | Every plan | Each API's own plan |
| You do | Mint a session, drop a tag | Mint a link | Nothing | Map the fields, check the signature, track deliveries |

## Errors you might see

| Error | Why | What to do |
| --- | --- | --- |
| `409` [`embed_link_used`](https://provenanceauth.com/docs/platform/errors.md#embed_link_used) | The link was opened already | Mint a new link. The page it opened keeps working in that browser. |
| `400` [`embed_link_expired`](https://provenanceauth.com/docs/platform/errors.md#embed_link_expired) | The link wasn't opened within `ttl` | Mint a new link. |
| `401` [`embed_token_invalid`](https://provenanceauth.com/docs/platform/errors.md#embed_token_invalid) | Not a link, or the page session has ended | Mint a new link. |
| `403` [`insufficient_scope`](https://provenanceauth.com/docs/platform/errors.md#insufficient_scope) | The key lacks the element's scope | Use a key with `attest` (capture) or `authorize` (checkout). |

## See also

- [Embeds](https://provenanceauth.com/docs/embeds.md)
- [Admin results and requests](https://provenanceauth.com/docs/embeds/admin-tools.md)
- [Capture result in your admin](https://provenanceauth.com/docs/embeds/capture-result.md)
- [Capture request composer](https://provenanceauth.com/docs/embeds/capture-request.md)
- [Checkout result in your admin](https://provenanceauth.com/docs/embeds/checkout-result.md)
- [Run result in your admin](https://provenanceauth.com/docs/embeds/run-result.md)
- [Traffic result in your admin](https://provenanceauth.com/docs/embeds/traffic-result.md)
