Logo
Salesforce Developers API Documentation

Composite

POST {{_endpoint}}/services/data/v{{version}}/composite/

Executes a series of REST API requests in a single call. You can use the output of one request as the input to a subsequent request. 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. The requests in a composite call are called subrequests. All 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.

https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_composite_composite.htm

 

Body PARAM

Key Datatype Required Description 



HEADERS

Key Datatype Required Description 
Content-Type
string




RESPONSES

status OK

{ "compositeResponse": [ { "body": { "id": "001...", "success": true, "errors": [] }, "httpHeaders": { "Location": "/services/data/v53.0/sobjects/Account/001..." }, "httpStatusCode": 201, "referenceId": "refAccount" }, { "body": { "id": "0032o00003WauzJAAR", "success": true, "errors": [] }, "httpHeaders": { "Location": "/services/data/v53.0/sobjects/Contact/003..." }, "httpStatusCode": 201, "referenceId": "refContact" } ] }



Curl
curl -X POST '/services/data/v61.0/composite/' -H 'Content-Type: application/json' -d '{"compositeRequest":[{"method":"POST","url":"/services/data/v61.0/sobjects/Account","referenceId":"refAccount","body":{"Name":"Sample Account"}},{"method":"POST","url":"/services/data/v61.0/sobjects/Contact","referenceId":"refContact","body":{"LastName":"Sample Contact","AccountId":"@{refAccount.id}"}}]}'

ENDPOINTS