---
schema_version: "1"
id: 84f275dd2952768b56d59a308cd6b4d4600ba352a7b133f2208780151e8c309f
title: patchInsuranceUpdateCensus(updateCensusInputParam, contractId)
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/insurance_developer_guide/apex_ConnectAPI_InsuranceGroupBenefitsFamily_patchInsuranceUpdateCensus.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.insurance_developer_guide.meta/insurance_developer_guide/apex_ConnectAPI_InsuranceGroupBenefitsFamily_patchInsuranceUpdateCensus.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: cf6479b7c81fba4789c28aff215b2f7433bc7c4ff7546ce2eabebdb00a4e428d
description: Update a group census from policy enrollments and endorsements on an existing group benefits contract.
---
# patchInsuranceUpdateCensus(updateCensusInputParam, contractId)

Update a group census from policy enrollments and endorsements on an existing group benefits contract.

## API Version

68.0

## Requires Chatter

No

## Signature

public static ConnectApi.InsuranceRefreshCensusRepresentation patchInsuranceUpdateCensus(ConnectApi.InsuranceRefreshCensusInputRepresentation updateCensusInputParam, String contractId)

## Parameters

**updateCensusInputParam**

- Type: [ConnectApi.InsuranceRefreshCensusInputRepresentation](https://developer.salesforce.com/docs/atlas.en-us.insurance_developer_guide.meta/insurance_developer_guide/apex_connectapi_input_insurance_refresh_census.htm "Input representation of the group census ID, date range, optional filters, and update options used to refresh a group census from policy enrollments and endorsements on a contract.")
- Group census ID, date range, optional filters, and update options used to refresh the group census.

**contractId**

- Type: String
- ID of the insurance contract whose policy enrollments and endorsements are used to update the group census.

## Return Value

Type: [ConnectApi.InsuranceRefreshCensusRepresentation](https://developer.salesforce.com/docs/atlas.en-us.insurance_developer_guide.meta/insurance_developer_guide/apex_connectapi_output_insurance_refresh_census.htm "Output representation that's returned when you start updating a group census from policy enrollments and endorsements on a group benefits contract.")

## Usage

Use this method to update a group census from policy enrollments and endorsements on an existing group benefits contract. Specify the contract in contractId and the census in groupCensusId. Set startDate and endDate in yyyy-MM-dd format to define the enrollment and endorsement window. Set policyEffectiveDate in the same format to select the policy version. The date must fall between the version's effectiveFromDate and effectiveToDate.

This method runs asynchronously and returns a requestId that you can use to track the job. To retry a failed run, pass that requestId with the same groupCensusId.

Use filter to limit the update to root contract group plans, contacts, or person accounts. Set shouldGenerateCSV to create a CSV file of the updated census details. Set shouldIncludeMemberPlans to include insurance plan details for each member. To stamp additional field values on group census members, add items to groupCensusAdditionalFields.

Check isSuccess, groupCensusId, and requestId on the response. Errors are in the errors property.

## Example

This example starts updating a group census from a contract for a date range, filters by person account, stamps an additional census field, and includes member plan details and a CSV file.

// Update a group census from policy enrollments and endorsements on a contract.

final String CONTRACT\_ID = '800SB00001HNnddYAD';

// Optional: filter by members and/or root contract group plans.
ConnectApi.InsuranceCensusFilterInputRepresentation filter =
    new ConnectApi.InsuranceCensusFilterInputRepresentation();
filter.objectName = 'PersonAccount';
filter.recordIds = new List<String\>{ '001SB00001wg2zZYAQ' };
// filter.contractGroupPlanIds = new List<String>{ /\* optional: root contract group plan IDs \*/ };

ConnectApi.InsuranceApexStringRepresentation sourceSystem =
    new ConnectApi.InsuranceApexStringRepresentation();
sourceSystem.key = 'SourceSystemName';
sourceSystem.value = 'new';

ConnectApi.InsuranceRefreshCensusInputRepresentation input =
    new ConnectApi.InsuranceRefreshCensusInputRepresentation();
input.groupCensusId = '0rfSB000000505pYAA';
input.startDate = '2026-07-04';
input.endDate = '2026-08-10';
input.policyEffectiveDate = '2026-12-12';
input.shouldIncludeMemberPlans = true;
input.shouldGenerateCSV = true;
input.filter = filter;
input.groupCensusAdditionalFields = new List<ConnectApi.InsuranceApexStringRepresentation>{
    sourceSystem
};
// input.requestId = '08Pxx0000000001EAA';  // only to retry records that failed in a previous run

try {
    ConnectApi.InsuranceRefreshCensusRepresentation result =
        ConnectApi.InsuranceGroupBenefitsFamily.patchInsuranceUpdateCensus(input, CONTRACT\_ID);

    System.debug('isSuccess: ' + result.isSuccess);
    System.debug('groupCensusId: ' + result.groupCensusId);
    System.debug('requestId: ' + result.requestId);
    System.debug('message: ' + result.message);
    System.debug('errors: ' + result.errors);
} catch (Exception e) {
    System.debug('Error while updating the census: ' + e.getMessage());
}