Skip to content

Blocks API

The Blocks API provides endpoints for working with shared content blocks. Blocks are reusable content components (MDX or Puck) that can be referenced across multiple pages. Unlike pages, blocks are not site-scoped by default — they exist globally, though site-specific blocks can shadow global ones.

All endpoints are relative to the API base URL (default: /__cms/api).


List Blocks

GET /blocks

List all blocks with optional filters. When the site parameter is provided, returns a merged list of global and site-specific blocks with scope annotation (site blocks shadow global blocks with the same name).

Parameters:

NameInTypeRequiredDescription
collectionquerystringnoFilter by collection (default: all)
localequerystringnoFilter by locale
sitequerystringnoIf provided, return merged global + site-specific blocks (Dev Branch Preview)

Response: 200 OK

{
  items: ContentManifest[]
  total: number
}

Example:

# List all global blocks
curl http://localhost:4321/__cms/api/blocks

# List blocks for a specific collection
curl "http://localhost:4321/__cms/api/blocks?collection=components"

# List merged blocks for a site (site-specific + global)
curl "http://localhost:4321/__cms/api/blocks?site=default"

Check Block Name Availability

GET /blocks/name-available

Check whether a block name is available within a collection. Useful for validating names before creating or renaming blocks.

Parameters:

NameInTypeRequiredDescription
namequerystringyesBlock name to check
collectionquerystringnoCollection to check in (default: components)
localequerystringnoLocale to check in (default: en)
excludeIdquerystringnoExclude this content ID from the check (for rename operations)
sitequerystringnoCheck availability in site-specific scope (Dev Branch Preview)

Response: 200 OK

// Available
{
  available: true;
}

// Taken
{
  available: false;
  existingId: string; // ID of the block using this name
}

Errors:

StatusCodeDescription
400MISSING_REQUIRED_FIELDname query parameter not provided

Example:

curl "http://localhost:4321/__cms/api/blocks/name-available?name=hero-banner&collection=components"

Get Block by Name

GET /blocks/:name

Get a block by its name. When the site parameter is provided, looks up the site-specific block first, falling back to the global block.

Parameters:

NameInTypeRequiredDescription
namepathstringyesBlock name
collectionquerystringnoCollection to look in (default: components)
localequerystringnoIf provided, return only this locale’s data
sitequerystringnoSite-first lookup: check site blocks, then global (Dev Branch Preview)

Response: 200 OK

// ContentManifest (or filtered to single locale)
{
  id: string
  type: 'puck' | 'mdx'
  kind: 'block'
  collection: string
  locales: {
    [locale: string]: {
      locale: string
      etag: string
      created: string
      modified: string
      name: string
      meta: ContentMeta
    }
  }
}

Errors:

StatusCodeDescription
404CONTENT_NOT_FOUNDNo block with this name in the specified collection

Example:

# Get a block by name
curl "http://localhost:4321/__cms/api/blocks/hero-banner?collection=components"

# Get a block with site-first lookup
curl "http://localhost:4321/__cms/api/blocks/hero-banner?site=default"

# Get only the English locale
curl "http://localhost:4321/__cms/api/blocks/hero-banner?locale=en"