Embeds · Guide
Show a traffic result
<provenance-traffic-result> shows one visit Identify's hosted check assessed (a traffic assessment) to your staff, inside your own admin tool: the outcome, who visited and whether the agent signed the request, the bot likelihood with the signals behind it, and the rule that decided. 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 identify scope. The embed needs Pro or the Free trial; the same rows show on the console's Traffic page on every plan.
export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
1. Mint a session on your server
Your server mints a short session for one visit with POST /, widget: "traffic_result" and the assessment'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": "traffic_result", "object_id": "tas_01M7P2K8D3QJ6V4ZB9XWN5T1RA", "ttl": 900 }'
// GET /admin/provenance/session?visit=tas_01M7… (your route, behind your staff sign-in)
const session = await prov.embed.createToken({ widget: "traffic_result", objectId: visitId, ttl: 900 });
res.json({ token: session.embedToken });
token = prov.embed.create_token(widget="traffic_result", object_id=visit_id, ttl=900)["embed_token"]
session, err := embed.CreateToken(ctx, pv.EmbedTokenParams{Widget: pv.WidgetTrafficResult, ObjectID: visitID, TTL: 900})
| Field | What it does |
|---|---|
object_ | One traffic assessment (tas_) from your hosted checks. Another kind of ID is 400 embed_; a middleware report or another account's assessment is 404. |
ttl | Seconds, up to 900 (15 minutes). |
A key without the identify scope gets 403 insufficient_scope. A copied session opens only this visit, 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-traffic-result base-url="https://sandbox-api.provenanceauth.com" publishable-key="prv_pub_1D10TzJo8F73Z7ZHhWGKPpn0K7suJ0se" theme="inherit">
<div slot="actions"><button id="block-agent" hidden>Block this agent</button></div>
</provenance-traffic-result>
<script>
const el = document.querySelector("provenance-traffic-result");
el.getToken = async () => (await (await fetch("/admin/provenance/session?visit=tas_01M7P2K8D3QJ6V4ZB9XWN5T1RA")).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. To show the visit a traffic list selected, set for to the list's id.
In React:
import { ProvenanceTrafficResult } from "@provenance/embed/react";
<ProvenanceTrafficResult
baseUrl={process.env.NEXT_PUBLIC_PROVENANCE_API!}
publishableKey="prv_pub_1D10TzJo8F73Z7ZHhWGKPpn0K7suJ0se"
getToken={async () => (await (await fetch(`/admin/provenance/session?visit=${visitId}`)).json()).token}
onResult={(r) => setResult(r)}
>
<BlockAgent result={result} />
</ProvenanceTrafficResult>;
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 { outcome } = e.detail;
// Your rule, in your code: offer a block on a visit your rules allowed.
document.querySelector("#block-agent").hidden = outcome !== "allow";
});
| Detail | Values |
|---|---|
status, outcome | The visit's decision: allow, block, challenge, log_, rate_ or require_ |
The slot can't cover or restyle the status line, the bot likelihood, the signature line, the rule's action or the "Powered by Provenance" foot.
What it shows
Each row, and where it comes from in GET /:
| Row | Example | From |
|---|---|---|
| Status line | Rejected · Posts to checkout, POST /checkout | decision., policy., request. and request. |
| Visitor | Suspected bot, Acme Shopper, Shopping agent | class, agent., agent. |
| Signature | Signed and verified, or Not signed | agent. |
| Person | Backed by a person | human. |
| Bot likelihood | High, or Unclassified with why | bot_ and bot_ |
| Bot score | 80 of 100 | bot_ |
| Signal | Headless browser, Hosting address, Typed in a field | signals[]., and field timing's typed and pointer flags |
| Deciding rule | Posts to checkout · Reject, each condition with the value it compared | policy., policy., policy. (actual) |
The status line says what Identify did to the request in the visit words: Allowed, Challenged or Rejected. The deciding rule's action reads in the rule builder's words (Allow, Challenge, Reject). Signals show by name only, never timings. A visit no rule decided shows no rule section.
The element never gets the address, a header, the user agent string, timing values, a pseudonym, an intent or any ID but the visit's. To see what it gets, call GET /v1/embed/traffic_result with the session. A visit 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 | kind: "traffic", 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 | Identify › Traffic, Hosted checks | Anywhere you like |
| Plan | Pro, or the Free trial | Every plan | Every plan |
| Work | Mint a session, drop the tag | None | Read the assessment, map the words |
Errors you might see
| Symptom | Cause | Fix |
|---|---|---|
400 embed_ | The ID isn't a traffic assessment | Pass the tas_ ID. |
403 insufficient_ | The key has no identify scope | Mint with an Identify key. |
401 embed_ | The session expired, or the assessment is past its retention | Mint a new one, or give the element getToken(). |
503 embed_ | The visit couldn't be read | Retry shortly. |