---
schema_version: "1"
id: a41d126406e3ce3cb801c0cb3b2dcb293979739009f4a4cf4604a82df78fa845
title: Improve Performance with the Composite Resource
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/api_tooling/tooling_resources_composite_composite.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_resources_composite_composite.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 9eb72e076bbdbba6fe34129fed1c65b883b023deb2249e6191b5e6cc8fd63dfc
description: Use the /composite resource to improve the performance of a development tool or app built with Tooling API. This resource executes a series of Tooling API requests in a single call, minimizing the number of round trips needed between the client and server. You can use the output of one request as the input to a subsequent request. The requests’ response bodies and HTTP statuses are returned in a single response body. The entire request counts as a single call toward your API limits. Available in API version 40.0 and later.
---
# Improve Performance with the Composite Resource

Use the /composite resource to improve the performance of a development tool or app built with Tooling API. This resource executes a series of Tooling API requests in a single call, minimizing the number of round trips needed between the client and server. You can use the output of one request as the input to a subsequent request. The requests’ response bodies and HTTP statuses are returned in a single response body. The entire request counts as a single call toward your API limits. Available in API version 40.0 and later.

For the most current API limit information, see the Salesforce Developer Limits Quick Reference. Contractual limits may also apply, as per your Salesforce contract.

The requests in a composite call are called subrequests. The subrequests are executed in the context of the same user.

In a subrequest’s body, you specify a reference ID that maps to the subrequest’s response. You can then refer to the ID in the url or body fields of later subrequests by using a JavaScript-like reference notation.

You can specify whether an error in a subrequest causes the entire composite request to roll back or just the subrequests that depend on it. You can also specify headers for each subrequest.

The following resources support composite.

- All sObject resources (vXX.X/tooling/sobjects/)
- The Query resource (vXX.X/tooling/query/?q=soql)

![Note](https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/images/icon_note.png)

#### Note

You can have up to 25 subrequests in a single call. Up to five of these subrequests can be query operations.

## Syntax

**URI**: /vXX.X/composite

**Formats**: JSON

**HTTP method**: GET (lists other available composite resources), POST

**Authentication**: Authorization: Bearer token

**Parameters**: None required

**Request body**: [Composite Request Body](https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_requests_composite_composite.htm "Describes a collection of subrequests to execute with the /composite resource.")

**Response body**: [Composite Response Body](https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_responses_composite_composite.htm "Describes the result of a /composite request.")

## Example

The following composite request body includes five subrequests.

- The first subrequest creates a MetadataContainer.
- The second subrequest creates an ApexClassMember.
- The third subrequest creates a ContainerAsyncRequest and starts the asynchronous deployment process.
- The fourth subrequest gets the created ContainerAsyncRequest.
- The fifth subrequest gets the created MetadataContainer.

The five subrequests count as a single call toward the API limit.

{
  "allOrNone":false,
  "compositeRequest":
  \[
    {
     "method":"POST",
     "body":{
       "Name":"MetadataContainer Unique Name"
     },
     “url":"/services/data/v40.0/tooling/sobjects/metadatacontainer/",
     "referenceId":"metadatacontainer\_reference\_id"
    },
    {
     "method":"POST",
     "body":{
       "contententityid":"<ID of an ApexClass you want to update>" ,
       "fullname":"ApexClassMemberUniqueFullName",
       "body":"public class Classtest2test {}",
       "MetadataContainerId":"@{metadatacontainer\_reference\_id.id}"
     },
     "url":"/services/data/v40.0/tooling/sobjects/apexclassmember/",
     "referenceId":"apexclassmember\_reference\_id"
    },
    {
     "method":"POST",
     "body":{
       "IsCheckOnly":"false",
       "MetadataContainerId":"@{metadatacontainer\_reference\_id.id}"
     },
     "url":"/services/data/v40.0/tooling/sobjects/containerasyncrequest/",
     "referenceId":"containerasyncrequest\_reference\_id"
    },
    {
     "method":"GET",
   "url":"/services/data/v40.0/tooling/sobjects/containerasyncrequest/@{containerasyncrequest\_reference\_id.id}",
     "referenceId":"containerasyncrequest\_GET\_reference\_id"
    },
    {
     "method":"GET",
     "url":"/services/data/v40.0/tooling/sobjects/metadatacontainer/@{metadatacontainer\_reference\_id.id}",
     "referenceId":"metadatacontainer\_GET\_reference\_id"
    }
  \]
}

- **[Composite Request Body](https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_requests_composite_composite.htm)**  
    Describes a collection of subrequests to execute with the /composite resource.
- **[Composite Response Body](https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_responses_composite_composite.htm)**  
    Describes the result of a /composite request.

#### See Also

- [REST API Developer Guide](https://developer.salesforce.com/docs/atlas.en-us.264.0.api_rest.meta/api_rest/resources_composite.htm "REST API Developer Guide - HTML (New Window)")