Salesforce APIs
Which Salesforce API to use for each job: REST API, SOAP API, Bulk API 2.0, Metadata API, Tooling API or an Apex web service, and how to choose.
An external system has to read or write in Salesforce: which API does it use? The official guide “Which API Do I Use?” compares twelve, and each is designed for a different job. This page covers seven: the three that move records (REST API, SOAP API and Bulk API 2.0), the two that move configuration (Metadata API and Tooling API) and the two ways to publish your own code as a web service (Apex REST and Apex SOAP). It explains the criterion that separates them, applies it to a private bank and ends with a checklist.
What a Salesforce API is
An API (application programming interface) is the way another program works with Salesforce without going through its user interface. Salesforce APIs differ in three things:
- The style. REST (Representational State Transfer) sends HTTP requests to specific addresses, called endpoints. SOAP (Simple Object Access Protocol) exchanges XML messages whose contract is described in a WSDL (Web Service Description Language) file.
- The data format. JSON (JavaScript Object Notation), XML (Extensible Markup Language) or CSV files, comma-separated values.
- The communication. Synchronous, when the caller waits for the answer. Asynchronous, when it hands over the work and collects the result later.
| API | Style | Format | Communication |
|---|---|---|---|
| REST API | REST | JSON, XML | Synchronous |
| SOAP API | SOAP (WSDL) | XML | Synchronous |
| Bulk API 2.0 | REST | CSV | Asynchronous |
| Metadata API | SOAP (WSDL) | XML | Asynchronous |
| Tooling API | REST or SOAP (WSDL) | JSON, XML, custom | Synchronous |
| Apex REST API | REST | JSON, XML, custom | Synchronous |
| Apex SOAP API | SOAP (WSDL) | XML | Synchronous |
They all need the same to get started. The user needs the API Enabled permission. The org needs one of these editions: Professional with API access enabled, Enterprise, Performance, Unlimited or Developer. There is one exception: the Apex REST Services permission gives access to Apex REST services even when the user lacks API Enabled.
First question: data or metadata?
Metadata is data that describes other data. Business data is the records: an account, an address, a product. Salesforce metadata describes the org’s schema, processes, presentation, permissions and general configuration. The City field of an address is metadata; “Andorra la Vella”, the value stored in it, is data.
Metadata API deploys, retrieves, creates, updates or deletes customizations, such as a custom object definition or a page layout. Its main purpose is to move metadata between orgs during development. The most common use is taking changes from a sandbox, a copy of the org for building and testing, to production. It does not work with records: SOAP API and REST API are for that.
The simplest way to use Metadata API is through Salesforce CLI or Salesforce Extensions for Visual Studio Code, which are built on top of it. How to use them belongs to the Metadata and deployment subcategory.
Tooling API gives fine-grained access to metadata. It can query small pieces of a metadata type, and those small retrieves make it a better fit for interactive applications. It is designed for building developer tools: managing working copies of Apex classes and triggers, executing anonymous Apex, or reading debug logs and code coverage. It offers REST and SOAP.
For records: REST API, SOAP API or Bulk API 2.0
REST API creates, manipulates and searches data by sending HTTP requests to endpoints. It needs hardly any tooling and is simpler to use than SOAP API. Salesforce presents it as an excellent choice for mobile applications and web projects. Its Composite resource executes a series of requests in a single call, and the output of one can be the input of the next. The whole series counts as a single call toward the API limits.
SOAP API creates, retrieves, updates, deletes and searches records from any language that supports web services. The example Salesforce gives is integrating the org with enterprise resource planning (ERP) and finance systems. It offers two WSDLs:
- The enterprise WSDL is a strongly typed representation of one specific org’s data: it gives the org’s schema, types and fields to the development environment. It must be regenerated when custom fields or objects are added, renamed or removed.
- The partner WSDL is a loosely typed representation of the object model, designed for applications that work with several orgs.
Bulk API 2.0 queries, inserts, updates, upserts (inserts or updates depending on whether the record exists) or deletes large volumes of records asynchronously. It is built on REST and works with CSV files. Each job states the object it processes and the operation. Salesforce gives a threshold: any operation on more than 2,000 records is a good candidate for Bulk API 2.0. Below that, it recommends bulkified synchronous calls, with REST API (for example, Composite) or with SOAP API.
When the standard API is not enough: Apex web services
Apex is Salesforce’s programming language: strongly typed, object-oriented and executed on Salesforce’s servers. A web service request can start Apex code. That is how your own logic is published for external systems.
- Apex REST. A class with the
@RestResourceannotation is published as a REST resource. Its methods are exposed with annotations:@HttpGet, for example, makes a method answer GET requests. - Apex SOAP. Methods declared with the
webservicekeyword are published as a SOAP web service.
Both support authentication with OAuth 2.0 and with a session ID. Calls to Apex REST count against the org’s API limits, and every Apex execution limit applies to them: the request or the response cannot exceed 6 MB in synchronous Apex or 12 MB in asynchronous Apex.
Do not confuse this with Apex callouts. An Apex web service receives calls from outside; a callout is Apex calling an external service.
The criterion, in five steps
The rules above chain into five steps. At each step, if the answer is yes, the arrow leads to the API; if it is no, you go down to the next step. The first two settle metadata; from the third on, what moves is data.
The last step is the most debatable. The two synchronous APIs serve the same purpose; what tips the balance is the client. If it already generates its code from a WSDL, the enterprise WSDL gives it the typed schema. If not, REST API needs less tooling.
Example: the integrations of a private bank
A private bank is rolling out Salesforce with seven integration needs:
- Initial load. The core banking system sends 250,000 clients with their accounts: Bulk API 2.0, with an upsert job over a CSV file.
- Nightly extract. The data warehouse collects the day’s opportunities every night, more than 2,000: a Bulk API 2.0 query job.
- Digital onboarding. The web form creates a client and their first application, two related records: REST API with Composite. The ID of the created client feeds the second request, and it all counts as one call.
- Accounting system. The bank’s ERP already generates its web service clients from a WSDL: SOAP API with the enterprise WSDL. Every new custom field the ERP needs forces a WSDL regeneration.
- Own calculation. The portal asks for a fee simulation using rules already written in Apex: an Apex REST service, so they are not duplicated in every system.
- A new field. A field and a page layout move from a sandbox to production: Metadata API, through Salesforce CLI.
- Quality control. An internal tool reports the code coverage of each Apex class: Tooling API.
Needs 1 to 5 draw on the same daily call allocation of the org.
When to use each one
The criterion that separates them is what moves and, if it is data, how much and under which contract.
| API | Use it when | Do not use it when |
|---|---|---|
| REST API | A few records must be read or written from a web or mobile application. | The operation exceeds 2,000 records: Bulk API 2.0. |
| SOAP API | The client works with WSDL and wants a typed contract. | The client has no SOAP tooling: REST API needs less. |
| Bulk API 2.0 | The load or query exceeds 2,000 records and can wait. | There are few records: bulkified synchronous calls. |
| Metadata API | Configuration must move between orgs. | What moves is records: it does not work with business data. |
| Tooling API | A tool needs individual pieces of metadata, fast. | Changes must be deployed between orgs: Metadata API. |
| Apex web service | The operation needs logic of your own that lives in Salesforce. | REST API or SOAP API already cover the operation: it would add code of your own to maintain. |
If the external system needs to learn about changes instead of asking for them, the way in is Pub/Sub API with Change Data Capture or Platform Events. It is explained in Core banking integration.
Limits and authentication
Limits belong to the org, not to each user or each integration:
- Daily allocation. It counts every call the org receives in 24 hours. REST API, SOAP API, Bulk API and Bulk API 2.0 count, and so do calls from installed managed packages.
- Concurrency. Requests lasting 20 seconds or longer cannot exceed 25 at a time in production and sandboxes, or 5 in Developer Edition and trial orgs. Above that, the API returns
REQUEST_LIMIT_EXCEEDED. - Timeout. A REST API or SOAP API call is cut off at 10 minutes, except queries, which have their own limits.
To authenticate, a client application needs an external client app or a connected app with an OAuth 2.0 authorization flow. As of Spring ’26, creating connected apps is restricted, and Salesforce recommends external client apps.
Two retirements affect existing integrations. The SOAP API login() call in versions 31.0 to 64.0 stops working in Summer ’27. Versions 31.0 to 40.0 of REST API, SOAP API and Bulk API are deprecated in Summer ’27 and retired in Summer ’28; so are Metadata API and Tooling API in those versions. The details are on the Summer ’26 page.
Before production
- Run every integration flow through the five steps and write down the chosen API, the expected volume and whether the client can wait for the answer.
- Give the integration user the API Enabled permission, or the Salesforce Integration User license, which limits the user to API-only operations.
- Create an external client app with the right OAuth 2.0 flow; do not plan new connected apps.
- Find integrations that use SOAP API
login()and migrate them to external client apps before Summer ’27. The test run of its Release Update disableslogin()in the org and lets you measure the impact. - Pin every client to API version 41.0 or later.
- If the enterprise WSDL is used, add its regeneration to the procedure for every change of fields, objects or package versions.
- Move every operation on more than 2,000 records to Bulk API 2.0, and group the smaller ones with Composite.
- Add up the expected daily consumption of every integration, managed packages included, and compare it with the org’s allocation.
- Configure API Usage Notifications, which sends an email past a set percentage, and track consumption on System Overview, in the
Sforce-Limit-Infoheader or through the/limitsresource. - Check that requests of 20 seconds or longer never approach 25 at a time.
- In Apex services, keep the request and the response below 6 MB, or 12 MB in asynchronous Apex.
- Test everything first in a sandbox or a Developer Edition org.
Official sources
- Which API Do I Use? — Salesforce Help (opens in a new tab)
- About REST API — REST API Developer Guide (opens in a new tab)
- Composite — REST API Developer Guide (opens in a new tab)
- Authorization Through External Client Apps or Connected Apps and OAuth 2.0 — REST API Developer Guide (opens in a new tab)
- About SOAP API — SOAP API Developer Guide (opens in a new tab)
- Bulk API 2.0 — Bulk API 2.0 and Bulk API Developer Guide (opens in a new tab)
- Understanding Metadata API — Metadata API Developer Guide (opens in a new tab)
- Introducing Tooling API — Tooling API (opens in a new tab)
- What is Apex? — Apex Developer Guide (opens in a new tab)
- Introduction to Apex REST — Apex Developer Guide (opens in a new tab)
- Exposing Apex Methods as SOAP Web Services — Apex Developer Guide (opens in a new tab)
- API Request Limits and Allocations — Salesforce Developer Limits and Allocations Quick Reference (opens in a new tab)
- SOAP API login() Call in SOAP API Versions 31.0 Through 64.0 Is Being Retired (Release Update) — Salesforce Help (opens in a new tab)
- Salesforce Platform API Versions 31.0 Through 40.0 Are Being Retired — Salesforce Help (opens in a new tab)