Use Case: Assembling a Document Using an Interview
Use this workflow when you need to collect user input through a HotDocs interview and use that data to assemble documents.
Overview
- To display an interview, you use a combination of REST API calls and the Core Assembly Service (CAS) JavaScript API. The REST API manages work items and versions, while the CAS renders the interview in your application.
- All REST operations require a valid access token.
- Document assembly occurs only after the work item version is completed.
API Call Sequence
Step 1 - Create a work item
Start by creating a work item. This defines the template and acts as the container for answer data and assembled documents.
Endpoint: POST /WorkItems
Purpose: Create a new work item for your template.
See: Creating a work item
Step 2 - Create a work item version
Create a new version of the work item to start an assembly session. Each version represents a distinct instance of document assembly.
Endpoint: POST /WorkItems/{workItemId}/Versions
Purpose: Start an assembly session for the work item.
See: Creating a new work item version
Step 3 - Display an interview
Use the Core Assembly Service JavaScript API to embed the interview in your web application. CAS:
- renders the interview UI
- handles navigation and validation
- saves answers back to HotDocs Advance
Before calling the Advance API to complete the work item version, you must finish the current interview session in the Core API.
Endpoint: Core API /ipi/session/<CoreSessionId>/finishcurrentinterview
Purpose: Signals that the interview session is complete and prepares CAS for assembly.
Step 4 - Complete the work item version
When the user finishes the interview, complete the work item version. This triggers document assembly and creates a new answer set.
Endpoint: POST /WorkItems/{workItemId}/Versions/{versionId}/Complete
Purpose: Finalize the version and assemble documents.
See: Completing a work item version
Step 5 - Download assembled documents
Query the API for the assembled documents and download them by handling the response stream.
Endpoint: GET /WorkItems/{workItemId}/Versions/{versionId}/Documents
Purpose: Retrieve assembled documents.