Skip to content
← Writing

Salesforce API: Which to Use (REST, SOAP, Bulk, Pub/Sub)

Which Salesforce API should you use? A decision table by use case and volume for REST, SOAP, Bulk API 2.0 and Pub/Sub, plus the gotchas that bite.

·8 min read·Salesforce AI

The right Salesforce API depends on two things: how many records you move and who starts the conversation. Use REST for most single-record and small-batch work, SOAP only when a client demands a WSDL, Bulk API 2.0 for large asynchronous loads, and Pub/Sub API (or Streaming API) when Salesforce should push changes to you.

Key takeaways

  • Choose by volume and direction: small and synchronous is REST, large and asynchronous is Bulk API 2.0, and "tell me when it changes" is Pub/Sub API.
  • SOAP is a compatibility choice, not a performance choice. Pick it when the calling tool needs a WSDL.
  • Your real constraint is the request budget, not the protocol. One call per record is how most integrations run dry.
  • AI agents that call Salesforce over the API or MCP will be metered, so design them to batch from day one.

What are the different Salesforce APIs?

There isn't one Salesforce API; there's a family, and each member is built for a different shape of integration.

Salesforce's own Which API Do I Use? page lists the options with their protocols, data formats and use cases. Access needs the API Enabled user permission, and Professional Edition needs API access switched on. The Salesforce developer integration centre is the best starting point for the official documentation, and the Platform API Basics module on Trailhead covers REST, SOAP, Bulk and Pub/Sub use cases.

One distinction trips people up. Everything in this post is an inbound API: an outside system calls Salesforce. When Salesforce calls out to another system, that's an Apex callout or an Integration Procedure, which is a different topic.

Limits vary by edition and contract, so confirm yours in your org.

Which Salesforce API should you use? A decision table

Start from the use case and the volume, and the answer is usually obvious. This is the table I wish more guides led with.

Use caseVolumeUse thisWhy
Web or mobile app reads and writes a record per user action1 to a handful per actionREST APIJSON, simple auth, no WSDL
Nightly sync of changed recordsHundreds to a few thousandREST sObject Collections200 records per call keeps request count low

| Initial migration, big ERP load, large export | Tens of thousands to millions | Bulk API 2.0 | Asynchronous, CSV, Salesforce handles batching | | Legacy tool or middleware that needs a typed contract | Any | SOAP API | Generates client code from a WSDL | | Tell my system when a record changes | Event-driven | Pub/Sub API with Change Data Capture | Push instead of polling | | Custom business event between systems | Event-driven | Platform events via Pub/Sub API | You define the payload | | Expose custom logic to a partner | Any | Apex REST | You own the contract (and the governor limits) | | Deploy metadata or build IDE tooling | n/a | Metadata API or Tooling API | Built for configuration, not data |

The volume thresholds are my judgement, not Salesforce rules. I stop reaching for single-record REST calls at around 2,000 records.

When should you use the Salesforce REST API?

Use REST API unless you have a specific reason not to; it's JSON over HTTPS and every developer can debug it.

A query looks like this (use the current API version for your org):

curl "https://MyDomain.my.salesforce.com/services/data/v66.0/query?q=SELECT+Id,Name+FROM+Account+LIMIT+5" \
  -H "Authorization: Bearer $ACCESS_TOKEN"
PATCH /services/data/v66.0/composite/sobjects
{
  "allOrNone": false,
  "records": [
    {"attributes": {"type": "Order__c"}, "Id": "a01xx0000001", "Status__c": "Shipped"},
    {"attributes": {"type": "Order__c"}, "Id": "a01xx0000002", "Status__c": "Delivered"}
  ]
}

Set allOrNone to false for integrations. One bad row shouldn't roll back 199 good ones, and the response tells you which one failed.

SOAP API: when the WSDL decides

Choose SOAP when the tool on the other side needs a WSDL, not because you expect it to be faster.

Check Salesforce's retirement notices before building on SOAP login(). Prefer OAuth-issued session tokens for any new work.

My take: I'd treat SOAP as a legacy-compatibility decision. If a new integration lands on SOAP and nobody can name the client that forces it, someone chose it from habit. Pick REST and move on.

Bulk API 2.0: when volume decides

Use Bulk API 2.0 when you're moving more than a few thousand records and don't need an answer in the same request.

It's asynchronous. You create a job, upload CSV, tell Salesforce you're done and collect results later. The steps for an ingest job:

  1. POST /services/data/v66.0/jobs/ingest with the object, operation (insert, update, upsert, delete), externalIdFieldName for upserts, and contentType CSV.
  2. PUT the CSV to /jobs/ingest/{jobId}/batches.
  3. PATCH the job with {"state": "UploadComplete"}.
  4. Poll the job until it reports JobComplete.
  5. Read /successfulResults/, /failedResults/ and /unprocessedrecords/.

Step 5 is where integrations quietly fail. A job can complete with thousands of failed rows. If nobody reads failedResults, the data is simply missing.

If you're a person rather than a pipeline, Salesforce Data Loader can run on Bulk API for the same reason.

Streaming API and Pub/Sub API: when Salesforce should call you

Use an event API when your system would otherwise poll Salesforce every few minutes asking "anything new?"

The Streaming API developer guide describes push technology that supports PushTopic events, generic events, platform events and Change Data Capture events. It also says that if you're building an app that publishes or subscribes to platform events and change data capture events, Salesforce recommends Pub/Sub API instead.

In practice:

  • New build, platform events or Change Data Capture: Pub/Sub API.
  • Existing CometD subscribers or PushTopics: Streaming API still works. Migrate when you next touch it.
  • Record changes: Change Data Capture needs no code on the Salesforce side. Custom business events: platform events.

A subscriber that was down for longer than the 72-hour retention window will miss events. Within 72 hours it can replay from its last stored replay ID.

How do you avoid Salesforce API limit errors? A worked example

The same data can cost you 150,000 API requests or 750, and that gap is the whole argument for choosing the API on volume.

Salesforce limits total API requests in a rolling 24 hours, plus concurrent requests. The Trailhead module above covers both. An Enterprise Edition org with 15 Salesforce licences gets 115,000 (100,000 base plus 1,000 per licence).

Say an ERP pushes 150,000 order updates a day:

ApproachAPI requestsShare of 115,000
One REST call per order150,000130%, so you're blocked before the day ends
REST sObject Collections, 200 per call7500.65%

The arithmetic is mine. Find your own figure in Setup > Company Information under API Requests, Last 24 Hours.

My take: Most "Salesforce API limit exceeded" incidents are design problems, not licensing problems. Before you buy more API capacity, count calls per record. Paying to support a one-call-per-record design is the expensive way to fix it.

Common Salesforce API mistakes in production

The mistakes that hurt in production are rarely about picking the wrong protocol.

  • Using an admin's login for the integration. Create a dedicated integration user with API Enabled and a minimal permission set. When that admin leaves or changes password, nothing breaks.
  • Forgetting that API writes fire your automation. Triggers, flows and validation rules all run, so a bulk load can hit governor limits you never saw in the UI. Know the order of execution before you load.
  • Polling when you could subscribe. A job that asks every minute spends 1,440 requests a day to learn nothing.
  • Ignoring long-running requests. Slow SOQL in one integration can block the others.
  • Hard-coding the API version. Pin it deliberately and review it each release, because old versions are retired.
  • Testing only in production-sized happy paths. Test partial failure in a sandbox first: one row with a bad picklist value.

What changes when AI agents call the API

Agents turn API design into a cost decision, because their calls will be metered.

You can prepare now. List every agent and integration touching Salesforce, estimate calls per day, and design agents to make one call per task, not one per step. My Salesforce MCP guide covers the setup and metering in detail, and the Agentforce pricing calculator helps you estimate the cost side.

Try this week

  • Open Setup > Company Information and note your 24-hour API request total and how much you use on a normal day.
  • List every system that calls Salesforce and which API each one uses. Flag anything making one call per record.
  • Replace one polling job with Change Data Capture or a platform event, or one single-record loop with sObject Collections.
  • Confirm every integration runs as a dedicated integration user, not a person.

If you're mapping this onto a bigger architecture, get in touch and I'll tell you honestly what I'd change first.

Frequently asked questions

What are the main types of Salesforce API?

The ones most developers use are REST API, SOAP API, Bulk API 2.0 and Pub/Sub API, with Streaming API as the older event option. There are also Apex REST, Composite, GraphQL, UI API, Tooling API and Metadata API for specific jobs. Salesforce's Which API Do I Use? page lists them all.

Should I use REST or SOAP in Salesforce?

Use REST by default. Choose SOAP only when the calling tool or middleware requires a WSDL, and then pick the Enterprise WSDL for one org or the Partner WSDL for many.

When should I use Bulk API instead of REST?

When you're loading or exporting more than a few thousand records and can wait for an asynchronous result. Below that, REST with sObject Collections is simpler. The cut-off is a judgement call, so test with your own data.

What is the difference between Streaming API and Pub/Sub API?

Streaming API uses push technology to deliver events. Salesforce recommends Pub/Sub API instead for publishing and subscribing to platform events and Change Data Capture events.

How do I check my Salesforce API limits?

Go to Setup > Company Information and read API Requests, Last 24 Hours. The total depends on your edition and licences, so don't rely on a generic number.

Want to put this to work in your business?

Join one of my live sessions, or tell me what you're trying to do with AI.

Newsletter

Get the next one by email.

New writing on Salesforce AI, AI agents and the AI-Native Enterprise. Confirm by email; unsubscribe any time.

Keep reading