Sub topic 1
What the Salesforce REST API Is and When to Use It
The Salesforce REST API lets a program create, read, update, and delete records in a Salesforce org with ordinary HTTP requests. This chapter explains what the API is, how a request travels, and how to decide whether it fits your task. Later chapters build the actual requests.
Prerequisites
This chapter assumes you already have:
- Basic HTTP knowledge: methods, headers, and status codes.
- Comfort reading JSON.
- Familiarity with Salesforce objects, fields, and record IDs.
- A Salesforce org, such as a Developer Edition org.
- Access to curl or a scripting language such as Python.
You do not need an access token yet. The next chapter covers it.
What the REST API is
The REST API is a web service that every Salesforce org exposes over HTTPS. Each record is a resource with its own URL. The HTTP method states the action, and request and response bodies are JSON.
The tutorial uses these pairings:
- POST creates a record.
- GET reads a record.
- PATCH updates a record.
Because it is plain HTTP, any language or tool that can send a request can use it. Nothing needs to run inside Salesforce.
How a request travels
Every call carries an OAuth 2.0 access token in the Authorization header. The URL combines your org's instance URL, an API version such as v60.0, and the resource you want. Salesforce checks the token and the user's permissions, runs the operation, and returns a status code with a JSON body.
The API runs as the authenticated user. Object permissions, field-level security, and validation rules all apply to your calls as they would in the Salesforce interface.
When to use it
The REST API suits work on individual records or small sets, driven from outside Salesforce. Typical cases are:
- A web or mobile app that saves form data as Salesforce records.
- A script that syncs a few records from another system.
- An integration that looks up a record when something happens elsewhere.
Other Salesforce APIs fit some jobs better:
| Need | Better fit |
|---|---|
| Load or export very large volumes, such as millions of rows | Bulk API 2.0 |
| Integrate with a system that requires a WSDL contract | SOAP API |
| Expose custom business logic at your own endpoint | Apex REST |
| React to changes as they happen | Platform Events or Change Data Capture |
| Create or update up to 200 records in one call | Composite sObjects (a REST API resource) |
Composite sObjects belong to the REST API, so you can start with single-record calls and move to batches later. A later chapter covers that choice.
The path ahead
The next chapters follow this order:
- Authenticating with an access token.
- Building resource URLs.
- Creating, reading, and updating a record.
- Reading error responses.
- Querying with SOQL, upserting by external ID, and batching with Composite sObjects.
By the end you will have run the full create, read, and update cycle yourself, in curl and in Python.
Exercise
A nightly job must copy 5 million rows from a data warehouse into Salesforce. A separate web form must save one new Account each time a visitor submits it. Which API suits each task, and why?
Show answer
Use Bulk API 2.0 for the nightly load, because it is built for very large volumes and processes them asynchronously. Use the REST API for the web form, because it handles single-record creates with a simple authenticated POST and returns the new record ID immediately.