postInsuranceContractEndorse(contractEndorseInputParam)

Create an endorsed contract version from a quote for a mid-term adjustment.

API Version

68.0

Requires Chatter

No

Signature

public static ConnectApi.InsuranceContractEndorseRepresentation postInsuranceContractEndorse(ConnectApi.InsuranceContractEndorseInputRepresentation contractEndorseInputParam)

Parameters

contractEndorseInputParam
Type: ConnectApi.InsuranceContractEndorseInputRepresentation
Quote ID, endorsement effective date, optional date-copy behavior, and additional fields used to create the endorsed contract.

Usage

Use this method to create an endorsed contract version from a quote. The method carries forward existing contract and contract group plan details and links the new version to the previous contract. Specify the quote in quoteId and the endorsement start date in effectiveDate using yyyy-MM-dd format.

Set updateExistingContractDates to true or omit it to copy the source contract end date onto the endorsed contract. Set it to false to skip copying the end date.

To stamp additional fields on Contract, InsuranceContract, or ContractGroupPlan, add items to additionalFields. For a contract group plan, set productPath to identify where in the product hierarchy the fields apply.

This method runs synchronously. Check isSuccess and contractId on the response. Errors are in the errors property.

Example

This example creates an endorsed contract from a quote, sets the endorsement effective date, and stamps enrollment dates on the insurance contract.

1// Create an endorsed contract version from a quote.
2
3final String SOURCE_QUOTE_ID = '0Q0SB000000w6zV0AQ';
4final String EFFECTIVE_DATE = '2026-09-01';   // yyyy-MM-dd
5
6// Optional: additional fields for Contract / InsuranceContract / ContractGroupPlan.
7ConnectApi.InsuranceApexStringRepresentation enrollmentStart =
8    new ConnectApi.InsuranceApexStringRepresentation();
9enrollmentStart.key = 'EnrollmentStartDate';
10enrollmentStart.value = '2026-09-01';
11
12ConnectApi.InsuranceApexStringRepresentation enrollmentEnd =
13    new ConnectApi.InsuranceApexStringRepresentation();
14enrollmentEnd.key = 'EnrollmentEndDate';
15enrollmentEnd.value = '2026-09-30';
16
17ConnectApi.InsuranceContractItem insuranceContractItem = new ConnectApi.InsuranceContractItem();
18insuranceContractItem.entity = 'InsuranceContract';
19// insuranceContractItem.productPath = 'Health/Dental';
20insuranceContractItem.fields = new List<ConnectApi.InsuranceApexStringRepresentation>{
21    enrollmentStart, enrollmentEnd
22};
23
24ConnectApi.InsuranceContractEndorseInputRepresentation input =
25    new ConnectApi.InsuranceContractEndorseInputRepresentation();
26input.quoteId = SOURCE_QUOTE_ID;
27input.effectiveDate = EFFECTIVE_DATE;
28// input.updateExistingContractDates = true;  // optional; default true copies source contract end date
29input.additionalFields = new List<ConnectApi.InsuranceContractItem>{ insuranceContractItem };
30
31try {
32    ConnectApi.InsuranceContractEndorseRepresentation result =
33        ConnectApi.InsuranceGroupBenefitsFamily.postInsuranceContractEndorse(input);
34
35    System.debug('isSuccess: ' + result.isSuccess);
36    System.debug('contractId: ' + result.contractId);
37    System.debug('message: ' + result.message);
38    System.debug('errors: ' + result.errors);
39} catch (Exception e) {
40    System.debug('Error while endorsing the contract: ' + e.getMessage());
41}