View as Markdown

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 /v1/embed/tokens, 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 }'
FieldWhat it does
object_idOne traffic assessment (tas_…) from your hosted checks. Another kind of ID is 400 embed_object_kind_mismatch; a middleware report or another account's assessment is 404.
ttlSeconds, 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";
});
DetailValues
status, outcomeThe visit's decision: allow, block, challenge, log_only, rate_limit or require_intent

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 /v1/identify/assessments/{id}:

RowExampleFrom
Status lineRejected · Posts to checkout, POST /checkoutdecision.action, policy.rule.name, request.method and request.path
VisitorSuspected bot, Acme Shopper, Shopping agentclass, agent.operator, agent.category
SignatureSigned and verified, or Not signedagent.verified
PersonBacked by a personhuman.backed
Bot likelihoodHigh, or Unclassified with whybot_likelihood and bot_likelihood_reason
Bot score80 of 100bot_score
SignalHeadless browser, Hosting address, Typed in a fieldsignals[].code, and field timing's typed and pointer flags
Deciding rulePosts to checkout · Reject, each condition with the value it comparedpolicy.rule.name, policy.rule.action, policy.rule.conditions[] (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

EventWhenDetail
pv:readyThe session openedwidget, object_id, mode
pv:resultFirst readkind: "traffic", 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 toolIdentify › Traffic, Hosted checksAnywhere you like
PlanPro, or the Free trialEvery planEvery plan
WorkMint a session, drop the tagNoneRead the assessment, map the words

Errors you might see

SymptomCauseFix
400 embed_object_kind_mismatchThe ID isn't a traffic assessmentPass the tas_… ID.
403 insufficient_scopeThe key has no identify scopeMint with an Identify key.
401 embed_token_invalidThe session expired, or the assessment is past its retentionMint a new one, or give the element getToken().
503 embed_result_unavailableThe visit couldn't be readRetry shortly.

See also