Collection Modules
Build and publish versioned premium collection logic for policies on Root.
Overview
Build collection modules to control how policies collect premiums, handle payment failures, integrate with payment providers, and respond to Root lifecycle events.
A collection module is TypeScript code that runs your premium collection strategy. For example, a card collection module might charge a card on the policy's billing day, retry failed payments after 3 days, and lapse the policy after 3 consecutive failures.
When a policy is issued, Root links it to a specific collection module definition (a versioned snapshot of the module code). Later edits and publishes create new definitions, but they do not change the behaviour of policies already linked to older definitions.
Code structure
Collection modules use standard Node.js modules. Use import and export to share variables and functions between files, and organise code into folders such as utils/, types/, or providers/.
Authoring workflow
Author collection modules with the Workbench CLI:
- Write the module locally.
- Push changes to update the draft.
- Test the draft in the sandbox environment.
- Publish the draft to create a new live version.
Draft and live versions
A collection module has one draft version and one or more live versions. Pushing changes updates the draft. Publishing promotes the draft to a new live version used in production.
Older live versions can still serve policies that were issued against them, while the latest live version is used for newly issued policies that use that collection module.
Where to go next
- Create a collection module to clone a starter template locally.
- Build a collection module to configure settings, lifecycle hooks, and UI components.
- Publish a collection module version to promote a tested draft to a live version.
- Link the collection module to a product module so policies can use it for payment collection.
Updated 11 days ago