{"id":2468,"date":"2026-10-29T09:00:00","date_gmt":"2026-10-29T03:30:00","guid":{"rendered":"https:\/\/swapnilzambare.com\/blog\/salesforce-composite-api\/"},"modified":"2026-11-15T22:00:00","modified_gmt":"2026-11-15T16:30:00","slug":"salesforce-composite-api","status":"publish","type":"post","link":"https:\/\/swapnilzambare.com\/blog\/salesforce-composite-api\/","title":{"rendered":"Salesforce Composite API Explained with Examples"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The Salesforce Composite API packs up to 25 REST calls into a single HTTP request, runs them in order, and lets a later call reuse the id a previous call created. One round trip instead of five, and no half finished data when something fails.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That second part is the reason integration teams reach for it. Creating an account, then a contact that points at it, then a case that points at the contact, normally means three calls and three chances for a partial result. Here it is one call with a rollback option.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/salesforce-composite-api-diagram-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/salesforce-composite-api-diagram-1-1024x640.png\" alt=\"Salesforce Composite API diagram showing subrequests, references and a single response\" class=\"wp-image-2466\" srcset=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/salesforce-composite-api-diagram-1-1024x640.png 1024w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/salesforce-composite-api-diagram-1-300x188.png 300w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/salesforce-composite-api-diagram-1-768x480.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Caption: Reference ids are what make later steps able to use the records earlier steps created.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What Is the Salesforce Composite API<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The Salesforce Composite API is a REST resource that accepts a list of subrequests. Each subrequest looks like a normal REST call, with a method, a URL, a body, and one extra field called <code>referenceId<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>POST \/services\/data\/v62.0\/composite\n\n{\n  \"allOrNone\": true,\n  \"compositeRequest\": [\n    {\n      \"method\": \"POST\",\n      \"url\": \"\/services\/data\/v62.0\/sobjects\/Account\",\n      \"referenceId\": \"newAccount\",\n      \"body\": { \"Name\": \"Bright Path Tutors\" }\n    },\n    {\n      \"method\": \"POST\",\n      \"url\": \"\/services\/data\/v62.0\/sobjects\/Contact\",\n      \"referenceId\": \"newContact\",\n      \"body\": {\n        \"LastName\": \"Mehta\",\n        \"AccountId\": \"@{newAccount.id}\"\n      }\n    }\n  ]\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>@{newAccount.id}<\/code> token is the whole trick. When the second subrequest runs, Salesforce has already created the account and substitutes the real id.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What You Can Reference<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Token<\/th><th>What it gives you<\/th><\/tr><\/thead><tbody><tr><td>@{ref.id}<\/td><td>The id a create step produced<\/td><\/tr><tr><td>@{ref.body.Name}<\/td><td>A field from a query or retrieve step<\/td><\/tr><tr><td>@{ref.httpStatusCode}<\/td><td>The status of an earlier step<\/td><\/tr><tr><td>@{ref.body.records[0].Id}<\/td><td>An id from a query result<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">That last one is useful when the first step is a query rather than a create. Find the record, then update it, all inside one request.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why the Salesforce Composite API Matters<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Benefit<\/th><th>What it saves you<\/th><\/tr><\/thead><tbody><tr><td>Fewer round trips<\/td><td>Latency, which dominates slow integrations<\/td><\/tr><tr><td>All or nothing<\/td><td>Half written data after a failure<\/td><\/tr><tr><td>Fewer API calls counted<\/td><td>Your daily API limit<\/td><\/tr><tr><td>Simpler client code<\/td><td>Manual id juggling between calls<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The API limit line is worth reading twice. A composite request counts as one call against your daily limit even though it does 25 things. For a nightly job that creates thousands of related records, that difference is large.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you are new to calling Salesforce from outside, the post on <a href=\"https:\/\/swapnilzambare.com\/blog\/salesforce-rest-api-postman\/\">the REST API with Postman<\/a> covers the basic request first.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Three Salesforce Composite API Resources<\/h2>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/salesforce-composite-api-diagram-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/salesforce-composite-api-diagram-2-1024x640.png\" alt=\"Salesforce Composite API comparison with batch and tree resources\" class=\"wp-image-2467\" srcset=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/salesforce-composite-api-diagram-2-1024x640.png 1024w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/salesforce-composite-api-diagram-2-300x188.png 300w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/salesforce-composite-api-diagram-2-768x480.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Caption: Pick composite for dependent steps, batch for independent ones, and tree for record hierarchies.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The Salesforce Composite API has three related resources and they are easy to confuse. For larger loads, see <a href=\"https:\/\/swapnilzambare.com\/blog\/salesforce-bulk-api-2\/\">Bulk API 2.0<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Resource<\/th><th>What it does<\/th><th>Steps share results<\/th><\/tr><\/thead><tbody><tr><td>composite<\/td><td>Runs up to 25 subrequests in order<\/td><td>Yes<\/td><\/tr><tr><td>composite\/batch<\/td><td>Runs up to 25 independent subrequests<\/td><td>No<\/td><\/tr><tr><td>composite\/tree<\/td><td>Creates up to 200 records in a parent child tree<\/td><td>Through local ids<\/td><\/tr><tr><td>composite\/sobjects<\/td><td>Creates, updates or deletes up to 200 records of one or more objects<\/td><td>No<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">When Batch Is the Better Fit<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Batch is the simpler cousin of the Salesforce Composite API, and it does not stop on a failure. If you need five unrelated queries, batch gives you all five answers even when one fails. Composite with <code>allOrNone<\/code> set to true would roll everything back.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">When Tree Is the Better Fit<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Tree is the part of the Salesforce Composite API built for one job, which is inserting a parent with its children in one go. You give each record a local reference, point the children at it, and Salesforce sorts out the order.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n  \"records\": [{\n    \"attributes\": { \"type\": \"Account\", \"referenceId\": \"acc1\" },\n    \"Name\": \"Bright Path Tutors\",\n    \"Contacts\": {\n      \"records\": [{\n        \"attributes\": { \"type\": \"Contact\", \"referenceId\": \"con1\" },\n        \"LastName\": \"Mehta\"\n      }]\n    }\n  }]\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Salesforce Composite API Transactions and allOrNone<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The Salesforce Composite API treats the whole request as one transaction when <code>allOrNone<\/code> is true. One failing step rolls back everything, including the steps that already succeeded.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>allOrNone<\/th><th>A step fails<\/th><th>What you get back<\/th><\/tr><\/thead><tbody><tr><td>true<\/td><td>Everything rolls back<\/td><td>Errors, and no data changed<\/td><\/tr><tr><td>false<\/td><td>Later steps still run<\/td><td>A mix of successes and errors<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Set it to true whenever the records only make sense together. Set it to false when each step is independent and partial progress is useful.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">One caveat that catches people. Even with <code>allOrNone<\/code> set to false, a subrequest whose reference points at a failed step cannot run, because the id it needs does not exist.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">A Real Salesforce Composite API Example<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Bright Path Tutors enrols students from a partner website. Each enrolment creates an Account if the family is new, a Contact for the student, and a <code>Course_Enrolment__c<\/code> record linking them to a course.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The first build used three separate REST calls from the partner system.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Problem<\/th><th>What happened<\/th><\/tr><\/thead><tbody><tr><td>Three round trips<\/td><td>Each enrolment took close to two seconds<\/td><\/tr><tr><td>Partial failures<\/td><td>An account with no contact, 14 times in one month<\/td><\/tr><tr><td>API call count<\/td><td>Three calls per enrolment against the daily limit<\/td><\/tr><tr><td>Client complexity<\/td><td>The partner stored ids between calls<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">One composite request replaced all of it.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Measure<\/th><th>Before<\/th><th>After<\/th><\/tr><\/thead><tbody><tr><td>HTTP calls per enrolment<\/td><td>3<\/td><td>1<\/td><\/tr><tr><td>Average time<\/td><td>1.9 seconds<\/td><td>0.7 seconds<\/td><\/tr><tr><td>Orphan records in a month<\/td><td>14<\/td><td>0<\/td><\/tr><tr><td>Daily API calls used<\/td><td>3 per enrolment<\/td><td>1 per enrolment<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The orphan record count is the figure the business cared about. Those 14 records each took a support call to clean up.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Limits and Things to Watch<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>25 subrequests per composite request, and 5 of those may be query or query all calls<\/li>\n\n<li>The whole request runs in one Apex transaction, so governor limits are shared across every step<\/li>\n\n<li>A reference can only point at an earlier step, never a later one<\/li>\n\n<li>Each subrequest URL must include the API version<\/li>\n\n<li>The response is an array in the same order as the request, so match by position or reference id<\/li>\n\n<li>Composite does not batch Apex REST calls to different custom endpoints as efficiently as you might hope<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The shared governor limits line is the one that bites on large jobs. Twenty five subrequests each touching 200 records can hit the DML row limit even though no single step would. The post on <a href=\"https:\/\/swapnilzambare.com\/blog\/apex-governor-limits-explained\/\">governor limits<\/a> lists the numbers that apply.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Reading the Response<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n  \"compositeResponse\": [\n    {\n      \"body\": { \"id\": \"001...\", \"success\": true },\n      \"httpStatusCode\": 201,\n      \"referenceId\": \"newAccount\"\n    },\n    {\n      \"body\": [{ \"message\": \"Required field missing\", \"errorCode\": \"REQUIRED_FIELD_MISSING\" }],\n      \"httpStatusCode\": 400,\n      \"referenceId\": \"newContact\"\n    }\n  ]\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The Salesforce Composite API reports a status per step, so always read <code>httpStatusCode<\/code> there rather than only the outer HTTP status. The overall call can return 200 while one subrequest inside it failed with a 400.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Calling It from Apex<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can also build a Salesforce Composite API request inside Apex when one org talks to another.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>HttpRequest req = new HttpRequest();\nreq.setEndpoint('callout:Partner_Org\/services\/data\/v62.0\/composite');\nreq.setMethod('POST');\nreq.setHeader('Content-Type', 'application\/json');\nreq.setBody(JSON.serialize(payload));\nHttpResponse res = new Http().send(req);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>callout:<\/code> prefix points at a named credential, which keeps the token out of your code. The post on <a href=\"https:\/\/swapnilzambare.com\/blog\/named-credentials-in-apex-callouts\/\">named credentials<\/a> covers that setup properly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Mistakes with the Salesforce Composite API<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Mistake<\/th><th>What you see<\/th><th>Fix<\/th><\/tr><\/thead><tbody><tr><td>Reference to a later step<\/td><td>An unresolved reference error<\/td><td>Order the steps so the source comes first<\/td><\/tr><tr><td>Missing API version in a subrequest URL<\/td><td>A 404 on that step<\/td><td>Include the version in every URL<\/td><\/tr><tr><td>Reading only the outer status<\/td><td>Silent failures<\/td><td>Check httpStatusCode on each subrequest<\/td><\/tr><tr><td>More than 25 subrequests<\/td><td>The request is rejected<\/td><td>Split the work into several requests<\/td><\/tr><tr><td>allOrNone true for independent work<\/td><td>One bad row loses everything<\/td><td>Set it to false when steps stand alone<\/td><\/tr><tr><td>Many query subrequests<\/td><td>A limit error<\/td><td>Keep query calls to the allowed few per request<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Best Practices for the Salesforce Composite API<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Give every subrequest a reference id you would recognise in a log<\/li>\n\n<li>Set allOrNone to true whenever the records only make sense together<\/li>\n\n<li>Check the status of each subrequest, not only the outer response<\/li>\n\n<li>Keep the step count well under the maximum so a future field addition does not break the request<\/li>\n\n<li>Put the API version in a constant rather than repeating it in every URL<\/li>\n\n<li>Log the full response body on failure, since the error detail sits inside it<\/li>\n\n<li>Use a named credential when the caller is Apex in another org<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Most Asked Salesforce Composite API Interview Questions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q1: What problem does the composite resource solve?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It packs several dependent REST calls into one round trip and lets later steps use ids from earlier ones.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q2: How many subrequests fit in one composite request?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Up to 25, of which a small number may be query calls.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q3: How does a step use an id from an earlier step?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With a reference token that names the earlier reference id and the field, such as the created record id.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q4: What does the allOrNone flag do?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When true, any failure rolls the whole request back. When false, independent steps still run.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q5: Does a composite request count as one API call?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Yes, which is a real saving against the daily limit.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q6: Are governor limits shared across the subrequests?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Yes. The whole request runs in one transaction, so the limits are shared.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q7: What is the difference between composite and composite batch?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Composite runs steps in order and lets them share results. Batch runs independent calls with no sharing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q8: When would you pick batch?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For several unrelated reads, since one failure does not stop the others.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q9: What is composite tree for?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Inserting a parent record with its children in one call, up to 200 records.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q10: How do records reference each other in a tree request?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Through a reference id in the attributes of each record.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q11: What is the sobjects collections resource for?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Creating, updating or deleting up to 200 records in one call, with no step sharing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q12: Can a reference point forward to a later step?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">No. References only look backwards, so order matters.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q13: Why must each subrequest URL include the API version?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Because each one is treated as a real REST call, and a missing version returns a 404.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q14: Can the outer call return 200 while a step failed?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Yes. That is why you read the status of each subrequest.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q15: Scenario: step three fails and allOrNone is false. What happens to step four?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It runs, unless it references step three, in which case it cannot resolve the id.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q16: Scenario: a nightly job hits the DML row limit. Why?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The subrequests share one transaction, so their row counts add up.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q17: Scenario: the partner reports orphan accounts. What is the fix?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Move the related creates into one composite request with allOrNone set to true.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q18: Can you call a custom Apex REST endpoint as a subrequest?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Yes, by using its URL path like any other REST resource.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q19: How do you call the composite resource from Apex?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Build the JSON body, send it with HttpRequest, and point the endpoint at a named credential.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q20: Why use a named credential for that?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It keeps the token and endpoint out of code and handles the authentication for you.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q21: How do you match a response to its request?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">By reference id, which appears in both, rather than relying on position alone.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q22: Does the Salesforce Composite API help with large data loads?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Not really. For millions of records, Bulk API 2.0 is the right tool.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q23: Can you mix reads and writes in one request?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Yes. A common pattern is a query, then an update that uses an id from the query result.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q24: What happens if two steps update the same record?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">They run in order within one transaction, so the last write wins.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q25: Is there a size limit on the request body?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Yes, a documented payload cap, so keep bodies lean and split very large work.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q26: Why keep the step count below the maximum?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So a later requirement can add a step without a redesign.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q27: What belongs in the log when a request fails?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The full response body, since the per step error detail is inside it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q28: What is the one habit that prevents most issues?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check every subrequest status and name reference ids clearly enough to read in a log.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Official Resources<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/developer.salesforce.com\/docs\/atlas.en-us.api_rest.meta\/api_rest\/\" target=\"_blank\" rel=\"noopener noreferrer\">REST API Developer Guide<\/a><\/li>\n\n<li><a href=\"https:\/\/developer.salesforce.com\/docs\/atlas.en-us.apexcode.meta\/apexcode\/\" target=\"_blank\" rel=\"noopener noreferrer\">Apex Developer Guide<\/a><\/li>\n\n<li><a href=\"https:\/\/trailhead.salesforce.com\/content\/learn\/modules\/api_basics\" target=\"_blank\" rel=\"noopener noreferrer\">API Basics on Trailhead<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">What Is Next<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Next, read <a href=\"https:\/\/swapnilzambare.com\/blog\/salesforce-graphql-api\/\">Salesforce GraphQL API Explained for Developers<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Salesforce Composite API packs up to 25 REST calls into a single HTTP request, runs them in order, and lets a later call&hellip;<\/p>\n","protected":false},"author":1,"featured_media":2465,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_swapz_level":"","_swapz_series_part":0,"_swapz_hide_toc":false,"_swapz_hide_featured":false,"_swapz_description":"","footnotes":""},"categories":[246,8,96],"tags":[68,34,81],"swapz_series":[],"class_list":["post-2468","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-integration-apis","category-salesforce","category-salesforce-developer","tag-advanced","tag-certification","tag-integration"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Salesforce Composite API Explained with Examples<\/title>\n<meta name=\"description\" content=\"The Salesforce Composite API packs many REST calls into one request and lets later steps reuse earlier ids. Learn the three flavours and when each fits.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/swapnilzambare.com\/blog\/salesforce-composite-api\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Salesforce Composite API Explained with Examples\" \/>\n<meta property=\"og:description\" content=\"The Salesforce Composite API packs many REST calls into one request and lets later steps reuse earlier ids. Learn the three flavours and when each fits.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/swapnilzambare.com\/blog\/salesforce-composite-api\/\" \/>\n<meta property=\"og:site_name\" content=\"Swapnil Zambare - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-29T03:30:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-11-15T16:30:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/salesforce-composite-api-featured.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2400\" \/>\n\t<meta property=\"og:image:height\" content=\"1260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Swapnil Zambare\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Swapnil Zambare\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/salesforce-composite-api\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/salesforce-composite-api\\\/\"},\"author\":{\"name\":\"Swapnil Zambare\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/person\\\/10b09224c8bcc562716e86789427592a\"},\"headline\":\"Salesforce Composite API Explained with Examples\",\"datePublished\":\"2026-10-29T03:30:00+00:00\",\"dateModified\":\"2026-11-15T16:30:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/salesforce-composite-api\\\/\"},\"wordCount\":1898,\"publisher\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/salesforce-composite-api\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/salesforce-composite-api-featured.png\",\"keywords\":[\"Advanced\",\"Certification\",\"Integration\"],\"articleSection\":[\"Integration and APIs\",\"Salesforce\",\"Salesforce Developer\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/salesforce-composite-api\\\/\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/salesforce-composite-api\\\/\",\"name\":\"Salesforce Composite API Explained with Examples\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/salesforce-composite-api\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/salesforce-composite-api\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/salesforce-composite-api-featured.png\",\"datePublished\":\"2026-10-29T03:30:00+00:00\",\"dateModified\":\"2026-11-15T16:30:00+00:00\",\"description\":\"The Salesforce Composite API packs many REST calls into one request and lets later steps reuse earlier ids. Learn the three flavours and when each fits.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/salesforce-composite-api\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/salesforce-composite-api\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/salesforce-composite-api\\\/#primaryimage\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/salesforce-composite-api-featured.png\",\"contentUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/salesforce-composite-api-featured.png\",\"width\":2400,\"height\":1260,\"caption\":\"Salesforce Composite API featured image showing several requests packed into one call\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/salesforce-composite-api\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Salesforce Composite API Explained with Examples\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\",\"name\":\"Swapnil Zambare - Blog\",\"description\":\"Salesforce &amp; Tech Guides\",\"publisher\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\",\"name\":\"Swapnil Zambare - Blog\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/site-icon-512.png\",\"contentUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/site-icon-512.png\",\"width\":512,\"height\":512,\"caption\":\"Swapnil Zambare - Blog\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/theSwapnilZambare\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/person\\\/10b09224c8bcc562716e86789427592a\",\"name\":\"Swapnil Zambare\",\"sameAs\":[\"https:\\\/\\\/swapnilzambare.com\\\/blog\"],\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/author\\\/swapnil-zambare\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Salesforce Composite API Explained with Examples","description":"The Salesforce Composite API packs many REST calls into one request and lets later steps reuse earlier ids. Learn the three flavours and when each fits.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/swapnilzambare.com\/blog\/salesforce-composite-api\/","og_locale":"en_US","og_type":"article","og_title":"Salesforce Composite API Explained with Examples","og_description":"The Salesforce Composite API packs many REST calls into one request and lets later steps reuse earlier ids. Learn the three flavours and when each fits.","og_url":"https:\/\/swapnilzambare.com\/blog\/salesforce-composite-api\/","og_site_name":"Swapnil Zambare - Blog","article_published_time":"2026-10-29T03:30:00+00:00","article_modified_time":"2026-11-15T16:30:00+00:00","og_image":[{"width":2400,"height":1260,"url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/salesforce-composite-api-featured.png","type":"image\/png"}],"author":"Swapnil Zambare","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Swapnil Zambare","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/swapnilzambare.com\/blog\/salesforce-composite-api\/#article","isPartOf":{"@id":"https:\/\/swapnilzambare.com\/blog\/salesforce-composite-api\/"},"author":{"name":"Swapnil Zambare","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/10b09224c8bcc562716e86789427592a"},"headline":"Salesforce Composite API Explained with Examples","datePublished":"2026-10-29T03:30:00+00:00","dateModified":"2026-11-15T16:30:00+00:00","mainEntityOfPage":{"@id":"https:\/\/swapnilzambare.com\/blog\/salesforce-composite-api\/"},"wordCount":1898,"publisher":{"@id":"https:\/\/swapnilzambare.com\/blog\/#organization"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/salesforce-composite-api\/#primaryimage"},"thumbnailUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/salesforce-composite-api-featured.png","keywords":["Advanced","Certification","Integration"],"articleSection":["Integration and APIs","Salesforce","Salesforce Developer"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/swapnilzambare.com\/blog\/salesforce-composite-api\/","url":"https:\/\/swapnilzambare.com\/blog\/salesforce-composite-api\/","name":"Salesforce Composite API Explained with Examples","isPartOf":{"@id":"https:\/\/swapnilzambare.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/swapnilzambare.com\/blog\/salesforce-composite-api\/#primaryimage"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/salesforce-composite-api\/#primaryimage"},"thumbnailUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/salesforce-composite-api-featured.png","datePublished":"2026-10-29T03:30:00+00:00","dateModified":"2026-11-15T16:30:00+00:00","description":"The Salesforce Composite API packs many REST calls into one request and lets later steps reuse earlier ids. Learn the three flavours and when each fits.","breadcrumb":{"@id":"https:\/\/swapnilzambare.com\/blog\/salesforce-composite-api\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/swapnilzambare.com\/blog\/salesforce-composite-api\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/swapnilzambare.com\/blog\/salesforce-composite-api\/#primaryimage","url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/salesforce-composite-api-featured.png","contentUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/salesforce-composite-api-featured.png","width":2400,"height":1260,"caption":"Salesforce Composite API featured image showing several requests packed into one call"},{"@type":"BreadcrumbList","@id":"https:\/\/swapnilzambare.com\/blog\/salesforce-composite-api\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/swapnilzambare.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Salesforce Composite API Explained with Examples"}]},{"@type":"WebSite","@id":"https:\/\/swapnilzambare.com\/blog\/#website","url":"https:\/\/swapnilzambare.com\/blog\/","name":"Swapnil Zambare - Blog","description":"Salesforce &amp; Tech Guides","publisher":{"@id":"https:\/\/swapnilzambare.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/swapnilzambare.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/swapnilzambare.com\/blog\/#organization","name":"Swapnil Zambare - Blog","url":"https:\/\/swapnilzambare.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/09\/site-icon-512.png","contentUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/09\/site-icon-512.png","width":512,"height":512,"caption":"Swapnil Zambare - Blog"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.linkedin.com\/in\/theSwapnilZambare"]},{"@type":"Person","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/10b09224c8bcc562716e86789427592a","name":"Swapnil Zambare","sameAs":["https:\/\/swapnilzambare.com\/blog"],"url":"https:\/\/swapnilzambare.com\/blog\/author\/swapnil-zambare\/"}]}},"_links":{"self":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/2468","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/comments?post=2468"}],"version-history":[{"count":2,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/2468\/revisions"}],"predecessor-version":[{"id":3394,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/2468\/revisions\/3394"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/media\/2465"}],"wp:attachment":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/media?parent=2468"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/categories?post=2468"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/tags?post=2468"},{"taxonomy":"swapz_series","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/swapz_series?post=2468"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}