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 /, 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
}'
// GET /admin/provenance/composer?case=LMB-20418 (your route, behind your staff sign-in)
const session = await prov.embed.createToken({
widget: "capture_request",
objectId: caseId,
author: { id: staff.id, displayName: staff.name },
request: { kinds: ["capture.id"], acceptedDocuments: ["passport", "driving_license"], expiresIn: { default: 86400, max: 604800 }, contact: { phone: applicant.phone } },
ttl: 900,
});
res.json({ token: session.embedToken });
token = prov.embed.create_token(
widget="capture_request",
object_id=case_id,
author={"id": staff_id, "display_name": staff_name},
request={"kinds": ["capture.id"], "accepted_documents": ["passport", "driving_license"], "contact": {"phone": applicant_phone}},
ttl=900,
)["embed_token"]
session, err := embed.CreateToken(ctx, pv.EmbedTokenParams{
Widget: pv.WidgetCaptureRequest,
ObjectID: caseID,
Author: &pv.EmbedAuthor{ID: staffID, DisplayName: staffName},
Request: &pv.CaptureRequestSessionOptions{Kinds: []string{"capture.id"}, Document: "any", Contact: &pv.EmbedContact{Phone: applicantPhone}},
TTL: 900,
})
| Field | What it does |
|---|---|
object_ | Your case reference, 1 to 200 characters. It becomes each request's case_, so staff can't send for another case. |
author | Required: id (your reference) and display_ for the staff member. Recorded on each request the session sends; Provenance doesn't check it. |
request. | What the session may send: capture. (an ID, then a selfie), capture. (photos and videos) and capture. (your own items). |
request. | capture.: the document kinds accepted (passport, passport_, driving_, national_, residence_; default all but passport_). With one, the person isn't asked which document they have. |
request., request. | capture.: { min, max } limits, as on a create. |
request. | capture. (required with it): the items, with your own labels and instructions. |
request. | { default, editable }: any or hardware, and whether staff may switch Require hardware proof. Not editable by default. |
request. | { default, max } in seconds: the expiry, and the longest staff may pick. |
request. | account (your reminder schedule, which staff may turn off) or off. |
request. | A phone or email to send to. It stays on Provenance's server; the element shows it masked. |
request. | Whether staff may replace that contact. Without a contact, staff type one. |
request. | Who types the contact: staff (default) or person, for a kiosk or a counter where the person types their own number. |
request. | Whether Show a QR is offered. On by default. |
request. | Requests the session may send, 1 to 10. 3 by default. |
request. | Up 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.. The element shows each by its label (or its kind), never the address. |
ttl | Seconds, 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
| Row | Example | From the session |
|---|---|---|
| Who | Email or Phone, one field; or the contact you gave, masked | request., request. |
| Consent to text | See consent to text | Your consent mode and request. |
| Asks for | ID front and back, a selfie | request. and their options |
| Require hardware proof | A switch, only when editable | request. |
| Expires | 24 hours | request. |
| Reminders | A switch | request. |
| Address, for rules | From the case | request., by label |
| Send the link | Sends by email or text | |
| Or have them scan this on their phone | Show a QR | request. |
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).
Consent to text
A phone send follows your consent mode and request.entry. A staff member never ticks a box worded as the person:
| Your mode | entry: "staff" (default) | entry: "person" |
|---|---|---|
| Provenance asks | No box. Provenance asks the person before the first text, as for any request | The consent box with its fixed wording and Terms · Privacy; the tick is the person's own |
| We have it | A box worded for staff, "They agreed to texts from Larkmoor Bank", with how they agreed; it's recorded as your statement, naming the author | The 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
| Event | When | Detail |
|---|---|---|
pv:ready | The session opened | widget, object_, mode |
pv:request_ | A request was created | request_, kind, delivery |
pv:delivery | One of its messages changed state | request_, channel, state |
pv:token_ | getToken() couldn't renew the session | widget |
pv:error | The element couldn't start, or a send was refused | code, message |
Confirm on your server from the webhook, never from the event alone.
Embed, console or your own
| This embed | The console | Your own UI on the API | |
|---|---|---|---|
| Where | Your admin tool | Attest › Captures, New request | Anywhere you like |
| Plan | Pro, or the Free trial | Every plan | Every plan |
| Work | Mint a session, drop the tag | None | Create with POST /, track deliveries, render the consent wording |
Errors you might see
| Symptom | Cause | Fix |
|---|---|---|
400 embed_ | The send asked for something the session doesn't allow; param names it | Send within the session's options, or mint one that allows it. |
429 embed_ | The session sent its max_ | Mint a new session. |
403 insufficient_ | The key has no attest scope | Mint with an Attest key. |
401 embed_ | The session expired, or the status asked for a request it didn't send | Mint a new one, or give the element getToken(). |
402 trial_ | The Free trial ended | Upgrade, or use the console's form. |