OCAPI requests: authentication, methods, caching and state
How an existing OCAPI integration picks the Shop or Data API and its authentication, builds valid request URLs, chooses PUT, PATCH, POST or a method override, prevents lost updates with resource states, and keeps Shop API responses cacheable.
Given a business requirement, use OCAPI Shop and Data APIs to enable interoperability with an external system.
~7 min read · 13 practice questions ·
What the exam expects
- Choose the Shop API or the Data API for an external system's requirement, and the matching authentication (none for guest browsing, a customer JWT, or an OAuth token).
- Build request URLs: version segment, multiple identifiers, URL-encoded case-sensitive IDs.
- Pick PUT, PATCH or POST, and override the method where PUT is blocked.
- Use
_resource_statefor optimistic locking andnot_existsfor safe creation. - Keep Shop API responses cacheable and explain what is never cached, when hooks run, and why stateless clients flood controllers with sessions.
Key terms: Shop API (interacts as a shop customer or an agent shopping on behalf of one); Data API (create, read, update and delete access to system resources); JWT (the customer token passed in each Shop API request); resource state (a server-side token for one resource's current state); composite cache entry (one document plus its expansion documents, cached together).
Key facts
- Detail
- Mandatory for all requests
- Detail
- OAuth token for the client ID or a Business Manager user
- Detail
- Lowercase v, underscore, such as
v24_5
- Detail
- URL encoded and case-sensitive
- Detail
- Blocked; use POST with a method override
- Detail
methodparameter beats the header
- Detail
- HTTP 409
- Detail
- Pass
not_exists
cache_time- Detail
- Default 60; 0 to 86,400 seconds
- Detail
- Shortest TTL of the included documents
- Detail
- Custom hooks don't run
- Detail
- Deprecated as of April 2026; maintenance-only
Sources for this section (6)
- Get Started With OCAPIdeveloper.salesforce.com (opens in a new tab)
- OCAPI URL Syntaxdeveloper.salesforce.com (opens in a new tab)
- OCAPI HTTP Methodsdeveloper.salesforce.com (opens in a new tab)
- OCAPI Resource Statesdeveloper.salesforce.com (opens in a new tab)
- OCAPI Best Practicesdeveloper.salesforce.com (opens in a new tab)
- Why Use SCAPIdeveloper.salesforce.com (opens in a new tab)
- When is the entire OCAPI cache cleared without anyone invalidating it?
- Why can't a team clear only the OCAPI cache?
- What does a PUT return when it creates a resource?
- Which Data API hook runs after
PUT /libraries/{library_id}/content/{content_id}?
The questions are free to read. Answers with their sources and self-grading are included with the pack.
Keep reading with the B2C Commerce Developer pack
- Core concepts
- Exam traps
- Worked scenario
The pack includes:
- All 28 lessons of the B2C Commerce Developer guide, with reading progress
- Interactive decision walks and step-by-step sequence steppers
- Practice exams purchase adds inline bank questions and topic practice (13 questions for this lesson)
- An official source cited for every claim
- An AI tutor that answers from the guide
- Choose guide-only, practice-only, or save $4 with both