Craft icon

Craft

Interact with your Craft documents via the API

Block → Construct Blocks

AI-generated

Summary

Construct block objects for Craft documents by specifying block data either through individual field mappings or by providing a JSON example for more flexible input.

Inputs

  • Input Data Mode (required) — Choose how to input block data: either by defining fields individually or by providing a JSON example of the blocks array.
  • Blocks (BlocksJson) (required) — Provide a JSON array example of block objects to infer fields and types. Setting a field's value to null allows any type.
  • Block Fields (columns) (required) — Map individual block fields like type, id, markdown, textStyle, etc., to construct blocks by defining each field separately.

Output shape

A list of items each containing a 'blocks' property, which is an array of constructed block objects matching the user input.

Output includes one item per input item, with each item's JSON containing the 'blocks' array. Errors for individual items appear in the respective output object if 'Continue On Fail' is enabled.

Examples

Example 1: Constructing blocks by defining fields directly, mapping each field to build block data.

Input Data Mode set to 'fields' with Block Fields mapping to define the block properties.

Example 2: Constructing blocks by providing a JSON example to define complex or nested block structures.

Input Data Mode set to 'json' with Blocks JSON field containing an example array of blocks.

Discussion