sfcc-scapi-hooks

Explain SFCC SCAPI hook registration and patterns for Shopper API extension.

27|9|Updated Aug 8, 2025
One-click install
npx skills add https://github.com/taurgis/sfcc-dev-mcp --skill sfcc-scapi-hooks
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sfcc-scapi-hooks
Source: https://github.com/taurgis/sfcc-dev-mcp/tree/main/ai-instructions/skills/sfcc-scapi-hooks
Command: npx skills add https://github.com/taurgis/sfcc-dev-mcp --skill sfcc-scapi-hooks

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This guide explains how to implement and register Salesforce B2C Commerce SCAPI hooks to extend Shopper APIs, enforce validation, and standardize hook workflows across cartridges.

Core Features & Use Cases

  • Hook types and execution order (before, after, modifyResponse) with transactional semantics for safety.
  • Registration and wiring: package.json and hooks.json, plus recommended cartridge structure.
  • CommonJS-based hook patterns, error handling, and inter-hook data sharing across hooks.
  • SCAPI vs OCAPI considerations and resilience patterns for production readiness.

Quick Start

Review this guide to implement and register SCAPI hooks in your SFCC cartridge.

Frequently Asked Questions about sfcc-scapi-hooks

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I register SCAPI hooks in an SFCC cartridge?

To register SCAPI hooks in an SFCC cartridge, configure the package.json and hooks.json files to wire beforePOST, afterPOST, and modifyResponse hooks into your CommonJS module structure.

What is the difference between SCAPI and OCAPI hooks in SFCC?

SCAPI hooks extend Shopper APIs using modern CommonJS patterns and structured registration, whereas OCAPI hooks follow older SOAP-era conventions for extending SFCC platform APIs.

How does the execution order work for before, after, and modifyResponse hooks?

The execution order for SCAPI hooks processes before hooks for validation, then the core API logic, followed by after hooks and modifyResponse hooks, maintaining transactional semantics for data safety.

How do I handle errors and share data across SCAPI hooks?

Handle errors and share data across SCAPI hooks by implementing CommonJS-based error handling patterns and inter-hook data passing techniques to ensure production resilience and standardized workflows.

Can I enforce validation on Shopper APIs using SCAPI hooks?

Yes, you can enforce validation on Shopper APIs by implementing beforePOST hooks within your cartridge to intercept and validate incoming requests before the core API transaction executes.

What are the limitations of using SCAPI hooks for cartridge development?

SCAPI hooks require strict adherence to transactional semantics and CommonJS patterns, meaning improper error handling or inter-hook data sharing can disrupt API resilience and platform stability.