DocumentationAPI Reference
DocumentationAPI ReferenceOpenAPIStatus

Methods

Use the client's methods to show or hide the embedded flow.

<!-- Replace "X.Y.Z" with the Inquiry SDK version you want to use. -->
<script src="https://cdn.withpersona.com/dist/persona-vX.Y.Z.js"></script>

<script>
  const client = new Persona.Client({
    templateId: "<your template ID starting with itmpl_>",
    environmentId: "<your template ID starting with env_>",
    onComplete: ({ inquiryId, status, fields }) => {
      // Inquiry completed. Optionally tell your server about it.
      console.log(`Sending finished inquiry ${inquiryId} to backend`);
      fetch(`/server-handler?inquiry-id=${inquiryId}`);
    }
  });
  
  function openClient() { client.open(); }
  function cancelClient() { client.cancel(true); }
</script>
MethodDescription
open()Use client.open() to show the embedded flow.
cancel(force: boolean)Use client.cancel(false) to transition to the cancel confirmation screen. Use client.cancel(true) to instantly hide the the embedded flow without displaying the cancel confirmation screen.
destroy()Use client.destroy() to clean up all Persona DOM elements from the page once you are finished using the flow.

If your integration creates more than one instance of the Persona client, this method should be called when finished using each client to avoid memory leaks.