Embeds · Guide
Show a run result
<provenance-run-result> shows one agent run to your staff, inside your own admin tool: whether it's active, halted or ended, what the team has spent against the budget, each agent's place in the chain, and the agents' newest purchases and refusals. Every row is one line, with a dot and a word. Beside it, a slot holds your own next step; Provenance shows the facts and never picks the action.
Before you begin: a publishable key (see embeds) and a secret key with the mandate scope. The embed needs Pro or the Free trial; the same rows show on the console's run page on every plan.
export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x
1. Mint a session on your server
Your server mints a short session for one run with POST /, widget: "run_result" and the run's ID. Put it behind a route your admin page calls, after your own sign-in check:
In the SDK tabs, prov (Node, Python) and embed (Go) are your server-side clients, set up as in admin results and requests.
curl -s -X POST $PROVENANCE_API/v1/embed/tokens \
-H "Authorization: Bearer $PROVENANCE_KEY" \
-H "Content-Type: application/json" \
-d '{ "widget": "run_result", "object_id": "run_01M7KR2Y8QW5TZ0D9H3XNB4C6E", "ttl": 900 }'
// GET /admin/provenance/session?run=run_01M7… (your route, behind your staff sign-in)
const session = await prov.embed.createToken({ widget: "run_result", objectId: runId, ttl: 900 });
res.json({ token: session.embedToken });
token = prov.embed.create_token(widget="run_result", object_id=run_id, ttl=900)["embed_token"]
session, err := embed.CreateToken(ctx, pv.EmbedTokenParams{Widget: pv.WidgetRunResult, ObjectID: runID, TTL: 900})
| Field | What it does |
|---|---|
object_ | One run (run_) of your account. Another kind of ID is 400 embed_; another account's is 404. |
ttl | Seconds, up to 900 (15 minutes). |
A key without the mandate scope gets 403 insufficient_scope. A copied session opens only this run, and only until it expires. For a phone, mint a hosted page link with the same body instead.
2. Drop the element in your page
npm install @provenance/embed
<script type="module" src="https://unpkg.com/@provenance/embed"></script>
<provenance-run-result base-url="https://sandbox-api.provenanceauth.com" publishable-key="prv_pub_1D10TzJo8F73Z7ZHhWGKPpn0K7suJ0se" theme="inherit">
<div slot="actions"><button id="review-trip" hidden>Review the trip</button></div>
</provenance-run-result>
<script>
const el = document.querySelector("provenance-run-result");
el.getToken = async () => (await (await fetch("/admin/provenance/session?run=run_01M7KR2Y8QW5TZ0D9H3XNB4C6E")).json()).token;
</script>
The element calls getToken() on load and one minute before each session ends, and swaps the new session in place. If your server can't answer, it says Session ended with Reload and fires pv:token_refresh_failed. See capture result in your admin for the details; they're the same here.
If your server adds a tag of its own to the end of the run's name, name it in hide-suffix and the element shows the run's name without it.
In React:
import { ProvenanceRunResult } from "@provenance/embed/react";
<ProvenanceRunResult
baseUrl={process.env.NEXT_PUBLIC_PROVENANCE_API!}
publishableKey="prv_pub_1D10TzJo8F73Z7ZHhWGKPpn0K7suJ0se"
getToken={async () => (await (await fetch(`/admin/provenance/session?run=${runId}`)).json()).token}
onResult={(r) => setResult(r)}
>
<ReviewTrip result={result} />
</ProvenanceRunResult>;
3. Put your own next step in the slot
The actions slot is yours. Decide what to show from pv:result, which carries enums only:
el.addEventListener("pv:result", (e) => {
const { status, outcome } = e.detail;
// Your rule, in your code: a halted run, or an agent's purchase refused.
document.querySelector("#review-trip").hidden = !(status === "halted" || outcome === "denied");
});
| Detail | Values |
|---|---|
status | The run's: active, halted or ended |
outcome | The newest action's result: valid, denied or pending, or null before the first |
The slot can't cover or restyle the status line, the outcome words or the "Powered by Provenance" foot.
What it shows
Each row, and where it comes from in the API, so you can find the same fact in GET / and GET / (with run_id):
| Row | Example | From |
|---|---|---|
| Status line | Active · 3 agents, what the team spent of the budget | The run's status; how many members; the root grant's spent and share |
| Budget | Spent, Budget, Available | The root member's mandate., mandate. and mandate. (spend per grant) |
| Team | Valet › Valet Flights, with its spend of its share | Each member's agent name (else its grant's purpose), its chain through grant., and its spent and share |
| Proposals | Kestrel Broadband support · Accepted, the offer, its price and the answer | The run's proposals from outside agents, when it has any: the same cards as <provenance-counter-offers> |
| Timeline | Valet Flights · Approved, the amount and the merchant | The run's verify decisions, newest first, at most 10: result, facts., facts. or facts., reason, created_ |
| Timeline | Started, Halted, Resumed, Ended | The run's created_, halted_ with halt_, resumed_, ended_ |
A chain longer than two names shows its root and its member with the count between: Valet › +1 › Seat picker. An action reads Approved, Rejected or In review, the product's outcome words. A halt says who stopped it by kind (the run guard, a person, or a call with a key), never which key or person.
The element never receives an ID: no session, agent, grant, decision or token ID reaches it. To see what it gets, call GET /v1/embed/run_result with the session.
While the run is active, the element reads it again every 15 seconds. A run that can't be read shows that it's unavailable, never a made-up result.
Events
| Event | When | Detail |
|---|---|---|
pv:ready | The session opened | widget, object_, mode |
pv:result | First read, and whenever the run changes | kind: "run", status, outcome |
pv:token_ | getToken() couldn't renew the session | widget |
pv:error | The element couldn't start | code, message |
Embed, console or your own
| This embed | The console | Your own UI on the API | |
|---|---|---|---|
| Where | Your admin tool | Mandate › Runs, the run page | Anywhere you like |
| Plan | Pro, or the Free trial | Every plan | Every plan |
| Work | Mint a session, drop the tag | None | Read the run and its decisions, walk the chain, format the spend |
To build your own, read the run page and the run's decisions from your server; the table above names the field behind each row.
Errors you might see
| Symptom | Cause | Fix |
|---|---|---|
400 embed_ | The ID isn't a run | Pass the run_ ID. |
403 insufficient_ | The key has no mandate scope | Mint with a Mandate key. |
401 embed_ | The session expired or is for another widget | Mint a new one, or give the element getToken(). |
503 embed_ | The run couldn't be read | Retry shortly. |