Tutorial: Unique Hosted Flow links via API
Tutorial: Unique Hosted Flow links via API
Tutorial: Unique Hosted Flow links via API
There are three ways to use Hosted Flow:
This guide walks you through the third method: creating unique links via Persona’s API. This is the method we recommend you use at scale.
You will:
To learn how to use the other two no-code methods, see the Help Center guide on Hosted Flow.
You’ll need access to:
Before you start, you should:
A user named Alexander Sample just joined your dog walking app as a dog walker. You want to verify his identity to ensure the safety of users on your service.
Alexander’s user ID in your app is “usr_ABC123”. During account signup in your app, he stated his birthdate is August 31, 1977.
Every inquiry is created from an inquiry template, which defines details like the specific verification logic and UI text and branding of that inquiry. You can think of inquiry templates as a mold that lets you create many inquiries.
Persona offers a suite of solutions that include preconfigured inquiry templates. In this tutorial, use the “KYC” solution to verify your dog walkers.
Follow these instructions to add the “KYC” solution to your Sandbox environment.
Find the ID of the newly-created inquiry template.
In the Persona dashboard, navigate to Inquiries > Templates. Find the “KYC” template in the list of inquiry templates, and note the value in the ID field. The value should begin with itmpl_.
Now, create an inquiry for Alexander Sample using the “KYC” inquiry template.
Make a POST request to /api/v1/inquiries:
This code demonstrates two best practices when creating inquiries:
reference-id. A reference ID lets you tag an inquiry as being associated with a particular end user. Persona recommends using the user’s UID from your internal systems.After you make this request, you should receive a JSON object as the response. The JSON has the following shape:
In the JSON, locate the top-level id field. This is the ID of the created inquiry, and it should begin with inq_. We’ll need this value in the next step.
Create Alexander’s unique verification link by combining the following base URL with your inquiry ID:
https://inquiry.withpersona.com/verify?inquiry-id=inq_XXXXXXXXXXXXX
Replace inq_XXXXXXXXXXXXX with the inquiry ID from Step 3.
This URL directs Alexander to a personalized verification flow with his information pre-filled. You can visit this URL to test that it works—but don’t start the verification yet. We’ll do that in Step 7. (Note: you’ll see a warning about being in a Sandbox environment. This is expected because you’re using Sandbox for testing.)
You can receive notifications when any inquiry’s state changes. For example, you can be alerted when any inquiry is started by a user, or when any inquiry is completed. See the full list of inquiry events you can be alerted about.
To receive automatic notifications:
inquiry.started, inquiry.completed, inquiry.approved, inquiry.declined, and inquiry.failedFor this tutorial, you can skip webhooks and view results in the dashboard.
Now you’re ready to share the Hosted Flow inquiry link with Alexander Sample. In a real production situation, you could share the link programmatically (e.g. within a user flow in your dog walking app, or via a programmatic SMS/email) or even manually (e.g. via an SMS/email) if you’re working at a small scale.
For this tutorial, you don’t actually have to send the link to anyone—you can pretend to be Alexander.
In production, Alexander would click the link and complete verification on his own.
For this tutorial, you’ll complete the flow yourself as Alexander:
Note: by default, an inquiry will expire if not completed within 24 hours. See Inquiry expiration for details.
If you set up the webhook in Step 5, check your server logs. You should see events from inquiry.started, inquiry.completed, and inquiry.approved.
Note: If you want to receive the inquiry.failed event, you can create a second inquiry using the curl command from Step 3. Then click through the verification flow, this time with the “Pass verifications” toggle disabled.
Now that you’ve completed the inquiry, take a look at the results. Note that because this inquiry was created in Sandbox, some of the data will be demo data.
Retrieve the inquiry details:
The response includes:
data.attributes.reference-id: The reference ID you provideddata.attributes.status: Should be approveddata.attributes.fields: Pre-filled and collected dataNote that:
approved instead of completed because the KYC solution includes Workflows that automatically approve passing inquiries. See the Next Steps section to learn more.Alternative: View in Dashboard You can also view results in the dashboard at Inquiries > All Inquiries. See this Help Center guide for details.
In this tutorial, you:
This is a complete API-based Hosted Flow integration.
To learn more, check out the following resources:
fields object in the Create Inquiry API doc, under request > data > attributes > fields.completed to approved.