Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

b2c-custom-api-development

БесплатноБез исполняемых скриптовНе проверен

Develop Custom SCAPI REST endpoints with api.json routes, schema.yaml definitions, and OAuth scope configuration. Use this skill whenever the user needs to…

SalesforceCommerceCloudот SalesforceCommerceCloud★ 58 звёзд на GitHub

Об этом скилле

Custom API Development Skill

This skill guides you through developing Custom APIs for Salesforce B2C Commerce. Custom APIs let you expose custom script code as REST endpoints under the SCAPI framework.

Tip: If b2c CLI is not installed globally, use npx @salesforce/b2c-cli instead (e.g., npx @salesforce/b2c-cli code deploy).

Scope & grounding

This skill provides CLI-specific workflows and quickstart patterns for Custom API development. It covers OpenAPI 3.0 contract structure, OAuth scope configuration, cartridge-path resolution rules, and circuit breaker behavior. However, platform-specific validation rules, operational limits, security scheme requirements, and Script API integration patterns can drift across Commerce Cloud releases. Before answering questions that reference specific API versions or framework behavior, or before emitting code the user will run, confirm current platform specifics against the official documentation via b2c docs search / b2c docs read (CLI) or docs_search / docs_read (MCP). The official documentation is the authoritative source for Custom API contract specifications, runtime behavior, and B2C Commerce platform details not covered here.

Canonical docs (confirm platform specifics with these):

  • commerce-api/custom-apis - overview, cartridge resolution, operational limits
  • commerce-api/custom-api-components-references - schema.yaml and script.js requirements
  • commerce-api/custom-api-authentication - OAuth scope rules, security schemes
  • commerce-api/custom-api-caching - caching behavior and configuration
  • commerce-api/custom-api-remote-includes - remote include patterns
  • commerce-api/custom-api-circuit-breaker - current thresholds and behavior
  • commerce-api/custom-api-troubleshooting - common issues and solutions
  • commerce-api/custom-api-status-report - registration status details
  • dw.system.RESTResponseMgr - Script API response manager
  • dw.system.Request - Script API request object
  • dw.system.RESTErrorResponse - Script API error response
  • dw.system.RESTSuccessResponse - Script API success response

Overview

A Custom API URL has this structure:

https://{shortCode}.api.commercecloud.salesforce.com/custom/{apiName}/{apiVersion}/organizations/{organizationId}/{endpointPath}

Three components are required to create a Custom API:

  1. API Contract - An OAS 3.0 schema file (YAML)
  2. API Implementation - A script using the B2C Commerce Script API
  3. API Mapping - An api.json file binding endpoints to implementations

Cartridge Structure

/my-cartridge
    /cartridge
        package.json
        /rest-apis
            /my-api-name              # API name (lowercase alphanumeric and hyphens only)
                api.json              # Mapping file
                schema.yaml           # OAS 3.0 contract
                script.js             # Implementation

Important: API directory names can only contain alphanumeric lowercase characters and hyphens.

Component 1: API Contract (schema.yaml)

Illustrative minimal example; confirm current schema validation rules, security scheme structure, and scope naming requirements with b2c docs read commerce-api/custom-api-components-references and b2c docs read commerce-api/custom-apis.

Minimal example:

openapi: 3.0.0
info:
  version: 1.0.0
  title: My Custom API
components:
  securitySchemes:
    ShopperToken:
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: https://{shortCode}.api.commercecloud.salesforce.com/shopper/auth/v1/organizations/{organizationId}/oauth2/token
          scopes:
            c_my_scope: My custom scope
  parameters:
    siteId:
      name: siteId
      in: query
      required: true
      schema:
        type: string
        minLength: 1
paths:
  /my-endpoint:
    get:
      operationId: getMyData
      parameters:
        - $ref: '#/components/parameters/siteId'
      responses:
        '200':
          description: Success
security:
  - ShopperToken: ['c_my_scope']

Key requirements:

  • Use ShopperToken for Shopper APIs (requires siteId), AmOAuth2 for Admin APIs
  • Custom scopes must start with c_, max 25 chars
  • Custom parameters must have c_ prefix

Cartridge path requirements (where the platform looks up your rest-apis/ folder)

Illustrative of platform cartridge resolution rules; confirm current runtime behavior and site context handling with b2c docs read commerce-api/custom-apis.

Call shape Cartridge path searched
Shopper API (ShopperToken) — always site-scoped The storefront site's cartridge path (the site that issued the SLAS token)
Admin API (AmOAuth2) with siteId=<storefront-site> That storefront site's cartridge path
Admin API (AmOAuth2) with siteId=Sites-Site (the special BM/organization site) The Business Manager cartridge path
Admin API (AmOAuth2) with siteId omitted
Полный SKILL.md на GitHub

Установить b2c-custom-api-development в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

evals/trigger-evals.jsonreferences/CONTRACT.mdreferences/IMPLEMENTATION.mdreferences/TESTING.md

FAQ

Что делает скилл b2c-custom-api-development?

Develop Custom SCAPI REST endpoints with api.json routes, schema.yaml definitions, and OAuth scope configuration. Use this skill whenever the user needs to create a custom API on the Commerce platform, define OpenAPI 3.0 schemas for request/response, structure the rest-apis cartridge folder, or debug endpoint registration and 404 issues. Also use when building headless commerce integrations, choosing between Shopper (`ShopperToken`) and Admin (`AmOAuth2`) APIs, or troubleshooting why a Custom API endpoint isn't appearing or returning 404 in `b2c scapi custom status` — even if they just say 'custom REST endpoint', 'expose my script as an API', or 'my admin custom API isn't registering'.

Как установить скилл b2c-custom-api-development?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл b2c-custom-api-development запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить b2c-custom-api-development с