---
schema_version: "1"
id: 1d2f9c3367964c50293e17bad72b43fea1ce491ae8f40f93bd484ef6765d3e30
title: Update Records Using sObject Collections
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/api-rest/guides/resources/resources-composite-sobjects-collections-update.md
canonical_url: https://developer.salesforce.com/docs/platform/api-rest/guide/resources-composite-sobjects-collections-update.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 3a8859a109fbe33eff6402017319f81c67459845c607e1d44053d2ca65fd40a1
products:
  - REST API Developer Guide
  - Platform Developer Content
---

# Update Records Using sObject Collections

Use a PATCH request with sObject Collections to update up to 200 records, returning a list of SaveResult objects. You can choose whether to roll back the entire request when an error occurs.

-   The list can contain up to 200 objects.
-   The list can contain objects of different types, including custom objects.
-   Each object must contain an attributes map. The map must contain a value for `type`.

    **note:** Using sObject Collections to update blob data requires more values in the attributes map. For more information, see [Using sObject Collections to Insert a Collection of Blob Records](https://developer.salesforce.com/docs/platform/api-rest/do-me/dome-sobject-insert-update-blob.md#using-sobject-collections-to-insert-a-collection-of-blob-records).

-   Each object must contain an `id` field with a valid ID value.
-   Objects are updated in the order they’re listed. The SaveResult objects are returned in the order in which the update requests were specified.
-   If the request body includes objects of more than one type, they are processed as chunks. For example, if the incoming objects are `{account1, account2, contact1, account3}`, the request is processed in three chunks: `{{account1, account2}, {contact1}, {account3}}.` A single request can process up to 10 chunks.
-   You can’t update records for multiple object types in one call when one of those types is related to a feature in the Salesforce Setup area.

If the request isn’t well formed, the API returns a `400 Bad Request` HTTP Status. Fix the syntax of the request and try again. If the request is well formed, the API returns a `200 OK` HTTP Status. If an item was processed successfully, the `success` flag shows for that item. Error information is returned in the `errors` array.

## Syntax

**URI:** `/services/data/vXX.X/composite/sobjects/`

**Formats:** JSON, XML

**HTTP Method:** PATCH

**Authentication:** `Authorization: Bearer token`

**Parameters**

|Parameter|Description|
|---------|-----------|
|`allOrNone`|Optional. Indicates whether to roll back the entire request when the update of any object fails (`true`) or to continue with the independent update of other objects in the request. The default is `false`.|
|`records`|Required. A list of records. Set the `id` and `type` attribute for each record.|

**Note:** If the sObject Collections request is embedded in a Composite request, the Composite request’s `allOrNone` parameter can also affect the results. See [allOrNone Parameters in Composite and Collections Requests](https://developer.salesforce.com/docs/platform/api-rest/guide/resources-composite-allornone.md).

## Example

**Example Request**

```nolang
curl -X PATCH https://MyDomainName.my.salesforce.com/services/data/v68.0/composite/sobjects/ -H "Authorization: Bearer token" -H "Content-Type: application/json" -d "@exampleRequestBody.json"
```

**Example Request Body**

```nolang
{
   "allOrNone" : false,
   "records" : [{
      "attributes" : {"type" : "Account"},
      "id" : "001xx000003DGb2AAG",
      "NumberOfEmployees" : 27000
   },{
      "attributes" : {"type" : "Contact"},
      "id" : "003xx000004TmiQAAS",
      "Title" : "Lead Engineer"
   }]
}

```

**Example Response Body**

```nolang
HTTP/1.1 200 OK

[
   {
      "id" : "001RM000003oCprYAE",
      "success" : true,
      "errors" : [ ]
   },
   {
      "id" : "003RM0000068og4YAA",
      "success" : true,
      "errors" : [ ]
   }
]

```

**Example Response Body (Some Items Failed and `allOrNone` is `false`)**

```nolang
HTTP/1.1 200 OK

[
   {
      "id" : "001RM000003oCprYAE",
      "success" : true,
      "errors" : [ ]
   },
   {
      "success" : false,
      "errors" : [
         {
            "statusCode" : "MALFORMED_ID",
            "message" : "Contact ID: id value of incorrect type: 001xx000003DGb2999",
            "fields" : [
               "Id"
            ]
         }
      ]
   }
]

```

**Example Response Body (Some Items Failed and `allOrNone` is `true`)**

```nolang
HTTP/1.1 200 OK

[
   {
      "id" : "001RM000003oCprYAE",
      "success" : false,
      "errors" : [
         {
            "statusCode" : "ALL_OR_NONE_OPERATION_ROLLED_BACK",
            "message" : "Record rolled back because not all records were valid and the request was using AllOrNone header",
            "fields" : [ ]
         }
      ]
   },
   {
      "success" : false,
      "errors" : [
         {
            "statusCode" : "MALFORMED_ID",
            "message" : "Contact ID: id value of incorrect type: 001xx000003DGb2999",
            "fields" : [
               "Id"
            ]
         }
      ]
   }
]

```

