SDK reference · Node SDK
prov.embed.createToken
prov.embed.createToken in Node SDK. Mint an embed session for one widget and one object (201): pass embedToken to the element.
Signature
prov.embed.createToken(params: CreateEmbedTokenParams): Promise<EmbedToken>Parameters
paramsCreateEmbedTokenParamsRequired
Request fields
Idempotency-Keystringheader- Retry a create safely: the same key + request returns the stored response (24 h, per caller).
widgetenumRequired- The widget, such as
approveorreceipt.capture,capture_result,capture_request,capture_listandappealneed a key with theattestscope;checkout_result,checkout_listandchargeback_protectionneedauthorize;run_result,run_listand the proposals widget ('counter_offers') needmandate;traffic_listandtraffic_resultneedidentify;rulesneeds the scope of its kind's product (authorizeforcheckout,mandateforintentandmandate_limits,attestforcapture);embedandtext_consenttake any account key; the rest needauthorizeormandate. object_idstring- The single object this token may touch: a draft (
mdr_…) or, with modecheckin, a mandate formandate; a claim forappeal(minted with averifykey); your account'sbox_id(GET /v1/account/text_consent) fortext_consent, the consent box; a capture request (capr_…) of your account forcapture_result(another kind of id is400 embed_object_kind_mismatch); a checkout assessment (cas_…) or a cart approval (coap_…) of your account forcheckout_result; an agent run (run_…) of your account forrun_resultand for'counter_offers'; a traffic assessment (tas_…, a hosted check) of your account fortraffic_result; your case reference (1 to 200 characters, the requests'case_id) forcapture_request, the request composer; the kind of rules,checkout,intent,captureormandate_limits, forrules. Required for every widget exceptagent_access,approvals,capture_list,checkout_list,run_listandtraffic_list(a list takes none: it is scoped to your account and itsfilters) andchargeback_protection(scoped to your account). subjectobjectagent_accessandapprovalsonly: the one person the token shows. The response'sobject_idis then a pairwise value, never the device or approver.Show child attributes
device_idstringagent_access: the person's device.approver_link_idstringapprovals: one of your accepted approver links; the token lists that approver's requests from your company.
ttlinteger- Seconds (≤ 900).
modestring- The widget's mode, such as
consent, orcheckinfor a mandate check-in. A result widget's mode isview; the request composer's issend;rulestakesview(the default),editorpublish; a console session mintingeditorpublishneeds Manage policies and a recent step-up, as a direct policy write does (403 manage_policies_required,recent_two_factor_required). publishable_key_idstring- Optional binding to one publishable key: the token then works only with that key (another key of the account gets
401 embed_token_invalid). showarray of enumscapture_resultonly: also show the request'scase_idormetadatain the embed.capture_listtakescase_idonly, shown on each row. Nothing else is ever shown.authorobjectcapture_requestonly, required: who is using the composer, as you report it. Recorded on each request the session sends (author); Provenance doesn't check it.Show child attributes
idstringRequired- Your reference for the staff member (1 to 200 characters).
display_namestringRequired- Their display name (1 to 120 characters).
requestobjectcapture_requestonly, required: the options every send of the session stays within. A send outside them is400 embed_request_out_of_scope.Show child attributes
kindsarray of enumsRequired- What the session may send: an ID session, a claim session, or your own items.
accepted_documentsarray of enumscapture.id: the document kinds accepted (one: the person isn't asked to choose).photosobjectcapture.claim:{ min, max, until_done }photos.videosobjectcapture.claim:{ min, max, max_duration_s }videos.itemsarray of objectscapture.items(required with it): the items, as on a create.require_tierobject{ default: any | hardware, editable }: the hardware requirement, and whether staff may change it (not by default).expires_inobject{ default, max }in seconds: the expiry and the longest staff may pick.remindersenumaccount(default): the account's schedule, which staff may turn off. One ofaccount,off.contactobject- A phone or email to send to. It stays on the server; the element shows it masked.
contact_editableboolean- Whether staff may replace a prefilled contact (not by default).
entryenum- Who types the contact:
staff(default) orperson(a kiosk or counter, where the person ticks their own consent box). One ofstaff,person. qrboolean- Whether **Show a QR** is offered (default true).
max_sendsinteger- Requests the session may send (default 3).
reference_addressesarray of objects- Up to five addresses every send carries, as
reference_addresseson a capture request create (one of each kind,otherup to two; anaddressor alocation, never both), so capture rules can compare each shot's place with them: a bank's application address as apersonreference, for example. The element shows each by its label (or kind), never the address.Show child attributes
kindenumRequired- What the address is. One of
loss,person,business,shipping,other. labelstring | null- Your label for it; the element shows it.
addressobject- A postal address.
Show child attributes
line1stringRequired- The street line.
line2string | null- A second line.
citystringRequired- The city.
regionstring | null- The ISO 3166-2 subdivision code (
OHorUS-OH). postal_codestring | null- The postal code.
countrystringRequired- ISO 3166-1 alpha-2.
locationobject- Coordinates (no geocoder needed).
Show child attributes
latnumberRequired- Latitude.
lngnumberRequired- Longitude.
rulesobjectrulesonly, required: everything a rules session may show and touch, passed on every mint (nothing is saved between sessions). Strict: an unknown key is400 parameter_invalid, so a typo never widens a session. At most 16 KB. The response echoes it as stored, every default written out.Show child attributes
showarray of objectsRequired- The rules the session sees, by id. They show in the policy's own order; rules not listed stay hidden.
Show child attributes
rule_idstringRequired- A rule of the kind's live policy (else
400 rules_embed_rule_missing). Formandate_limits, a row:cap,budget,allowed_mcc,named_merchants,blocked_mcc,blocked_merchants,refuse_over_cap,refuse_over_shareorask_over_cap. templatestring- A template id of the kind the row reads as.
fieldsarray of objects- The values that are blanks, each a path into the rule (
when.0.value) with its bounds.Show child attributes
pathstringRequired- A condition's value:
when.N.value,when.items.N.valueorwhen.items.N.conditions.M.value. Formandate_limits:amountoncap,allocation(shared,reserved) andat_limit(stop,ask,continue) onbudget,valueon a margin row (withadvanced, its unit, a percentage or a fixed amount, is offered beside it; the bounds bound a percentage). minnumber- A number blank's lowest value.
maxnumber- A number blank's highest value.
valuesarray of strings- The words a word blank may take (the field's own values).
can_turn_offboolean- Whether the session may turn the rule off (not by default).
lockedboolean- Shown read-only: no blanks, no turning off.
add_from_templatesarray of strings- Template ids of the kind the session may add (none by default).
advancedboolean- Whether an
editorpublishsession may open the Advanced view (not by default): whole rules from the kind's catalog (GET /v1/embed/rules/catalog), a shown rule replaced or a new one added. Onmandate_limits, a margin row's unit: a fixed amount instead of a percentage. On every plan. visibilityenum- Which rules the session shows besides those in
show: every rule of the policy (all, the default withmanage; with full control each can be changed like a listed rule, without it they're read-only) or only the rules the session itself added (session, the default withoutmanage). Not onmandate_limits. One ofall,session. manageboolean- Full control (not by default): in an
editorpublishsession, every shown rule that isn't locked can be moved (order), turned off, deleted (remove), duplicated (copy_of) and have every value edited; withadvanced, its conditions and outcome too, the default rows included. A listed rule missing from the policy is left out of the session rather than refused. Not onmandate_limits. advanced_fieldsarray of strings- With
advanced: the catalog fields the Advanced view's field picker offers, by key (order.amount,agent.bot_likelihood_score; the keys ofGET /v1/embed/rules/catalog), each listed once. A new condition in the session reads one of them; a rule it edits keeps the fields it already reads (anything else is400 rules_embed_out_of_scope). Absent: every field of the kind's catalog. Not onmandate_limits. savesenumdraft(the default): a save waits to be published.publishneeds modepublish. One ofdraft,publish.draft_groupstring | null- Sandbox only (
400in live): an opaque label up to 64 characters that keeps one group's drafts from another's.
filtersobject- The list widgets only: filters pinned for the session, which the browser can't change (another value is
400 embed_filter_pinned).capture_list: any ofstatus,item_type,source,destination,case_id,created_gteandcreated_lte, with the values the capture request list takes.checkout_list: any ofoutcome(which also takesin_review),approval_status,order_id,created_gteandcreated_lte, with the values the checkout assessment list takes.run_list: any ofstatus(one value, or several separated by commas),q,created_gteandcreated_lte, with the values the run list takes.traffic_list: any ofoutcome,classandbot_likelihood(each one value, or several separated by commas),signed,created_gteandcreated_lte, with the values the traffic assessment list takes.Show child attributes
statusstringcapture_list: the request's status (pending,in_progress,completed,expired,cancelled).run_list: the run's status (active,halted,ended), one or several separated by commas.item_typeenum- An item type the request asks for. One of
photo,selfie,id_document,video. sourceenum- How an item was taken. One of
browser,native_sdk. destinationenum- Where the link opened. One of
company_app,provenance_app,app_clip,web. case_idstring- Your case reference, for example one case's requests.
created_gtetimestamp- Created at or after this time.
created_ltetimestamp- Created at or before this time.
outcomestringcheckout_list: the outcome (allow,challenge,reject;frictionlessis still accepted), orin_review(an approval waiting for your review).traffic_list: the decision (allow,block,log_only,rate_limit,challenge,require_intent), one or several separated by commas.approval_statusenumcheckout_list: the cart approval's status. One ofpending,in_review,approved,denied,expired.order_idstringcheckout_list: orders whose reference contains this text.qstringrun_list: runs whose name or ID contains this text.classstringtraffic_list: Identify's class (signed_agent,declared_bot,suspected_bot,likely_human,unknown), one or several separated by commas.signedenumtraffic_list: the agent signature verified, or didn't. One oftrue,false.bot_likelihoodstringtraffic_list: the bot likelihood band (low,medium,high,unclassified), one or several separated by commas.
Returns
Promise<EmbedToken> The embed token, what it allows and when it expires.
HTTP operation
POST /v1/embed/tokens: Create an embed token
Errors
- authentication_required
- embed_object_kind_mismatch
- invalid_json
- parameter_invalid
- parameter_missing
- plan_required
- rate_limit_exceeded
- resource_missing
- rules_embed_rule_missing
- usage_limit_reached
Example
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/embed/tokens`, {
method: "POST",
headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
body: JSON.stringify({ "widget": "embed", "object_id": "portal-check", "ttl": 600 }),
})).json();import os
import httpx
api = os.environ["PROVENANCE_API"]
data = httpx.post(f"{api}/v1/embed/tokens", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
"widget": "embed",
"object_id": "portal-check",
"ttl": 600
}).json()