View as Markdown

Embeds · Guide

Compose capture requests

<provenance-capture-request> lets your staff send a capture request from inside your own admin tool: email or text, or a QR the person scans at the counter. Your server fixes what a session may send (the kinds, the hardware requirement, the longest expiry, the contact); the element only chooses within that. After a send it shows each message's status, then when the person opened the link and when the photos arrived.

Before you begin: a publishable key (see embeds) and a secret key with the attest scope. The embed needs Pro or the Free trial; the console's New request form (Attest › Captures) does the same on every plan: Person and Case, where the link opens (Your app, Text or Email) and what to ask for.

export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_capture_C4pT9vQ2bW7mK3sYd8cFjLh6gAe1nR5x

1. Mint a session on your server

Your server mints a session for one case with POST /v1/embed/tokens, widget: "capture_request", your case reference, who is sending, and the options every send stays within. 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": "capture_request",
    "object_id": "LMB-20418",
    "author": { "id": "usr_8841", "display_name": "Ria Anand" },
    "request": {
      "kinds": ["capture.id"],
      "accepted_documents": ["passport", "driving_license"],
      "require_tier": { "default": "hardware", "editable": true },
      "expires_in": { "default": 86400, "max": 604800 },
      "contact": { "phone": "+14155550132" },
      "max_sends": 3
    },
    "ttl": 900
  }'
FieldWhat it does
object_idYour case reference, 1 to 200 characters. It becomes each request's case_id, so staff can't send for another case.
authorRequired: id (your reference) and display_name for the staff member. Recorded on each request the session sends; Provenance doesn't check it.
request.kindsWhat the session may send: capture.id (an ID, then a selfie), capture.claim (photos and videos) and capture.items (your own items).
request.accepted_documentscapture.id: the document kinds accepted (passport, passport_card, driving_license, national_id_card, residence_permit; default all but passport_card). With one, the person isn't asked which document they have.
request.photos, request.videoscapture.claim: { min, max } limits, as on a create.
request.itemscapture.items (required with it): the items, with your own labels and instructions.
request.require_tier{ default, editable }: any or hardware, and whether staff may switch Require hardware proof. Not editable by default.
request.expires_in{ default, max } in seconds: the expiry, and the longest staff may pick.
request.remindersaccount (your reminder schedule, which staff may turn off) or off.
request.contactA phone or email to send to. It stays on Provenance's server; the element shows it masked.
request.contact_editableWhether staff may replace that contact. Without a contact, staff type one.
request.entryWho types the contact: staff (default) or person, for a kiosk or a counter where the person types their own number.
request.qrWhether Show a QR is offered. On by default.
request.max_sendsRequests the session may send, 1 to 10. 3 by default.
request.reference_addressesUp to five addresses every send carries, as on a capture request create: one of each kind (other up to two), each an address or a location. Capture rules then compare where each photo was taken with them: a bank's application address as a person reference is capture.min_distance_km.person_address. The element shows each by its label (or its kind), never the address.
ttlSeconds, up to 900 (15 minutes).

A key without the attest scope gets 403 insufficient_scope. A copied session sends only within its options, at most max_sends times, 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-capture-request base-url="https://sandbox-api.provenanceauth.com" publishable-key="prv_pub_1D10TzJo8F73Z7ZHhWGKPpn0K7suJ0se" theme="inherit">
</provenance-capture-request>

<script>
  const el = document.querySelector("provenance-capture-request");
  el.getToken = async () => (await (await fetch("/admin/provenance/composer?case=LMB-20418")).json()).token;
  el.addEventListener("pv:request_sent", (e) => console.log("sent", e.detail.request_id));
</script>

getToken() works as it does for the capture result: the element calls it on load and one minute before each session ends, and a half-typed number stays when the session renews.

In React:

import { ProvenanceCaptureRequest } from "@provenance/embed/react";

<ProvenanceCaptureRequest
  baseUrl={process.env.NEXT_PUBLIC_PROVENANCE_API!}
  publishableKey="prv_pub_1D10TzJo8F73Z7ZHhWGKPpn0K7suJ0se"
  getToken={async () => (await (await fetch(`/admin/provenance/composer?case=${caseId}`)).json()).token}
  onRequestSent={(d) => setRequestId(d.request_id)}
/>;

What it shows

RowExampleFrom the session
WhoEmail or Phone, one field; or the contact you gave, maskedrequest.contact, request.contact_editable
Consent to textSee consent to textYour consent mode and request.entry
Asks forID front and back, a selfierequest.kinds and their options
Require hardware proofA switch, only when editablerequest.require_tier
Expires24 hoursrequest.expires_in
RemindersA switchrequest.reminders
Address, for rulesFrom the caserequest.reference_addresses, by label
Send the linkSends by email or text
Or have them scan this on their phoneShow a QRrequest.qr

After a send, the card shows one line per fact: "Text sent to •••• 0132 · 1:23 pm", "Opened 1:24 pm", "Next reminder tomorrow 9:00 am", then "Received 1:31 pm". Send another starts over while the session has sends left.

Show a QR creates its own request with nothing sent (delivery: "self") and draws its link. The link lasts 15 minutes and the QR blurs after 2 minutes until Show again, because it's a working link on a staff screen. A QR request and a sent request are separate requests, so one link is never both in a message and on a screen.

On a desktop, Or open the link sits under the QR and blurs with it. On a phone (a touch screen with no hover, up to 820 px wide), the row reads "Or take the photos on this phone" with Use this phone, and the request opens with one Open on this phone button in place of the QR. The handoff attribute forces one: handoff="qr" always draws the QR, handoff="link" always shows the button. In React, pass handoff="qr" or handoff="link".

When your page already chose the link-only request (the person is on their own phone), start="link" opens straight on it: nothing is sent and no picker shows (start="link" in React too).

A phone send follows your consent mode and request.entry. A staff member never ticks a box worded as the person:

Your modeentry: "staff" (default)entry: "person"
Provenance asksNo box. Provenance asks the person before the first text, as for any requestThe consent box with its fixed wording and Terms · Privacy; the tick is the person's own
We have itA box worded for staff, "They agreed to texts from Larkmoor Bank", with how they agreed; it's recorded as your statement, naming the authorThe consent box, as above

Consent records are on Pro and up, so on Free the composer shows no box.

Records

Each request the composer sends is an ordinary capture request: it's billed as one, fires the same webhooks, and reads the same on the API, with two more fields:

{ "created_via": "embed", "author": { "ref": "usr_8841", "name": "Ria Anand" } }

The console's request drawer shows Sent from an embed by Ria Anand.

What the browser sees

The element reads GET /v1/embed/capture_request_form, sends with POST /v1/embed/capture_request_sends, and reads each sent request's status with GET /v1/embed/capture_request_sends/{id}. None of them returns the full contact, another request, the author's ID or the API object, and the link only for a QR. The send also returns a capture_result session for the new request, so your page can swap in <provenance-capture-result>.

Events

EventWhenDetail
pv:readyThe session openedwidget, object_id, mode
pv:request_sentA request was createdrequest_id, kind, delivery
pv:deliveryOne of its messages changed staterequest_id, channel, state
pv:token_refresh_failedgetToken() couldn't renew the sessionwidget
pv:errorThe element couldn't start, or a send was refusedcode, message

Confirm on your server from the webhook, never from the event alone.

Embed, console or your own

This embedThe consoleYour own UI on the API
WhereYour admin toolAttest › Captures, New requestAnywhere you like
PlanPro, or the Free trialEvery planEvery plan
WorkMint a session, drop the tagNoneCreate with POST /v1/attest/capture_requests, track deliveries, render the consent wording

Errors you might see

SymptomCauseFix
400 embed_request_out_of_scopeThe send asked for something the session doesn't allow; param names itSend within the session's options, or mint one that allows it.
429 embed_sends_exhaustedThe session sent its max_sendsMint a new session.
403 insufficient_scopeThe key has no attest scopeMint with an Attest key.
401 embed_token_invalidThe session expired, or the status asked for a request it didn't sendMint a new one, or give the element getToken().
402 trial_endedThe Free trial endedUpgrade, or use the console's form.

See also