Endorse Multi-Root Insurance Policy Action

Create an endorsement for an existing multi-root insurance policy to apply updates or changes to the policy and its associated child policies.

This action is available in API version 66.0 and later.

Supported REST HTTP Methods 

URI: /services/data/vXX.X/actions/standard/endorseMultiRootInsPolicy

Where XX.X is the latest API version.

Formats: JSON, XML

HTTP Methods: POST

Authentication: Authorization: Bearer TOKEN

Where TOKEN is your OAuth access token.

Inputs 

InputTypeDescription
endorseMultiRootPolicyInputRepApex-definedRequired. An Apex ConnectApi.EndorseMultiRootPolicyInputRep record that contains the details of the policy to be endorsed. To calculate billing, specify billingRecord details if Career Billing is enabled in your org.

Outputs 

OutputTypeDescription
jobIdentifierstringA unique system-generated ID for the job that processes the endorsement of the multi-root insurance policy.

Example 

POST

This sample request is for the Endorse Multi-Root Insurance Policy action.

1{
2  "inputs": [
3    {
4      "endorseMultiRootPolicyInputRep": {
5        "contextId": "5dbc40312f69b2d8cb4e7042a700d06f32fc5b9df7de3eabc94aa19a66ed77b3",
6        "policyId": "0YTxx00000001IfGAI",
7        "effectiveDate": "2024-06-06",
8        "insurancePolicy": {
9          "policyName": "Endorsed Test Auto Ins policy",
10          "policyNumber": "PLC5678987"
11        },
12        "transactionRecord": {
13          "name": "Endorsed Policy Transaction"
14        },
15        "billingRecord": {
16           "billDayOfMonth": 15,
17            "billToContact": "003xx000000001aEAA"
18        },
19        "additionalInput": [
20          {
21            "instanceKey": "AutoBundle2",
22            "additionalFieldsList": [
23              {
24                "key": "AssetDescription__c",
25                "value": "Test_AssetDescription__c"
26              },
27              {
28                "key": "SourceSystem",
29                "value": "Test_SourceSystem"
30              }
31            ]
32          },
33          {
34            "instanceKey": "AutoDriver",
35            "additionalFieldsList": [
36              {
37                "key": "ParticipantName",
38                "value": "Test_ParticipantName"
39              },
40              {
41                "key": "Participant_Hometown__c",
42                "value": "Test_Participant_Hometown__c"
43              }
44            ]
45          },
46          {
47            "instanceKey": "AutoRoot",
48            "additionalFieldsList": [
49              {
50                "key": "Primary_Policy_Holder__c",
51                "value": "Test_Primary_Policy_Holder__c"
52              },
53              {
54                "key": "PolicyDescription",
55                "value": "Test_PolicyDescription"
56              }
57            ]
58          },
59          {
60            "instanceKey": "AutoBundle2_AutoComp1",
61            "additionalFieldsList": [
62              {
63                "key": "Coverage_Description__c",
64                "value": "Test_Coverage_Description__c"
65              },
66              {
67                "key": "Description",
68                "value": "Test_Description"
69              }
70            ]
71          }
72        ]
73      }
74    }
75  ]
76}

This is a sample code to call the Endorse Multi-Root Insurance Policy action from Apex.

1public with sharing class MultiRootPolicyEndorsementInvocable {
2    
3    /**
4     * Execute Multi-Root Policy Endorsement with parameters map
5     * Usage: MultiRootPolicyEndorsementInvocable.executeMultiRootEndorsement(paramsMap);
6     * 
7     * @param params Map of parameters:
8     *   - contextId (String, REQUIRED)
9     *   - policyId (String, REQUIRED)
10     *   - effectiveDate (String, REQUIRED)
11     *   - policyName (String, optional)
12     *   - policyNumber (String, optional)
13     *   - transactionName (String, optional)
14     *   - additionalFields (Map<String, Map<String, String>>, optional)
15     */
16    public static void executeMultiRootEndorsement(Map<String, Object> params) {
17        // Extract and validate contextId (REQUIRED)
18        String contextId = (String) params.get('contextId');
19        if (String.isBlank(contextId)) {
20            System.debug('ERROR: contextId is required');
21            return;
22        }
23        
24        // Extract and validate policyId (REQUIRED)
25        String policyId = (String) params.get('policyId');
26        if (String.isBlank(policyId)) {
27            System.debug('ERROR: policyId is required');
28            return;
29        }
30        
31        
32        // Extract and validate effectiveDate (REQUIRED)
33        String effectiveDate = (String) params.get('effectiveDate');
34        if (String.isBlank(effectiveDate)) {
35            System.debug('ERROR: effectiveDate is required');
36            return;
37        }
38        
39        // Multi-Root Endorse Policy IA - Create the standard Invocable Action
40        Invocable.Action action = Invocable.Action.createStandardAction('endorseMultiRootInsPolicy');
41        
42        // Instantiate the IA input object for Multi-Root Policy Endorsement
43        // IMPORTANT: Use EndorseMultiRootPolicyInputRep, NOT EndorsePolicyIAInputRep
44        ConnectApi.EndorseMultiRootPolicyInputRep policyInput = 
45            new ConnectApi.EndorseMultiRootPolicyInputRep();
46        
47        // Set context ID (REQUIRED)
48        policyInput.contextId = contextId;
49
50        // Set policy ID (REQUIRED)
51        policyInput.policyId = policyId;
52        
53        // Set effectiveDate (REQUIRED)
54        policyInput.effectiveDate = effectiveDate;
55        
56        // Extract optional parameters
57        String policyName = (String) params.get('policyName');
58        String policyNumber = (String) params.get('policyNumber');
59        String transactionName = (String) params.get('transactionName');
60        Map<String, Map<String, String>> additionalFields = 
61            (Map<String, Map<String, String>>) params.get('additionalFields');
62        
63        // Populate Insurance Policy details (using IA classes) - all optional
64        if (!String.isBlank(policyName) || !String.isBlank(policyNumber)) {
65            
66            ConnectApi.InsPolicyIAInputRep insurancePolicy = 
67                new ConnectApi.InsPolicyIAInputRep();
68            
69            if (!String.isBlank(policyName)) {
70                insurancePolicy.policyName = policyName;
71            }
72            if (!String.isBlank(policyNumber)) {
73                insurancePolicy.policyNumber = policyNumber;
74            }
75            policyInput.insurancePolicy = insurancePolicy;
76        }
77        
78        // Populate Transaction record (using IA transaction representation) - optional
79        if (!String.isBlank(transactionName)) {
80            ConnectApi.InsPolicyTrxnIAInputRep transactionRecord = 
81                new ConnectApi.InsPolicyTrxnIAInputRep();
82            transactionRecord.name = transactionName;
83            policyInput.transactionRecord = transactionRecord;
84        }
85        
86        // Populate additional input for multi-root policies - optional
87        if (additionalFields != null && !additionalFields.isEmpty()) {
88            List<ConnectApi.InsPolicyAddlInputIARep> additionalInputList = new List<ConnectApi.InsPolicyAddlInputIARep>();
89            
90            for (String instanceKey : additionalFields.keySet()) {
91                ConnectApi.InsPolicyAddlInputIARep additionalInput = 
92                    new ConnectApi.InsPolicyAddlInputIARep();
93                
94                // Set instance key (e.g., "AutoSilver", "familyHealth")
95                additionalInput.instanceKey = instanceKey;
96                
97                // Build additional fields list for this instance
98                Map<String, String> fieldsMap = additionalFields.get(instanceKey);
99                if (fieldsMap != null && !fieldsMap.isEmpty()) {
100                    List<ConnectApi.AdditionalFieldIARep> fieldsList = new List<ConnectApi.AdditionalFieldIARep>();
101                    
102                    for (String fieldKey : fieldsMap.keySet()) {
103                        ConnectApi.AdditionalFieldIARep field = new ConnectApi.AdditionalFieldIARep();
104                        field.key = fieldKey;
105                        field.value = fieldsMap.get(fieldKey);
106                        fieldsList.add(field);
107                    }
108                    
109                    additionalInput.additionalFieldsList = fieldsList;
110                }
111                
112                additionalInputList.add(additionalInput);
113            }
114            
115            policyInput.additionalInput = additionalInputList;
116        }
117        
118        // Set invocation parameters
119        // IMPORTANT: Parameter name is endorseMultiRootPolicyInputRep (camelCase)
120        action.setInvocationParameter('endorseMultiRootPolicyInputRep', policyInput);
121        
122        System.debug('Starting Multi-Root Policy Endorsement Invocable Action (endorseMultiRootInsPolicy)...');
123        System.debug('Context ID: ' + contextId);
124        if (!String.isBlank(policyName)) {
125            System.debug('Policy Name: ' + policyName);
126        }
127        
128        try {
129            // Invoke the action
130            List<Invocable.Action.Result> results = action.invoke();
131            
132            System.debug('Multi-Root Policy Endorsement IA result = ' + results);
133            
134            // Process results
135            for (Invocable.Action.Result result : results) {
136                if (result.isSuccess()) {
137                    System.debug('SUCCESS: Multi-Root Policy Endorsement completed successfully!');
138                    Object outputValue = result.getOutputParameters().get('jobIdentifier');
139                    if (outputValue != null) {
140                        System.debug('Job Identifier: ' + outputValue);
141                    } else {
142                        System.debug('Multi-Root Policy Endorsement job started - result: ' + result.getOutputParameters());
143                    }
144                } else {
145                    System.debug('ERROR: Multi-Root Policy Endorsement failed');
146                    System.debug('Error Details: ' + result.getErrors());
147                }
148            }
149            
150        } catch (Exception e) {
151            System.debug('EXCEPTION in Multi-Root Policy Endorsement Invocable Action: ' + e.getMessage());
152            System.debug('Stack Trace: ' + e.getStackTraceString());
153        }
154    }
155}
156
157/*
158 * USAGE EXAMPLE:
159 * Copy and paste this code into Developer Console Execute Anonymous Window
160 */
161Map<String, Object> params = new Map<String, Object>();
162params.put('contextId', '0000000i18tq18g002917629276616310d09368a7cb24db687f6fd95af4b9954');
163params.put('policyId', '0YTSM0000001MzN4AU');
164params.put('policyName', 'James Multi-Root Policy Apex IA');
165params.put('effectiveDate', '2026-08-01');
166params.put('transactionName', 'Endorsement Second');
167
168
169// Build additional fields configuration
170Map<String, Map<String, String>> additionalFields = new Map<String, Map<String, String>>();
171
172// Configuration for AutoSilver instance
173Map<String, String> autoFields = new Map<String, String>();
174autoFields.put('PolicyName', 'James Auto Policy IA Apex');
175autoFields.put('Name', 'James Auto Policy');
176additionalFields.put('AutoSilver', autoFields);
177
178// Configuration for FamilyHealth instance
179Map<String, String> healthFields = new Map<String, String>();
180healthFields.put('PolicyName', 'James Medical Policy IA Apex');
181healthFields.put('Name', 'James Medical Policy');
182healthFields.put('Email__c', 'medical@james.co');
183additionalFields.put('familyHealth', healthFields);
184
185params.put('additionalFields', additionalFields);
186
187MultiRootPolicyEndorsementInvocable.executeMultiRootEndorsement(params);

This sample response is for the Endorse Multi-Root Insurance Policy action.

1[
2  {
3    "actionName": "endorseMultiRootInsPolicy",
4    "errors": null,
5    "invocationId": null,
6    "isSuccess": true,
7    "outcome": null,
8    "outputValues": {
9      "jobIdentifier": "750x00000000001AAA"
10    },
11    "sortOrder": -1,
12    "version": 1
13  }
14]