---
schema_version: "1"
id: 34b16b6bd179e68702b3a815e3a8da4d24b5615b1101063e13e47c3ccedaad7f
title: Composite Graph
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.md
canonical_url: https://developer.salesforce.com/docs/platform/api-rest/guide/resources-composite-graph.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: ca54bd2235a81abf88b692c365447c2ef7ef2493788a431e4e60e6a88d660e29
products:
  - REST API Developer Guide
  - Platform Developer Content
---

# Composite Graph

The composite graph resource lets you submit composite graph operations. This resource is available in REST API version 50.0 and later.

**note:** The response bodies and HTTP statuses of the requests are returned in a single response body. The entire request counts as a single call toward your API limits.

## Syntax

**URI:** `/services/data/vXX.X/composite/graph`

**Formats:** JSON

**HTTP methods:** POST

**Authentication:** `Authorization: Bearer token`

**Request parameters:** None

## Request Body

```nolang
{
    "graphs" : [
        {
            "graphId" : "graphId",
            "compositeRequest" : [
                compositeSubrequest,
                compositeSubrequest,
        ...
                ]
        }
    ]
}
```

where each `compositeSubrequest` is a [composite subrequest](https://developer.salesforce.com/docs/platform/api-rest/guide/resources-composite-graph-composite-subrequest.md).

## Response Body

```nolang
{
    "graphs" : [
        {
            "graphId" : "graphId",
            "graphResponse" : {
                "compositeResponse" : [
                    compositeSubrequestResult,
                    compositeSubrequestResult,
                    compositeSubrequestResult,
                    ...
                ]
            },
            "isSuccessful" : flag
        },
        ...
    ]
}
```

| Name                | Type                                                                               | Description                                                              |
| ------------------- | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| `graphs`            | Array of graph responses.                                                          |                                                                          |
| `graphId`           | String                                                                             | The identifier of the graph.                                             |
| `graphResponse`     | Object                                                                             | The response of the request.                                             |
| `compositeResponse` | Array of [composite subrequest results](https://developer.salesforce.com/docs/platform/api-rest/guide/resources-composite-subrequest-result.md). | Results for each node in the graph.                                      |
| `isSuccessful`      | Boolean                                                                            | Whether this graph was processed successfully (`true`) or not (`false`). |

## Example

**Example Request**

```nolang
curl -X POST https://MyDomainName.my.salesforce.com/services/data/v68.0/composite/graph -H "Authorization: Bearer token" -H "Content-Type: application/json" -d "@graphRequestBody.json"
```

**Example Request Body**

```nolang
{
    "graphs" : [
        {
            "graphId" : "1",
            "compositeRequest" : [
                {
                    "url" : "/services/data/v68.0/sobjects/Account/",
                    "body" : {
                        "name" : "Cloudy Consulting"
                    },
                    "method" : "POST",
                    "referenceId" : "reference_id_account_1"
                },
                {
                    "url" : "/services/data/v68.0/sobjects/Contact/",
                    "body" : {
                        "FirstName" : "Nellie",
                        "LastName" : "Cashman",
                        "AccountId" : "@{reference_id_account_1.id}"
                    },
                    "method" : "POST",
                    "referenceId" : "reference_id_contact_1"
                },
                {
                    "url" : "/services/data/v68.0/sobjects/Opportunity/",
                    "body" : {
                        "CloseDate" : "2024-05-22",
                        "StageName" : "Prospecting",
                        "Name" : "Opportunity 1",
                        "AccountId" : "@{reference_id_account_1.id}"
                    },
                    "method" : "POST",
                    "referenceId" : "reference_id_opportunity_1"
                }
            ]
        },
        {
            "graphId" : "2",
            "compositeRequest" : [
                {
                    "url" : "/services/data/v68.0/sobjects/Account/",
                    "body" : {
                        "name" : "Easy Spaces"
                    },
                    "method" : "POST",
                    "referenceId" : "reference_id_account_2"
                },
                {
                    "url" : "/services/data/v68.0/sobjects/Contact/",
                    "body" : {
                        "FirstName" : "Charlie",
                        "LastName" : "Dawson",
                        "AccountId" : "@{reference_id_account_2.id}"
                    },
                    "method" : "POST",
                    "referenceId" : "reference_id_contact_2"
                }
            ]
        }
    ]
}

```

**Example Response Body**

```nolang
{
   "graphs" : [
      {
         "graphId" : "1",
         "graphResponse" : {
            "compositeResponse" : [
               {
                  "body" : {
                     "id" : "001R00000064wc7IAA",
                     "success" : true,
                     "errors" : [ ]
                  },
                  "httpHeaders" : {
                     "Location" : "/services/data/v68.0/sobjects/Account/001R00000064wc7IAA"
                  },
                  "httpStatusCode" : 201,
                  "referenceId" : "reference_id_account_1"
               },
               {
                  "body" : {
                     "id" : "003R000000DDMlTIAX",
                     "success" : true,
                     "errors" : [ ]
                  },
                  "httpHeaders" : {
                     "Location" : "/services/data/v68.0/sobjects/Contact/003R000000DDMlTIAX"
                  },
                  "httpStatusCode" : 201,
                  "referenceId" : "reference_id_contact_1"
               },
               {
                  "body" : {
                     "id" : "006R0000003FPYxIAO",
                     "success" : true,
                     "errors" : [ ]
                  },
                  "httpHeaders" : {
                     "Location" : "/services/data/v68.0/sobjects/Opportunity/006R0000003FPYxIAO"
                  },
                  "httpStatusCode" : 201,
                  "referenceId" : "reference_id_opportunity_1"
               }
            ]
         },
         "isSuccessful" : true
      },
      {
         "graphId" : "2",
         "graphResponse" : {
            "compositeResponse" : [
               {
                  "body" : {
                     "id" : "001R00000064wc8IAA",
                     "success" : true,
                     "errors" : [ ]
                  },
                  "httpHeaders" : {
                     "Location" : "/services/data/v68.0/sobjects/Account/001R00000064wc8IAA"
                  },
                  "httpStatusCode" : 201,
                  "referenceId" : "reference_id_account_2"
               },
               {
                  "body" : {
                     "id" : "003R000000DDMlUIAX",
                     "success" : true,
                     "errors" : [ ]
                  },
                  "httpHeaders" : {
                     "Location" : "/services/data/v68.0/sobjects/Contact/003R000000DDMlUIAX"
                  },
                  "httpStatusCode" : 201,
                  "referenceId" : "reference_id_contact_2"
               }
            ]
         },
         "isSuccessful" : true
      }
   ]
}
```
