Sf b2c scapi

From OrcaQubits/agentic-commerce-skills-plugins · View interactive version

Sf b2c scapi is an AI agent skill from the GitHub repository OrcaQubits/agentic-commerce-skills-plugins. Build with Salesforce Commerce API (SCAPI) — Shopper APIs (Products, Search, Baskets, Orders, Customers), SLAS authentication, Commerce SDK for Node.js, rate limiting, pagination, and headless commerce patterns. This is the primary B2C API. Use when building headless storefronts or API integrations.

How to use this skill

Skill file

sf-b2c-scapi

Build headless commerce experiences and API integrations with Salesforce Commerce API (SCAPI).

Before Writing Code

Fetch live documentation FIRST:

Why: SCAPI is the modern API replacing OCAPI. Endpoints, authentication flows, rate limits, and SDK versions change frequently. Always verify current specs before implementing.

Conceptual Architecture

API Families

| Family | Scope | Examples |

|--------|-------|---------|

| Shopper Products | Product data for storefront | Product details, images, prices, variations |

| Shopper Search | Product discovery | Keyword search, refinements, facets, suggestions |

| Shopper Baskets | Cart operations | Create basket, add/remove items, shipping, payment |

| Shopper Orders | Order lifecycle | Create order from basket, order history, status |

| Shopper Customers | Customer identity | Registration, profile, addresses, payment methods |

| Shopper Promotions | Pricing incentives | Active promotions, promotion details |

| Shopper Gift Certificates | Gift cards | Balance check, redemption |

| Einstein | AI recommendations | Product and search recommendations |

| Pricing / Inventory | Admin data | Price books, multi-location inventory |

SLAS Authentication Overview

SCAPI uses SLAS (Shopper Login and API Access Service) for OAuth 2.0 authentication. Two primary flows exist:

| Flow | Client Type | Use Case |

|------|------------|----------|

| Authorization Code + PKCE | Public (browser/mobile) | Guest and registered shoppers in frontend apps |

| Client Credentials | Private/confidential (server) | Server-to-server integrations, back-office tools |

Session Bridging

When transitioning a guest user to a registered session (login during checkout), SCAPI supports session bridging to preserve the guest basket. The guest token is exchanged for a registered token via the SLAS token endpoint, and the basket is merged server-side. Fetch live docs for the exact merge behavior and conflict resolution rules.

Rate Limiting

| Aspect | Detail |

|--------|--------|

| Scope | Per client ID, per endpoint |

| Typical range | 1,000 -- 10,000 requests/min (varies by API) |

| Burst | Short burst allowances above sustained rate |

| Headers | X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset |

| On 429 | Exponential backoff; respect Retry-After header |

Pagination

SCAPI uses offset-based pagination with limit and offset parameters. Responses include total count and a next link. Avoid deep pagination on large result sets -- use refinements to narrow results instead.

Commerce SDK

Two SDK packages exist:

| Package | Environment | Notes |

|---------|------------|-------|

| commerce-sdk | Node.js only | Server-side integrations |

| commerce-sdk-isomorphic | Browser + Node.js | PWA Kit and universal apps |

// Pattern: SDK initialization
// Fetch live docs for current config shape
import { ShopperProducts } from 'commerce-sdk-isomorphic';
const client = new ShopperProducts(config);
// Pattern: Search with refinements
// Fetch live docs for refinement syntax
const results = await searchClient.productSearch({
  parameters: { q, limit, offset, refine, sort }
});

Search Refinement Syntax

| Syntax | Meaning |

|--------|---------|

| attribute=value | Exact match |

| attribute=(min..max) | Range filter |

| attribute=val1\|val2 | OR condition |

| cgid=category-id | Category refinement |

Best Practices

Authentication

SDK and Performance

Error Handling

Fetch the SCAPI API reference, Commerce SDK README, and SLAS guide for exact endpoint paths, request/response shapes, and SDK configuration before implementing.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.