# Hook extension points with hooks.json and HookMgr

*B2C Commerce Developer Study Guide · Application Development · Last updated November 3, 2026 · https://www.certifyforce.com/study-guide/b2c-commerce-developer/application-development/hook-extension-points-with-hooks-json-and-hookmgr*

How to register OCAPI and custom hooks with package.json and hooks.json, pick a before, after or modifyResponse hook for a requirement, control the outcome with Status objects and return values, and call custom extension points with HookMgr.

- Certification: Salesforce B2C Commerce Developer
- Exam section: Application Development
- Study guide: https://www.certifyforce.com/study-guide/b2c-commerce-developer

**Official exam objective:**

> Given a use case, extend functionality or capture an event using hook extension points.

## What the exam expects

- Register a hook: `package.json` with a `hooks` property, a hooks.json mapping, an exported function and the cartridge on the right site's path.
- Choose the before, after or modifyResponse hook of an OCAPI Shop API resource from a requirement (validate, change data inside the transaction, reshape the response).
- Predict what the server does with a returned `Status`, a returned value, nothing returned and an uncaught exception.
- Pass data between the hooks of one request and add properties to a response correctly.
- Define custom extension points, call them with `HookMgr`, and predict which registered modules run, in which order, and what `callHook` returns.

Key terms: **extension point** (a named point in the business logic where scripts can be registered); **hook** (a script registered for an extension point); **`Status`** (the `dw.system.Status` object a hook may return, `OK` or `ERROR`); **`dw.order.calculate`** (the Calculate hook for basket totals); **custom hook** (an extension point you define yourself and call with `HookMgr`).

## Key facts

| Fact | Detail | Source |
|---|---|---|
| `package.json` `hooks` path | Relative to the directory containing package.json | [Extensibility via Hooks](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/extensibility_via_hooks.html) |
| hooks.json `script` paths | Relative to the hooks.json file | [Extensibility via Hooks](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/extensibility_via_hooks.html) |
| Export name | Hook name without package qualification, such as `beforePUT` | [Extensibility via Hooks](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/extensibility_via_hooks.html) |
| Organization-level resources | Register the cartridge to the Business Manager site | [Extensibility via Hooks](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/extensibility_via_hooks.html) |
| GET requests | before and modifyResponse hooks only | [Extensibility via Hooks](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/extensibility_via_hooks.html) |
| Status ERROR | Rollback and HTTP 400 fault | [Extensibility via Hooks](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/extensibility_via_hooks.html) |
| Uncaught exception | Rollback and HTTP 500 fault | [Extensibility via Hooks](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/extensibility_via_hooks.html) |
| Data between hooks | `request.custom` | [Extensibility via Hooks](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/extensibility_via_hooks.html) |
| `order.beforePOST` | Called before an order is created for the basket | [Hook Method Details](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/hook-method-details.html) |
| `callHook` with nothing registered | Returns undefined | [Class HookMgr](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.system.HookMgr.html) |
| Several modules for one extension point | All run; only the last returns a value | [SFRA Hooks](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/b2c-sfra-hooks.html) |

## Check yourself

- Why do GET resources have no after hook?
- When does creating an order through `POST /orders` recalculate the basket by default?
- Which two arguments does a basket `modifyGETResponse` function receive?
- What does an ERROR fault returned to the caller contain?

## Sources

- [Extensibility via Hooks](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/extensibility_via_hooks.html)
- [SFRA Hooks](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/b2c-sfra-hooks.html)
- [Class HookMgr](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.system.HookMgr.html)
- [OCAPI Hooks for Shop API](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-commerce-ocapi/hooks-shop.html)
- [Hook Method Details](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/hook-method-details.html)
- [Class Status](https://developer.salesforce.com/docs/commerce/b2c-commerce/references/b2c-script-api/dw.system.Status.html)

## About the full unit

The "Core concepts", "Exam traps" and "Worked scenario" sections of this unit, its 15 linked practice questions, and unlimited timed mock exams are included with the B2C Commerce Developer pack (USD $19): https://www.certifyforce.com/practice-exams
