ContentBlockById()

Returns the content contained in a content block.

In Marketing Cloud Engagement, the function retrieves a content block from Content Builder by its ID. This function returns content from Content Builder. For Classic Content areas, use the ContentArea() function.

In Marketing Cloud Next, the function retrieves a content block from the Marketing Content Management System by its content key. If more than one version of the content block is available, the function retrieves the version that was published most recently.

Marketing Cloud Engagement ✅ Yes
Marketing Cloud Next ✅ Yes

This function became available in Marketing Cloud Next during the Summer ’26 release (API version 67.0).

The ContentBlockbyId() function has five parameters:

  • contentBlockId (number): Required. The ID of the content block to retrieve.
  • impressionRegionName (string): The name of the impression region to associate with the content block.
  • boolErrorOnMissingContentBlock (boolean): If true, the function returns an error if the content block can’t be found. If false, the function doesn’t return an error. The default value is true.
  • errorMessage (string): The content to return if an error occurs while retrieving the content block.
  • statusCode (number): The exit code of the function. A value of 0 indicates the function found the content block and successfully rendered the content. A value of -1 indicates either no content or an invalid content block.

To call the function, provide the ID (Marketing Cloud Engagement) or content key (Marketing Cloud Next) of the content block that you want to return.

If the function finds the content block, it returns the content in it. Otherwise, it returns an error message.

In Marketing Cloud Engagement, you can optionally begin an impression region when you insert the content block. This example inserts the content block with the ID 52413 and creates an impression area called “bodytext” at the same time.

Use the EndImpressionRegion() function to denote the end of the impression region.

Use the status code parameter to show fallback content if the function couldn’t retrieve the content block.

If the specified content block is found, the function outputs the content of the content block. Otherwise, the function outputs the fallback message and the message shown in the If statement.