Method: people.batchUpdateContacts
Stay organized with collections
Save and categorize content based on your preferences.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-08-06 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-08-06 UTC."],[[["\u003cp\u003eUpdate a batch of up to 200 contacts and optionally receive a map of updated contact data.\u003c/p\u003e\n"],["\u003cp\u003eSpecify which fields to update using \u003ccode\u003eupdateMask\u003c/code\u003e and which fields to return using \u003ccode\u003ereadMask\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eSequential requests for the same user are recommended to avoid latency and failures.\u003c/p\u003e\n"],["\u003cp\u003eRequires the \u003ccode\u003ehttps://www.googleapis.com/auth/contacts\u003c/code\u003e OAuth scope for authorization.\u003c/p\u003e\n"],["\u003cp\u003eThe API uses the \u003ccode\u003ePOST\u003c/code\u003e method and the \u003ccode\u003ehttps://people.googleapis.com/v1/people:batchUpdateContacts\u003c/code\u003e endpoint.\u003c/p\u003e\n"]]],["This describes how to use a `POST` request to `https://people.googleapis.com/v1/people:batchUpdateContacts` for updating multiple contacts. The request body requires a `contacts` map (resource name to contact data), an `updateMask` (fields to update), and a `readMask` (fields to return). Optionally, a `sources` enum may be included. The response contains an `updateResult` map, listing each updated contact with their resource name. The request is limited to 200 contacts, and sequentially to the same user. The auth scope needed is `https://www.googleapis.com/auth/contacts`.\n"],null,["# Method: people.batchUpdateContacts\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Request body](#body.request_body)\n - [JSON representation](#body.request_body.SCHEMA_REPRESENTATION)\n- [Response body](#body.response_body)\n - [JSON representation](#body.BatchUpdateContactsResponse.SCHEMA_REPRESENTATION)\n- [Authorization scopes](#body.aspect)\n- [Try it!](#try-it)\n\nUpdate a batch of contacts and return a map of resource names to PersonResponses for the updated contacts.\n\nMutate requests for the same user should be sent sequentially to avoid increased latency and failures.\n\n### HTTP request\n\n`POST https://people.googleapis.com/v1/people:batchUpdateContacts`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Request body\n\nThe request body contains data with the following structure:\n\n| JSON representation |\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"contacts\": { string: { object (/people/api/rest/v1/people#Person) }, ... }, \"updateMask\": string, \"readMask\": string, \"sources\": [ enum (/people/api/rest/v1/ReadSourceType) ] } ``` |\n\n| Fields ||\n|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `contacts` | `map (key: string, value: object (`[Person](/people/api/rest/v1/people#Person)`))` Required. A map of resource names to the person data to be updated. Allows up to 200 contacts in a single request. An object containing a list of `\"key\": value` pairs. Example: `{ \"name\": \"wrench\", \"mass\": \"1.3kg\", \"count\": \"3\" }`. |\n| `updateMask` | `string (`[FieldMask](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask)` format)` Required. A field mask to restrict which fields on the person are updated. Multiple fields can be specified by separating them with commas. All specified fields will be replaced, or cleared if left empty for each person. Valid values are: - addresses - biographies - birthdays - calendarUrls - clientData - emailAddresses - events - externalIds - genders - imClients - interests - locales - locations - memberships - miscKeywords - names - nicknames - occupations - organizations - phoneNumbers - relations - sipAddresses - urls - userDefined |\n| `readMask` | `string (`[FieldMask](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask)` format)` Required. A field mask to restrict which fields on each person are returned. Multiple fields can be specified by separating them with commas. If read mask is left empty, the post-mutate-get is skipped and no data will be returned in the response. Valid values are: - addresses - ageRanges - biographies - birthdays - calendarUrls - clientData - coverPhotos - emailAddresses - events - externalIds - genders - imClients - interests - locales - locations - memberships - metadata - miscKeywords - names - nicknames - occupations - organizations - phoneNumbers - photos - relations - sipAddresses - skills - urls - userDefined |\n| `sources[]` | `enum (`[ReadSourceType](/people/api/rest/v1/ReadSourceType)`)` Optional. A mask of what source types to return. Defaults to [READ_SOURCE_TYPE_CONTACT](/people/api/rest/v1/ReadSourceType#ENUM_VALUES.READ_SOURCE_TYPE_CONTACT) and [READ_SOURCE_TYPE_PROFILE](/people/api/rest/v1/ReadSourceType#ENUM_VALUES.READ_SOURCE_TYPE_PROFILE) if not set. |\n\n### Response body\n\nIf not successful, returns [BatchUpdateContactsErrorDetails](/people/api/rest/v1/BatchUpdateContactsErrorDetails), a list of errors corresponding to each contact.\n\nThe response to a request to update a batch of contacts.\n\nIf successful, the response body contains data with the following structure:\n\n| JSON representation |\n|----------------------------------------------------------------------------------------------|\n| ``` { \"updateResult\": { string: { object (/people/api/rest/v1/PersonResponse) }, ... } } ``` |\n\n| Fields ||\n|----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `updateResult` | `map (key: string, value: object (`[PersonResponse](/people/api/rest/v1/PersonResponse)`))` A map of resource names to the contacts that were updated, unless the request `readMask` is empty. An object containing a list of `\"key\": value` pairs. Example: `{ \"name\": \"wrench\", \"mass\": \"1.3kg\", \"count\": \"3\" }`. |\n\n### Authorization scopes\n\nRequires the following OAuth scope:\n\n- `https://www.googleapis.com/auth/contacts`\n\nFor more information, see the [Authorization guide](/workspace/guides/configure-oauth-consent)."]]