# Get Started with the B2C Commerce API

The B2C Commerce API (SCAPI) is a set of RESTful APIs for building storefronts, merchant tools, and integrations on the B2C Commerce platform. It also goes by "Salesforce Commerce API" or just "Commerce API." For B2C Commerce customers, the API is available at no extra cost.

:::tip
To browse the endpoints, see the [API Reference](/docs/commerce/commerce-api/references/about-commerce-api/about.md). To learn how SCAPI fits into the B2C Commerce stack, see [Composable Storefront and SCAPI](https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/pwa-scapi.md).
:::

## Make Your First Request

The following two curl commands are all you need to get started. They use a SLAS private client to get a guest token, then fetch a product from the demo sandbox.

### Step 1: Get a Guest Token

Replace `{client_id}` and `{client_secret}` with your SLAS private client credentials. (To create a SLAS client, see [Authorization for Shopper APIs](/docs/commerce/b2c-commerce/guide/authorization-for-shopper-apis.md).)

```sh
curl "https://kv7kzm78.api.commercecloud.salesforce.com/shopper/auth/v1/organizations/f_ecom_zzte_053/oauth2/token" \
  -u "{client_id}:{client_secret}" \
  -d "grant_type=client_credentials" \
  -d "channel_id=RefArch"
```

The response includes an `access_token`:

```json
{
  "access_token": "eyJ0eXAiOiJKV1Q...",
  "expires_in": 1800,
  "token_type": "Bearer"
}
```

### Step 2: Call a Shopper API

Use the `access_token` from Step 1 to fetch a product:

```sh
curl "https://kv7kzm78.api.commercecloud.salesforce.com/product/shopper-products/v1/organizations/f_ecom_zzte_053/products/25695327M?siteId=RefArch" \
  -H "Authorization: Bearer {access_token}"
```

A successful response returns product details as JSON:

```json
{
  "id": "25695327M",
  "name": "Striped Silk Tie",
  "currency": "USD",
  "price": 19.19,
  ...
}
```

In addition to securing access to the Shopper API, SLAS can also turn on third-party identity providers, single sign-on, and personalization in your application.

:::note
**Other ways to get started:**

- Run a complete example (including token acquisition) with the Commerce SDK: [Quick Start](/docs/commerce/b2c-commerce/guide/api-and-sdk-demo.md)
- Explore APIs interactively: [SCAPI Postman Collection](https://www.postman.com/salesforce-developers/workspace/salesforce-developers/collection/15394816-b59efa68-87fd-4398-ba68-f15e931b879f)
- Use the B2C CLI to verify instance connectivity: [Agentic B2C Developer Toolkit](/docs/commerce/b2c-commerce/guide/b2c-developer-tooling.md)
:::

## Choose Your Path

| I want to...                     | Start here                                                                                                                               |
| -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| **Build a storefront**           | [Composable Storefront](https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide) uses the Shopper APIs exclusively. |
| **Build backend or admin tools** | Use the [SCAPI Admin APIs](/docs/commerce/b2c-commerce/guide/authorization-for-admin-apis.md) with an Account Manager token.             |
| **Extend existing API behavior** | Add custom logic with [Hooks](/docs/commerce/b2c-commerce/guide/extensibility_via_hooks.md).                                             |
| **Create new API endpoints**     | Build [Custom APIs](/docs/commerce/b2c-commerce/guide/custom-apis.md) under the SCAPI framework.                                         |
| **Migrate from OCAPI**           | See [Why Use SCAPI Instead of OCAPI](/docs/commerce/b2c-commerce/guide/why-use-scapi.md).                                                |

## Set Up Your Instance

If you don't have a B2C Commerce instance, try the demo sandbox used in the example above. It's also used in the [Quick Start](/docs/commerce/b2c-commerce/guide/api-and-sdk-demo.md).

To set up your own instance:

1. Determine your environment (dev, staging, or production), or create an [on-demand sandbox](https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/creating-an-on-demand-sandbox.md).
2. Look up your configuration values: [Base URL and Request Formation](/docs/commerce/b2c-commerce/guide/base-url.md).
3. Set up API access: [Authorization](/docs/commerce/b2c-commerce/guide/authorization.md).

## Understand SCAPI

### Shopper APIs vs. Admin APIs

SCAPI consists of two API types, plus open-source SDKs and a developer tooling ecosystem. The API type you use depends on your application.

|                    | Shopper APIs                                                  | Admin APIs                                                                           |
| ------------------ | ------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| **Purpose**        | Customer-facing (browsing, cart, checkout)                    | Merchant-facing (product, order, inventory management)                               |
| **Authentication** | [SLAS](/docs/commerce/b2c-commerce/guide/slas.md) (OAuth 2.1) | [Account Manager](/docs/commerce/b2c-commerce/guide/authorization-for-admin-apis.md) |
| **Scale**          | High-scale, supports anonymous users                          | Moderate usage                                                                       |
| **Access**         | Read-only (exceptions: Baskets, Orders)                       | Read and write                                                                       |
| **Naming**         | API names start with "Shopper"                                | No naming convention                                                                 |

### JavaScript SDKs

| Package                                                                                          | Description                   | Docs                                                                       |
| ------------------------------------------------------------------------------------------------ | ----------------------------- | -------------------------------------------------------------------------- |
| [`commerce-sdk`](https://www.npmjs.com/package/commerce-sdk)                                     | Node.js (server-side or CLI)  | [Docs](https://salesforcecommercecloud.github.io/commerce-sdk/)            |
| [`commerce-sdk-isomorphic`](https://www.npmjs.com/package/commerce-sdk-isomorphic)               | Isomorphic (server + browser) | [Docs](https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/) |
| [`@salesforce/commerce-sdk-react`](https://www.npmjs.com/package/@salesforce/commerce-sdk-react) | React hooks for SCAPI         | [Docs](https://salesforcecommercecloud.github.io/pwa-kit/)                 |

For other languages, use the [SCAPI Postman Collection](https://www.postman.com/salesforce-developers/workspace/salesforce-developers/collection/15394816-b59efa68-87fd-4398-ba68-f15e931b879f) or the API specs in [`commerce-sdk`](https://github.com/SalesforceCommerceCloud/commerce-sdk/tree/main/apis).

To explore SCAPI with your assistant, use the [B2C MCP](/docs/commerce/b2c-commerce/guide/b2c-developer-tooling.md#connect-your-ai-assistant). It provides documentation search, schema discovery, and general-purpose execution of SCAPI Admin APIs, including discovered Custom Admin APIs. Shopper schemas are available for reference; Shopper API execution uses your storefront code or a direct API client.

## Operational Reference

The following information is important when preparing for production use.

### Constraints

- SCAPI requests are [rate limited](/docs/commerce/b2c-commerce/guide/throttle-rates.md) to ensure availability.
- Shopper APIs must respond within 10 seconds; Admin APIs within 60 seconds. See [Timeouts and Limits](/docs/commerce/b2c-commerce/guide/timeouts-limits.md).
- Request and response bodies have size limits. See [Timeouts and Limits](/docs/commerce/b2c-commerce/guide/timeouts-limits.md).
- Shopper API requests are routed by USID. Don't reuse the same USID for many guest shoppers.
- For staging with vanity domains, set up [eCDN for Staging](https://help.salesforce.com/s/articleView?id=cc.b2c_configure_ecdn_for_staging.htm\&type=5).
- For cross-origin browser access, configure [CORS](/docs/commerce/b2c-commerce/guide/scapi-cors.md).

### Troubleshooting

- Use correlation IDs to match requests to responses. Include a `correlation-id` header in your request and the response returns it as `x-correlation-id`. See [View SCAPI Logs and Track Requests](/docs/commerce/b2c-commerce/guide/scapi-logs-request-tracking.md).

### Change Policy

:::important
Some new features are available only with specific B2C Commerce versions. This information is included in the [B2C Commerce Release Notes](https://help.salesforce.com/s/articleView?id=commerce.b2c_rn_release_notes.htm\&type=5) and the API specification where applicable.

Make sure that your code can handle nonbreaking changes to the API, such as new fields, new optional parameters, or changes to error messages.
:::

SCAPI is updated regularly with new features, bug fixes, and improvements. Updates are announced in [Salesforce Status](https://status.salesforce.com/products/B2C_Commerce_Cloud) and the [SCAPI Release Notes](/docs/commerce/commerce-api/references/about-commerce-api/about.md). Some features require specific [B2C Commerce versions](https://help.salesforce.com/s/articleView?id=commerce.b2c_rn_release_notes.htm\&type=5).

For the full list of nonbreaking change types and the deployment schedule, see the [B2C Commerce Deployment Schedule](https://help.salesforce.com/s/articleView?id=commerce.b2c_deploy_schedule\_24.htm\&type=5).

### Availability

Subscribe to availability updates on [Salesforce Status](https://status.salesforce.com/products/B2C_Commerce_Cloud). During maintenance, SCAPI returns [maintenance responses](/docs/commerce/b2c-commerce/guide/response-handling.md). For load management details, see [Load Shedding and Rate Limiting](/docs/commerce/b2c-commerce/guide/throttle-rates.md).

## Next Steps

- For detailed use cases and examples, see [Develop](https://developer.salesforce.com/docs/commerce/commerce-api/guide/dev-container.md).
- To explore endpoint specifications, see the [API Reference](https://developer.salesforce.com/docs/commerce/commerce-api/references).
- For cross-cutting topics (authentication, caching, hooks, personalization), see [General Guidance](/docs/commerce/b2c-commerce/guide/general-guidance.md).
