Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
postInsuranceCreateContacts(createContactsInputParam, createPortalUsers)
API Version
65.0
Requires Chatter
No
Signature
public static ConnectApi.InsuranceContactsAndUsersCreationRepresentation postInsuranceCreateContacts(ConnectApi.InsuranceContactsAndUsersCreationInputRepresentation createContactsInputParam, Boolean createPortalUsers)
Parameters
- createContactsInputParam
- Type: ConnectApi.InsuranceContactsAndUsersCreationInputRepresentation
- Details to create contacts and users.
- createPortalUsers
- Type: Boolean
- Indicates whether to create portal users for the new contacts (true) or not (false). The default value is false.
Return Value
Type: ConnectApi.InsuranceContactsAndUsersCreationRepresentation
Example
Here's an example of how to invoke the Insurance Create Contracts API from Apex code.
1// Create Group Benefits Contract via Connect API (simple version)
2
3// 1) Create the top-level input
4ConnectApi.InsuranceContractCreationInputRepresentation input =
5 new ConnectApi.InsuranceContractCreationInputRepresentation();
6
7// Required: Quote Id to convert
8input.quoteId = '0Q0xx0000004C9QCAU';
9
10// Optional dates (ISO-8601 strings)
11input.contractStartDate = '2026-01-01';
12input.contractEndDate = '2026-12-31';
13input.enrollmentStartDate = '2025-12-01';
14input.enrollmentEndDate = '2025-12-31';
15// Optional: contract term in months
16// input.contractTerm = 12;
17
18// 2) (Optional) Additional fields per contract item (e.g., per quote line)
19// Build a map-like structure using InsuranceApexStringMapInputRepresentation
20List<ConnectApi.InsuranceApexStringRepresentation> fieldPairs = new List<ConnectApi.InsuranceApexStringRepresentation>();
21ConnectApi.InsuranceApexStringRepresentation kv1 = new ConnectApi.InsuranceApexStringRepresentation();
22kv1.key = 'CustomerSignedTitle';
23kv1.value = 'Mr';
24fieldPairs.add(kv1);
25
26// One contract item (repeat and add to the list for more)
27ConnectApi.ContractItem item = new ConnectApi.ContractItem();
28item.entity = 'Contract'; // e.g., 'ContractLineItem__c' (use your org’s API name)
29// item.instanceKey = 'QLI-1'; // unique identification key from Quote Line Item
30item.fields = fieldPairs;
31
32// Wrap into list and assign to input.additionalFields
33input.additionalFields = new List<ConnectApi.ContractItem>{ item };
34
35// 3) Execute the Contract Creation API
36try {
37 ConnectApi.InsuranceContractCreationOutputRepresentation result =
38 ConnectApi.InsuranceGroupBenefitsFamily.postInsuranceGBQuoteToContract(input);
39
40 System.debug('Contract creation result: ' + JSON.serializePretty(result));
41} catch (Exception e) {
42 System.debug('Error while creating contract: ' + e.getMessage());
43}