Use this method to cancel a specific insurance policy. Provide the cancellation effective date, reason, and target status in the input representation, along with the ID of the policy to cancel. The policy is canceled synchronously, and the response includes the transaction ID, impacted policy versions, and any errors.
Example
The Apex example shows how to use the ConnectApi.InsuranceBrokerageFamily.cancelInsurancePolicy() method to cancel a specific insurance policy.
Class Definition
This Apex example shows how to cancel an insurance policy.
1global class CancelConnectDriver{23 global static void callCancelConnectAPI(){4 Map<String, Object>input = new Map<String, Object>();5 input.put('policyId', '0YTxx000000001dGAA');67 ConnectApi.InsurancePolicyCancellationInputRepresentation cancelInput = new ConnectApi.InsurancePolicyCancellationInputRepresentation();8 cancelInput.cancellationEffectiveDate = '2026-07-01';9 cancelInput.status = 'Cancelled';10 cancelInput.cancellationReason = 'Customer Request';1112 input.put('policyInput', cancelInput);1314 Map<String, Object>output = new Map<String, Object>();15 Map<String, Object>args = new Map<String, Object>();16 args.put('input', input);17 args.put('output', output);1819 CancelTestConnectAPI callable = new CancelTestConnectAPI();20 Object result = callable.call('cancel', args);2122 ConnectApi.InsurancePolicyCancellationRepresentation policyData =23(ConnectApi.InsurancePolicyCancellationRepresentation)result;24 System.debug('Cancel Policy Data: ' + JSON.serializePretty(policyData));2526 if(output.containsKey('error')){27 System.debug('Error: ' + output.get('error'));28}29}30}
Usage Example
Use the CancelTestConnectAPI class to execute the cancel action and process the result.