View as Markdown

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 /v1/embed/tokens, 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 }'
FieldWhat it does
object_idOne run (run_…) of your account. Another kind of ID is 400 embed_object_kind_mismatch; another account's is 404.
ttlSeconds, 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");
});
DetailValues
statusThe run's: active, halted or ended
outcomeThe 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 /v1/mandate/runs/{id} and GET /v1/mandate/assessments (with run_id):

RowExampleFrom
Status lineActive · 3 agents, what the team spent of the budgetThe run's status; how many members; the root grant's spent and share
BudgetSpent, Budget, AvailableThe root member's mandate.spent, mandate.share and mandate.available (spend per grant)
TeamValet › Valet Flights, with its spend of its shareEach member's agent name (else its grant's purpose), its chain through grant.parent_grant_id, and its spent and share
ProposalsKestrel Broadband support · Accepted, the offer, its price and the answerThe run's proposals from outside agents, when it has any: the same cards as <provenance-counter-offers>
TimelineValet Flights · Approved, the amount and the merchantThe run's verify decisions, newest first, at most 10: result, facts.transaction_amount, facts.payee or facts.counterparty, reason, created_at
TimelineStarted, Halted, Resumed, EndedThe run's created_at, halted_at with halt_reason, resumed_at, ended_at

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

EventWhenDetail
pv:readyThe session openedwidget, object_id, mode
pv:resultFirst read, and whenever the run changeskind: "run", status, outcome
pv:token_refresh_failedgetToken() couldn't renew the sessionwidget
pv:errorThe element couldn't startcode, message

Embed, console or your own

This embedThe consoleYour own UI on the API
WhereYour admin toolMandate › Runs, the run pageAnywhere you like
PlanPro, or the Free trialEvery planEvery plan
WorkMint a session, drop the tagNoneRead 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

SymptomCauseFix
400 embed_object_kind_mismatchThe ID isn't a runPass the run_… ID.
403 insufficient_scopeThe key has no mandate scopeMint with a Mandate key.
401 embed_token_invalidThe session expired or is for another widgetMint a new one, or give the element getToken().
503 embed_result_unavailableThe run couldn't be readRetry shortly.

See also