Embeds · Guide
Show a run's proposals
When your agent meets an agent run by another company, that agent may propose something other than what was asked: a later flight, a cheaper plan. <provenance-counter-offers> shows each proposal of one run and how it was answered, on your own pages. It is read only: the person answers on their own approval page or app, as described in counter-offers.
The API calls a proposal a counter_offer. On screen it reads Proposal.
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 run result shows the same section, so a page that already embeds a run needs nothing more.
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: "counter_offers" and the run's ID. Put it behind a route your page calls, after your own sign-in check:
curl -s -X POST $PROVENANCE_API/v1/embed/tokens \
-H "Authorization: Bearer $PROVENANCE_KEY" \
-H "Content-Type: application/json" \
-d '{ "widget": "counter_offers", "object_id": "run_01M7KR2Y8QW5TZ0D9H3XNB4C6E", "ttl": 900 }'
// GET /account/provenance/session?run=run_01M7… (your route, behind your sign-in)
const session = await (
await fetch(`${process.env.PROVENANCE_API}/v1/embed/tokens`, {
method: "POST",
headers: { Authorization: `Bearer ${process.env.PROVENANCE_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({ widget: "counter_offers", object_id: runId, ttl: 900 }),
})
).json();
res.json({ token: session.embed_token });
import os
import httpx
session = httpx.post(
f"{os.environ['PROVENANCE_API']}/v1/embed/tokens",
headers={"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"},
json={"widget": "counter_offers", "object_id": run_id, "ttl": 900},
).json()
token = session["embed_token"]
| 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's proposals, and only until it expires.
2. Drop the element in your page
npm install @provenance/embed
<script type="module" src="https://unpkg.com/@provenance/embed"></script>
<provenance-counter-offers base-url="https://sandbox-api.provenanceauth.com" publishable-key="prv_pub_1D10TzJo8F73Z7ZHhWGKPpn0K7suJ0se" theme="inherit"></provenance-counter-offers>
<script>
const el = document.querySelector("provenance-counter-offers");
el.getToken = async () => (await (await fetch("/account/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. It takes your theme like every other element. A run with no proposals draws nothing, so you can place the element on every run's page.
In React:
import { ProvenanceCounterOffers } from "@provenance/embed/react";
<ProvenanceCounterOffers
baseUrl={process.env.NEXT_PUBLIC_PROVENANCE_API!}
publishableKey="prv_pub_1D10TzJo8F73Z7ZHhWGKPpn0K7suJ0se"
getToken={async () => (await (await fetch(`/account/provenance/session?run=${runId}`)).json()).token}
/>;
What it shows
Each proposal is one card, with one line per row:
| Row | Example | From |
|---|---|---|
| Head | Kestrel Broadband support · Accepted · 2:10 pm | The outside agent's display name, one status word and when the proposal arrived |
| Offer | Fibre 100 for 12 months | The names of the option's lines |
| Price | The amount, in the offer's currency | The option's total |
| Date | Thu 3 Dec, 2:10 pm | The start of the option's dates, when it has any |
| Proof | Signed, or Reported by the agent | Signed when the outside agent signed every option |
| Asked | Cancel home internet | What your agent asked for, when it shared the request (share: true on the brief) |
| Also offered | Home internet at 50% off for 12 months, with its price | Every other option, one line each |
| Answer | Accepted · Passkey · 2:12 pm | The result, how a person answered, and when |
The status is one word: Challenged while the proposal waits on the person, Accepted once it is accepted, and Proposal otherwise. The answer leads with one word too: Accepted, Declined, No answer or Waiting. An answer the grant's own limits allowed reads Accepted · Within the grant. A proposal the agent took back reads Withdrawn.
What stays out
The element reads the shared view of each proposal's exchange record, the part both companies can read. Your side's private part stays on your server:
- The person's limit, the differences from what was asked and the reason a rule asked.
- The person's note to their agent and any change they asked for.
- Who the person is. An answer carries its method (Passkey, App, Link or Console) and its time.
- Every ID, offer hash and signed token, and the outside agent's web address and key.
- Any location or device.
To see exactly what the element gets, call GET /v1/embed/counter_offers with the session.
While a proposal is open or waiting, the element reads it again every 15 seconds. Proposals that can't be read show as unavailable; nothing is shown in their place.
Events
| Event | When | Detail |
|---|---|---|
pv:ready | The session opened | widget, object_, mode |
pv:result | First read, and whenever a proposal changes | kind: "counter_, count, status (the newest proposal's) |
pv:token_ | getToken() couldn't renew the session | widget |
pv:error | The element couldn't start | code, message |
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 proposals couldn't be read | Retry shortly. |