Generate document
Generate a document from a template and case data using the appropriate rendering engine
Overview
The Document Generation activity generates a PDF document by rendering a template with case-specific input data. It returns the raw PDF content — the handler is responsible for storing it in file storage and constructing the attachment metadata for state.
Usage
Called once per document to generate. The handler iterates over documentsToGenerate in each document package and calls this activity for each.
Handler responsibilities:
- Select the
generatorfor this document (e.g.,STACC_DOCUMENT_GENERATION,SPAMA) - Narrow the relevant standard-model entities from case state into
inputData - Call this activity with
generator,templateName, andinputData - Receive the PDF buffer
- Store it via
fileStorage.storeFile() - Construct attachment metadata and update state
Request
- Endpoint:
/document-generation/generate - Method:
POST
Request body:
- generator (required): Which document generation engine to use (
STACC_DOCUMENT_GENERATION,SPAMA, or others) - templateName (required): Template identifier, e.g.,
ACCEPTANCE_LETTER,CUSTOMER_LETTER,FIXED_RATE_AGREEMENT - inputData (required): Template-specific data payload built from narrowed standard-model types
Input Data
The inputData is built from narrowed subsets of standard-model types. The handler selects which entities are relevant for each template and strips fields the template does not need.
For example, an acceptance letter might include:
- parties — narrowed to names and NIN (from
Party.personalInformation) - financing.loanAgreements — narrowed to loan amount, interest rate, and repayment period
- collateralObjects — narrowed to address
A mortgage deed would instead focus on collateral objects, agreements, and cadastre data.
The full standard-model structures are not sent — only the subset each template requires.
Template names are identifiers configured in the template management system (e.g., control panel). The list is not finite — new templates can be added without changes to this adapter. Examples of existing templates:
CUSTOMER_LETTER— Parties, financing terms, addressesACCEPTANCE_LETTER— Agreement details, acceptance termsFIXED_RATE_AGREEMENT— Interest rates, repayment termsMORTGAGE_DEED— Collateral details, ownership, cadastre dataPLEDGE_DECLARATION— Collateral agreement, guarantor info
Response
- Content-Type:
application/pdf - Body: Raw PDF document as binary stream
Data Flow
- Handler narrows standard-model entities from case state into
inputData POST /document-generation/generatewith generator, templateName, and inputData- Adapter renders template and returns PDF buffer
- Handler stores in fileStorage, constructs metadata, and updates state