# What are the primary characteristics and architectural advantages of using the Salesforce REST API for integrations?

**Topic:** Integration · **Difficulty:** Medium · **Tags:** Integration, REST API, Core Protocols

Read it on the site: https://www.forcechallenges.com/interview-questions/what-are-the-primary-characteristics-and-architectural-advantages-of-using-the-salesforce-rest-api-for

## Answer

**Basics:** REST maps operations to URLs and HTTP verbs. A client sends an access token (OAuth) with each call. JSON is compact, human readable and natively supported by JavaScript and mobile SDKs, unlike XML envelopes. It solves the need for simple, stateless access to Salesforce data without generating client code from a WSDL.

**How it works:**
1. Authenticate with OAuth 2.0 and get an access token and the instance URL.
2. Call resources under `/services/data/vXX.0/`: `sobjects/Account/{id}` (GET, PATCH, DELETE), `sobjects/Account` (POST), `query?q=` (SOQL), `search?q=` (SOSL), `limits`, `describe`.
3. Salesforce returns JSON and an HTTP status (200, 201, 204, 400, 401, 403, 404).
4. Errors come as a JSON array with `errorCode` and `message`.
5. Large query results paginate through `nextRecordsUrl` (batches of about 2,000 by default).

**Advanced / deep dive:** Efficiency features matter: the **Composite** resource runs up to 25 subrequests in one call with reference IDs between steps; **sObject Collections** act on up to 200 records at once; **Composite Graph** handles dependent trees; **upsert by External ID** uses `PATCH /sobjects/Obj/ExtField__c/value`. Compared to SOAP, REST is lighter, stateless and cacheable with conditional headers; compared to Bulk API it fits real-time, low-to-medium volume, not millions of rows. UI API (a REST family) returns layout and field-level-security-aware data for building UIs. The API call count applies to a 24-hour rolling org allocation, plus a concurrent long-running limit (25 requests longer than 20 seconds, verify in docs). Sharing, FLS and object permissions of the authenticated user apply.

**Code / config example:**
```
GET /services/data/vXX.0/query?q=SELECT+Id,Name+FROM+Account+WHERE+LastModifiedDate>2026-01-01T00:00:00Z
Authorization: Bearer <access_token>

PATCH /services/data/vXX.0/sobjects/Account/ERP_Id__c/A-1001
Content-Type: application/json
{ "Name": "Acme", "Industry": "Retail" }
```

**Hidden gotchas & must-remember points:**
- Always version the URL and keep a pinned version; behavior changes between versions.
- Each REST call counts against daily API limits; use Composite or Bulk to save calls.
- PATCH is used for update, not PUT.
- Always use the `instance_url` from the OAuth response or a My Domain URL.
- A query returning more than one page requires following `nextRecordsUrl`.
- REST returns 403 REQUEST_LIMIT_EXCEEDED, which clients must treat as retryable later.

**Best practice:** Use REST for transactional integrations, batch requests with Composite, authenticate with OAuth through a least-privilege integration user, and monitor limits via the `/limits` resource.

---
Source: ForceChallenges · last updated 2026-11-02
