Skip to content

Content Commands

Commands for working with Page Designer content libraries and metadefinitions.

Authentication

The content export and content list commands require OAuth authentication:

OperationAuth Required
content exportOAuth (OCAPI for export job + WebDAV for assets)
content listOAuth (OCAPI for export job)
content validateNone (local file validation)
bash
export SFCC_CLIENT_ID=your-client-id
export SFCC_CLIENT_SECRET=your-client-secret

The content export and content list commands also support a --library-file flag for offline use with a local XML file, which skips authentication entirely.

For complete setup instructions, see the Authentication Guide.


b2c content export

Export Page Designer pages with their component trees and static assets from a content library.

The command fetches the library XML from the instance (via a site archive export job), parses the page/component tree structure, filters by the specified page IDs, downloads referenced static assets via WebDAV, and writes the result to a local directory as a re-importable site archive.

Usage

bash
b2c content export [PAGES...] --library <library-id>

Arguments

ArgumentDescriptionRequired
PAGESOne or more content IDs to export (pages, content assets, or components)Yes

Flags

In addition to global flags:

FlagDescriptionDefault
--libraryLibrary ID or site ID. Also configurable via content-library in dw.json.
--output, -oOutput directorycontent-<timestamp>
--site-libraryTreat the library as a site-private libraryfalse
--asset-query, -qJSON dot-paths for static asset extraction (can be repeated)image.path
--regex, -rTreat page IDs as regular expressionsfalse
--folderFilter by folder classification (can be repeated)
--offlineSkip asset downloadsfalse
--library-fileUse a local library XML file instead of fetching from instance
--keep-orphansInclude orphan components (not linked to any page) in exportfalse
--show-treeDisplay tree structure of exported contenttrue
--timeoutExport job timeout in seconds
--dry-runPreview export without downloading assets or writing filesfalse

Examples

bash
# Export a single page from a shared library
b2c content export homepage --library SharedLibrary --server my-sandbox.demandware.net

# Export multiple pages
b2c content export homepage about-us contact --library SharedLibrary

# Export pages matching a regex pattern
b2c content export "hero-.*" "promo-.*" --library SharedLibrary --regex

# Export a specific component by ID
b2c content export hero-banner --library SharedLibrary

# Export from a site-private library
b2c content export homepage --library RefArch --site-library -o ./export

# Preview what would be exported without downloading
b2c content export homepage --library SharedLibrary --dry-run

# Export with JSON output
b2c content export homepage --library SharedLibrary --json

# Export from a local XML file (no instance connection needed)
b2c content export homepage --library SharedLibrary --library-file ./library.xml --offline

# Filter by folder classification
b2c content export homepage --library SharedLibrary --folder seasonal --folder holiday

# Custom asset extraction paths
b2c content export homepage --library SharedLibrary -q "image.path" -q "video.url"

# Using environment variables and dw.json config
export SFCC_SERVER=my-sandbox.demandware.net
export SFCC_CLIENT_ID=your-client-id
export SFCC_CLIENT_SECRET=your-client-secret
b2c content export homepage

Output

The command displays:

  1. A tree visualization of the exported content (pages, components, and assets)
  2. Asset download progress with success/failure indicators
  3. A summary line listing counts by type, e.g.: Exported: 2 pages, 1 content asset, 5 components, 3 static assets to ./export

With --json, returns a structured result including the library tree, output path, downloaded/failed asset lists, and counts.

Notes

  • The --library flag can be set in dw.json as content-library or in package.json under b2c.contentLibrary to avoid passing it every time
  • Use b2c content list to discover available page IDs before exporting
  • You can export pages, content assets, or individual components by their content ID. When a component ID is specified, it is promoted to the root of the export with its full child tree
  • The --asset-query flag specifies JSON dot-notation paths within component data to extract static asset references. The default image.path covers the common Page Designer image component pattern
  • Use * in asset query paths to traverse arrays (e.g., slides.*.image.path)

b2c content list

List pages and content items in a content library. Useful for discovering page IDs before running an export.

Usage

bash
b2c content list --library <library-id>

Flags

In addition to global flags:

FlagDescriptionDefault
--libraryLibrary ID or site ID. Also configurable via content-library in dw.json.
--site-libraryTreat the library as a site-private libraryfalse
--library-fileUse a local library XML file instead of fetching from instance
--typeFilter by node type: page, content, or component
--componentsInclude components in table outputfalse
--treeShow tree structure instead of tablefalse
--timeoutJob timeout in seconds

Examples

bash
# List all content in a library
b2c content list --library SharedLibrary --server my-sandbox.demandware.net

# List only pages
b2c content list --library SharedLibrary --type page

# List including components
b2c content list --library SharedLibrary --components

# Show tree structure
b2c content list --library SharedLibrary --tree

# List from a site-private library
b2c content list --library RefArch --site-library

# List from a local XML file
b2c content list --library SharedLibrary --library-file ./library.xml

# JSON output
b2c content list --library SharedLibrary --json

Output

Default table output:

ID               TYPE        TYPE ID            CHILDREN
homepage         PAGE        page.storePage     5
about-us         PAGE        page.storePage     3
footer           CONTENT                        2

With --components, components are included in the table output alongside pages and content items.

With --tree, displays a hierarchical tree visualization:

homepage (typeId: page.storePage)
├── component.heroBanner (hero-banner)
│   └── /images/hero.jpg (STATIC ASSET)
└── component.productGrid (product-grid)
about-us (typeId: page.storePage)
└── component.textBlock (text-block)
    └── /images/about.png (STATIC ASSET)
footer-content (CONTENT ASSET)

Pages show id (typeId: type), components show typeId (id), content assets show id (CONTENT ASSET), and static assets show path (STATIC ASSET). The tree uses color when output to a terminal: page names are bold, component type IDs are cyan, asset paths are green, and tree connectors are dim.

With --json, returns { data: [...] } with each item containing id, type, typeId, and children count.


b2c content validate

Validate Page Designer metadefinition JSON files against bundled JSON schemas. This is a local-only command — no instance connection or authentication is required.

The command auto-detects the schema type using file path conventions (experience/pages/ → pagetype, experience/components/ → componenttype) and falls back to inspecting the JSON properties. You can also specify the type explicitly with --type.

Usage

bash
b2c content validate <files...>

Arguments

ArgumentDescriptionRequired
filesOne or more file paths, directories, or glob patternsYes

When a directory is passed, all *.json files within it are validated recursively.

Flags

In addition to global flags:

FlagDescriptionDefault
--type, -tSchema type to validate against (skips auto-detection)Auto-detected

Available schema types: pagetype, componenttype, aspecttype, cmsrecord, customeditortype, contentassetpageconfig, contentassetcomponentconfig, contentassetstructuredcontentdata, image.

Examples

bash
# Validate a single page type definition
b2c content validate cartridge/experience/pages/storePage.json

# Validate all metadefinitions in a directory recursively
b2c content validate cartridge/experience/

# Validate with a glob pattern
b2c content validate 'cartridge/experience/**/*.json'

# Explicitly specify the schema type
b2c content validate --type componenttype mycomponent.json

# Validate multiple files
b2c content validate pages/home.json pages/about.json components/hero.json

# JSON output for CI/scripting
b2c content validate cartridge/experience/ --json

Output

The command prints a color-coded result for each file:

PASS: experience/pages/storePage.json (pagetype)
PASS: experience/components/hero.json (componenttype)
FAIL: experience/components/broken.json (componenttype)
  ERROR at .attribute_definition_groups[0]: is required

2/3 file(s) valid, 1 error(s)

The command exits with a non-zero status when any file fails validation.

With --json, returns a structured result:

json
{
  "results": [
    {
      "valid": true,
      "schemaType": "pagetype",
      "errors": [],
      "filePath": "/path/to/storePage.json"
    }
  ],
  "totalFiles": 1,
  "validFiles": 1,
  "totalErrors": 0
}

Notes

  • Auto-detection uses file path conventions first: files under experience/pages/ are validated as pagetype, files under experience/components/ as componenttype. For other schema types, use --type.
  • Schemas are bundled with the SDK and follow the Page Designer metadefinition specification.
  • Use b2c content validate in CI pipelines to catch metadefinition errors before deployment.

Released under the Apache-2.0 License.