---
schema_version: "1"
id: 93da178b589419f68aed61ffe1a6ebb17e90382d61c89cc81422dc522da7962e
title: Composite Subrequest
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/api-rest/guides/resources/resources-composite-graph-composite-subrequest.md
canonical_url: https://developer.salesforce.com/docs/platform/api-rest/guide/resources-composite-graph-composite-subrequest.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 512adc0a66944f9cf67f95bd309d4538ffbd4386d52d98a3aef22c53e12a2e89
products:
  - REST API Developer Guide
  - Platform Developer Content
---

# Composite Subrequest

The composite subrequest describes a subrequest to execute with the Composite Graph resource.

## Properties

|Name|Type|Description|
|----|----|-----------|
|`body`|Varies|Optional. The input body for the subrequest. The contents depend on the request specified in the `url` property. Referenceable types are DateTime, String, Boolean, Byte, Character, Short, Integer, Long, Double, and Float.|
|`method`|String|Required. The method to use with the requested resource. Possible values are DELETE, GET, PATCH, and POST (case-sensitive). For a list of valid methods, refer to the documentation for the requested resource. This method is distinct from the POST method that is used to submit the composite graph request. The method specified here is the one that operates (within the graph) on the resource specified in the `url`.|
|`referenceId`|String|Required. Reference ID that maps to the subrequest’s response and can be used to reference the response in later subrequests. You can reference the `referenceId` in either the body or URL of a subrequest. Use this syntax to include a reference: `@{referenceId.FieldName}`. You can use two operators with the reference ID. The `.` operator references a field on a JSON object in the response. For example, say you retrieve an account record’s data in one subrequest and assign the reference ID `Account1Data` to the output. You can refer to the account’s name in later subrequests like this: `@{Account1Data.Name}`. The `[]` operator indexes a JSON collection in the response. For example, say you request basic account information with the sObject Basic Information resource in one subrequest and assign the reference ID `AccountInfo` to the output. Part of the response includes a collection of recently created accounts. You can refer to the ID of the first account in the recent items collection like this: `@{AccountInfo.recentItems[0].Id}`. You can use each operator recursively as long as it makes sense in the context of the response. For example, to refer to the billing city component of an account’s compound address field: `@{NewAccount.BillingAddress.city}`. `referenceId` is case-sensitive, so pay close attention to the case of the fields you’re referring to. See [Usage](#usage). The `referenceId` must start with a letter or a number, and must not contain anything besides letters, numbers, or underscores (’\_’).|
|`url`|String|Required. The resource to request. The URL can include any query string parameters that the subrequest supports. The query string must be URL-encoded. You can use parameters to filter response bodies. The version number `XX.X` must be 50.0 or later.|

The methods supported for `method` depend on the `url`:

-   If the `url` is `/services/data/vXX.X/sobject/sObject` then POST is supported. (See [sObject Basic Information](https://developer.salesforce.com/docs/platform/api-rest/guide/resources-sobject-basic-info.md).)
-   If the `url` is ` /services/data/vXX.X/sobject/sObject/id` then DELETE, GET, and PATCH are supported. (See [sObject Rows](https://developer.salesforce.com/docs/platform/api-rest/guide/resources-sobject-retrieve.md).)
-   If the `url` is `/services/data/vXX.X/sobject/sObject/customFieldName/externalId` then DELETE, GET, PATCH, and POST are supported. You can use PATCH to upsert via an external ID). See [Insert or Update (Upsert) a Record Using an External ID](https://developer.salesforce.com/docs/platform/api-rest/do-me/dome-upsert.md).

Only the following values are supported for `url`:

-   `/services/data/vXX.X/sobject/sObject`
-   `/services/data/vXX.X/sobject/sObject/id`
-   `/services/data/vXX.X/sobject/sObject/customFieldName/externalId`

## Examples

The following is an example of a `POST` subrequest.

```nolang
{
   "body" : {
     "Name" : "Sample Account"
   },
   "method" : "POST",
   "referenceId" : "refAccount",
   "url" : "/services/data/v68.0/sobjects/Account"
}
```

The following is an example of a `GET` subrequest.

```nolang
{
   "method" : "GET",
   "referenceId" : "NewAccountFields",
   "url" : "/services/data/v68.0/sobjects/Account/@{refAccount.id}"
}
```

## Usage

Because `referenceId` is case-sensitive, it’s important to note the case of the fields that you’re referring to. The same field can use different cases in different contexts. For example, when you create a record, the ID field appears as `id` in the response. But when you access a record’s data with the sObject Rows resource, the ID field appears as `Id`. In the Example 2, the `@{refAccount.id}` reference is valid because `refAccount` refers to the response from a POST like that shown in Example 1. If you use `Id` instead (mixed case rather than all lowercase), as in `@{refAccount.Id}`, you get an error when sending the request because the reference ID uses the wrong case.

When processing a composite graph request, if the number of graph failures exceeds the maximum limit of 14, processing is halted for the remaining graphs in the request. The response includes errors for the failed graphs, and the status for the remaining graphs is shown as `PROCESSING_HALTED`. See [Composite Graph Limits](https://developer.salesforce.com/docs/platform/api-rest/guide/resources-composite-graph-limits.md) for the current limits.

## Results

Results for subrequests are the same as that for other Composite requests. See [Composite Subrequest Result](https://developer.salesforce.com/docs/platform/api-rest/guide/resources-composite-subrequest-result.md).

