- Home
- Skills
- Salesforcecommercecloud
- B2c Developer Tooling
- B2c Custom Api Development
b2c-custom-api-development_skill
- TypeScript
20
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill salesforcecommercecloud/b2c-developer-tooling --skill b2c-custom-api-development- SKILL.md6.0 KB
Overview
This skill teaches how to build Custom SCAPI endpoints for Salesforce B2C Commerce. It covers the required OAS 3.0 contract, the cartridge layout and api.json mapping, implementation patterns using the B2C Script API, and OAuth scope configuration for Shopper and Admin APIs. Follow the workflow to deploy, register, and test headless commerce endpoints securely.
How this skill works
The skill inspects and guides the three components required for a Custom API: the schema.yaml OpenAPI contract (security, parameters, paths), the script implementation that exports endpoint handlers and uses RESTResponseMgr, and the api.json mapping that binds operations to script files. It explains OAuth scopes, siteId handling for Shopper APIs, and the deployment/registration steps used by the b2c CLI to register endpoints with the platform.
When to use it
- Creating REST endpoints for headless B2C Commerce integrations
- Exposing custom logic as SCAPI endpoints for storefront or third-party clients
- Defining OAS contracts and request/response validation for custom APIs
- Configuring OAuth scopes and testing secure shopper/admin access
- Deploying and troubleshooting endpoint registration and runtime errors
Best practices
- Keep API directory names lowercase alphanumeric with hyphens only
- Define all request parameters in schema.yaml and prefix custom params with c_
- Use ShopperToken for shopper-facing APIs (include siteId) and AmOAuth2 for admin APIs
- Mark exported handler functions with .public = true and return RFC 9457 error format
- Use RESTResponseMgr.createSuccess/createError and centralize logging for easier debugging
Example use cases
- Build a product lookup endpoint for a headless mobile app using schema.yaml for validation
- Expose a cart calculation micro-endpoint secured with a c_ scope for client integration
- Create admin-only endpoints for batch SKU updates using AmOAuth2 and Account Manager tokens
- Proxy external pricing service calls from scripts and return normalized responses via RESTResponseMgr
FAQ
API directories must use lowercase alphanumeric characters and hyphens only. Custom scopes must start with c_ and be no longer than 25 characters.
How do I make an exported function available as an endpoint?
Export the handler in the script and set exports.myOp.public = true. Map operationId to the implementation name in api.json (no file extension).
Why am I getting 404 for my endpoint after deploy?
Ensure the cartridge is in the site's cartridge path, the code version is activated, and the endpoint registered successfully (use b2c scapi custom status).
Which token flow for shopper vs admin APIs?
Shopper APIs use SLAS client credentials with ShopperToken and require siteId. Admin APIs use Account Manager OAuth (AmOAuth2) and do not include siteId.