### Persona Inquiry Configuration Examples Source: https://docs.withpersona.com/2025-12-08/react-native-sdk-v2-integration-guide Demonstrates various ways to configure and start a Persona inquiry, including using template IDs, reference IDs, custom fields, and inquiry IDs. ```javascript // Configuration with only a template ID Inquiry.fromTemplate("itmpl_EXAMPLE").build().start(); // Configuration with only a template ID in the sandbox Inquiry.fromTemplate("itmpl_EXAMPLE") .environment(Environment.SANDBOX) .build() .start(); // Configuration with a template and reference ID Inquiry.fromTemplate("itmpl_EXAMPLE") .referenceId("myUser_123") .build() .start(); // Configuration passing fields to profile data into the inquiry. // Refer to the field schema for a given template in the Persona Dashboard. Inquiry.fromTemplate("itmpl_EXAMPLE") .fields( Fields.builder() .string('nameFirst', 'Alexander') .string('nameLast', 'Example') .build(), ) .build() .start(); // Configuration with only an inquiry ID Inquiry.fromInquiry("inq_EXAMPLE").build().start(); // Configuration resuming an inquiry session with an access token Inquiry.fromInquiry("inq_EXAMPLE") .sessionToken("SOME_SESSION_TOKEN") .build() .start(); ``` -------------------------------- ### Create Account with Go SDK Source: https://docs.withpersona.com/api-reference/accounts/create-an-account This Go code example shows how to make a POST request to create an account. Replace '' with your API token. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.withpersona.com/api/v1/accounts" payload := strings.NewReader("{}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Retrieve Generic Document with C# Source: https://docs.withpersona.com/api-reference/documents/retrieve-a-generic-document This C# example uses the RestSharp library to make a GET request to the API. Ensure you have the RestSharp NuGet package installed. ```csharp using RestSharp; var client = new RestClient("https://api.withpersona.com/api/v1/document/generics/document-id"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Retrieve Generic Document with Swift Source: https://docs.withpersona.com/api-reference/documents/retrieve-a-generic-document A Swift example demonstrating how to set up an NSMutableURLRequest for a GET request to the API, including the Authorization header. ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.withpersona.com/api/v1/document/generics/document-id")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" ``` -------------------------------- ### Install Backend Dependencies Source: https://docs.withpersona.com/2025-12-08/tutorial-embedded-flow-precreate Commands to create and activate a Python virtual environment, then install the required dependencies from the requirements.txt file. ```bash # Create a virtual environment cd embedded-flow-precreate-demo/backend/ python -m venv venv # Activate the virtual environment source venv/bin/activate # Install dependencies pip install -r requirements.txt ``` -------------------------------- ### Install Backend Dependencies Source: https://docs.withpersona.com/2025-12-08/tutorial-ios-sdk-precreate Commands to set up a Python virtual environment and install the necessary backend dependencies using pip. ```bash # Create a virtual environment cd ios-demo-backend python -m venv venv # Activate the virtual environment source venv/bin/activate # Install dependencies pip install -r requirements.txt ``` -------------------------------- ### Retrieve a Case Template (JavaScript) Source: https://docs.withpersona.com/api-reference/case-templates/retrieve-a-case-template Utilize the `fetch` API to perform a GET request. This example demonstrates handling the response and potential errors. ```JavaScript const url = 'https://api.withpersona.com/api/v1/case-templates/case-template-id'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### Build and Install Demo App Source: https://docs.withpersona.com/quickstart-android-webview Clone the open-source Persona Android WebView demo app and install it from the command line. ```shell $ git clone https://github.com/persona-id/persona-android-webview $ cd persona-android-webview $ ./gradlew installDebug ``` -------------------------------- ### Retrieve Generic Document with PHP Source: https://docs.withpersona.com/api-reference/documents/retrieve-a-generic-document Using GuzzleHttp in PHP to fetch document data. This example requires the GuzzleHttp library to be installed via Composer. ```php request('GET', 'https://api.withpersona.com/api/v1/document/generics/document-id', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` -------------------------------- ### List All Inquiries cURL Example Source: https://docs.withpersona.com/2025-12-08/api-reference/inquiries/list-all-inquiries Use this cURL command to make a GET request to the /api/v1/inquiries endpoint. Ensure you include your Bearer token for authentication. ```bash $ curl https://api.withpersona.com/api/v1/inquiries \ -H "Authorization: Bearer " ``` -------------------------------- ### Full Relay Gateway Service Workflow Example Source: https://docs.withpersona.com/2025-12-08/relay-gateway-service-usage A comprehensive example using curl to demonstrate the complete workflow: creating a relay session, issuing a privacy pass, and redeeming the claim. ```bash # Step 1 — Create a Relay session curl -X POST https:///relays \ -H "Content-Type: application/json" \ -d '{ "claim-type": "age_over18_united_kingdom", "encryption-key-pem": "" }' # ---- Widget handles user verification on the frontend ---- # Step 2 — Issue a Privacy Pass curl -X POST https:///relays/privacy-passes \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -H "Persona-Relay-Secret: " \ -d '{ "relay-token": "" }' # Step 3 — Redeem and retrieve the claim curl -X POST https:///relays//redeem \ -H "Content-Type: application/json" \ -H "Persona-Relay-Secret: " \ -d '{ "privacy-pass-token": "" }' ``` -------------------------------- ### Start NodeJS Webhook Server Source: https://docs.withpersona.com/2025-12-08/quickstart-webhooks Command to start the NodeJS webhook server using npm. ```bash npm start ``` -------------------------------- ### List Inquiry Templates (JavaScript) Source: https://docs.withpersona.com/api-reference/inquiry-templates/list-all-inquiry-templates Fetch inquiry templates using the fetch API. This example demonstrates making a GET request with the required Authorization header. ```javascript const url = 'https://api.withpersona.com/api/v1/inquiry-templates'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### List All Events using Swift Source: https://docs.withpersona.com/api-reference/events/list-all-events This Swift example uses URLSession to make a GET request to the events API. It configures the request with headers and handles the response. ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.withpersona.com/api/v1/events")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Create Backend Directory Source: https://docs.withpersona.com/2025-12-08/tutorial-ios-sdk-precreate Create a new directory for your backend application and navigate into it. ```bash mkdir ios-demo-backend cd ios-demo-backend ``` -------------------------------- ### Inquiry API Response without Signals Source: https://docs.withpersona.com/2025-12-08/inquiry-signals Example of a `GET /api/v1/inquiries/:id` response when inquiry signals are not enabled or no signals are available. The `signals` array is empty. ```json { "data": { "id": "inq_abc123", "type": "inquiry", "attributes": { "status": "approved", "signals": [] } } } ``` -------------------------------- ### Inquiry API Response with Signals Source: https://docs.withpersona.com/2025-12-08/inquiry-signals Example of a `GET /api/v1/inquiries/:id` response when inquiry signals are enabled and available. The `signals` array is populated with signal objects. ```json { "data": { "id": "inq_abc123", "type": "inquiry", "attributes": { "status": "approved", "signals": [ { "name": "inquiry/bot_score", "value": 42 }, { "name": "inquiry/behavior_threat_level", "value": "low" } ] } } } ``` -------------------------------- ### Start Local Python Server Source: https://docs.withpersona.com/2025-12-08/tutorial-embedded-flow-inquiry-template This command starts a local HTTP server in the specified directory, useful for hosting static web pages during development. ```bash cd embedded-flow-demo/ python -m http.server 8000 ``` -------------------------------- ### Install Persona Node.js SDK Source: https://docs.withpersona.com/2025-12-08/relay-sdk-quickstart Install the Persona Node.js SDK using npm. ```bash npm install @persona/sdk-node ``` -------------------------------- ### Retrieve Inquiry with C# (RestSharp) Source: https://docs.withpersona.com/api-reference/inquiries/retrieve-an-inquiry This C# example utilizes the RestSharp library to make a GET request for inquiry information. Replace '' with your actual API token. ```csharp using RestSharp; var client = new RestClient("https://api.withpersona.com/api/v1/inquiries/inquiry-id"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Select Inquiry Environment Source: https://docs.withpersona.com/2025-12-08/ios-sdk-v2-integration-guide Choose the environment for an inquiry. Defaults to `.production`. Use `.sandbox` for development or specify a sandbox environment by ID. ```swift let inquiry = Inquiry.from(templateId: "itmpl_EXAMPLE", delegate: delegate) .environment(.sandbox) // Optional: pin to a specific environment by ID // .environmentId("env_EXAMPLE") .build() ``` -------------------------------- ### Retrieve Country List Item (Swift) Source: https://docs.withpersona.com/api-reference/list-items/retrieve-a-country-list-item An example in Swift using URLSession to perform a GET request. It configures the request with the necessary Authorization header and handles the response. ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.withpersona.com/api/v1/list-item/countries/list-item-id")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Print Inquiry PDF with C# (RestSharp) Source: https://docs.withpersona.com/api-reference/inquiries/print-an-inquiry-pdf A C# example using the RestSharp library to execute a GET request for printing an inquiry. It adds the Authorization header to the request. ```csharp using RestSharp; var client = new RestClient("https://api.withpersona.com/api/v1/inquiries/inquiry-id/print"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Start Webhook Server Source: https://docs.withpersona.com/quickstart-webhooks Starts the Python Flask webhook server. ```bash python webhook-server.py ``` -------------------------------- ### Print Inquiry PDF with Ruby Source: https://docs.withpersona.com/api-reference/inquiries/print-an-inquiry-pdf A Ruby example using Net::HTTP to send a GET request for printing an inquiry. It handles SSL and sets the Authorization header. ```ruby require 'uri' require 'net/http' url = URI("https://api.withpersona.com/api/v1/inquiries/inquiry-id/print") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` -------------------------------- ### Start the Backend Server Source: https://docs.withpersona.com/2025-12-08/tutorial-embedded-flow-precreate Commands to navigate to the backend directory and start the Python server. Keep this terminal open while the application is running. ```bash cd embedded-flow-precreate-demo/backend python server.py ``` -------------------------------- ### Initialize and Load Persona WKWebView Source: https://docs.withpersona.com/quickstart-ios-wkwebview Set up a WKWebView with necessary configurations and load the Persona verification URL. Ensure `allowsInlineMediaPlayback` is true for proper camera flow. Customize the URL with your environment, template IDs, and redirect URI. ```swift // Create the web view and show it private lazy var webView: WKWebView = { let config = WKWebViewConfiguration() // allowsInlineMediaPlayback is required, as it defaults to false on some devices like iPads. // If unset, will cause the camera capture flow to be fullscreen instead of inline. config.allowsInlineMediaPlayback = true let webView = WKWebView(frame: .zero, configuration: config) return webView }() webView.navigationDelegate = self webView.allowsBackForwardNavigationGestures = false webView.scrollView.bounces = false // Add the web view and set up its contstraints view.addSubview(webView) webView.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ webView.leadingAnchor.constraint(equalTo: view.leadingAnchor), webView.trailingAnchor.constraint(equalTo: view.trailingAnchor), webView.topAnchor.constraint(equalTo: view.topAnchor), webView.bottomAnchor.constraint(equalTo: view.bottomAnchor) ]) // Add the Persona configuration options as query items. // See the Persona docs ( for full documentation. var components = URLComponents(string: ""] let request = NSMutableURLRequest(url: NSURL(string: "https://api.withpersona.com/api/v1/api-logs")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### OnboardingViewModel Swift Implementation Source: https://docs.withpersona.com/2025-12-08/tutorial-ios-sdk-precreate This Swift class manages the state and logic for the onboarding and verification process. It handles starting verification, processing responses, and managing completion or cancellation events. Ensure your backend URL is correctly configured for the simulator or a physical device. ```swift import Foundation import Combine import Persona2 @MainActor class OnboardingViewModel: ObservableObject { @Published var isLoading = false @Published var errorMessage: String? @Published var showPersonaFlow = false @Published var showSuccess = false @Published var inquiryId: String? @Published var sessionToken: String? @Published var completedInquiryId: String? @Published var completedInquiryStatus: String? // Replace with your backend URL // For iOS Simulator: use http://localhost:8000 // For physical device: use your computer's IP address (e.g., http://192.168.1.100:8000) private let backendURL = "http://localhost:8000/api/inquiries/get-or-create" func startVerification() async { isLoading = true errorMessage = nil guard let url = URL(string: backendURL) else { errorMessage = "Invalid server URL" isLoading = false return } var request = URLRequest(url: url) request.httpMethod = "POST" request.setValue("application/json", forHTTPHeaderField: "Content-Type") do { let (data, _) = try await URLSession.shared.data(for: request) let response = try JSONDecoder().decode(InquiryResponse.self, from: data) inquiryId = response.inquiryId sessionToken = response.sessionToken showPersonaFlow = true } catch { errorMessage = "Failed to verify: \(error.localizedDescription)" } isLoading = false } func handleCompletion(inquiryId: String, status: String) { print("Verification completed. Inquiry ID: \(inquiryId), Status: \(status)") completedInquiryId = inquiryId completedInquiryStatus = status showPersonaFlow = false showSuccess = true } func handleCancellation() { print("User cancelled verification") showPersonaFlow = false } func handleEvent(_ event: InquiryEvent) { switch event { case .start(let startEvent): print("Inquiry started: \(startEvent.inquiryId) with session token: \(startEvent.sessionToken)") case .pageChange(let pageChangeEvent): print("Page changed to: \(pageChangeEvent.name)") default: print("Inquiry event: \(event)") } } func handleError(_ error: Error) { print("Verification error: \(error.localizedDescription)") showPersonaFlow = false errorMessage = "Verification failed. Please try again." } } struct InquiryResponse: Codable { let inquiryId: String let sessionToken: String? enum CodingKeys: String, CodingKey { case inquiryId = "inquiry_id" case sessionToken = "session_token" } } ``` -------------------------------- ### Retrieve Account using Python Source: https://docs.withpersona.com/2025-12-08/api-reference/accounts/retrieve-an-account?explorer=true This Python code example shows how to make a GET request to retrieve account details. Remember to substitute 'account-id' and your API key. ```python import requests url = "https://api.withpersona.com/api/v1/accounts/account-id" headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.get(url, headers=headers) if response.status_code == 200: print(response.json()) else: print(f"Error: {response.status_code}") ``` -------------------------------- ### Start Persona Inquiry from Template Source: https://docs.withpersona.com/react-native-sdk-integration-guide Initiate the Persona Inquiry flow using a template ID. This example demonstrates setting the environment, handling success, cancellation, failure, and errors. ```typescript import Inquiry, {Environment} from 'react-native-persona'; // ...