Skip to content
FrameworkJavaScript

BlockData: the per-block payload

The structure of each block in the blocks array.

TypeScript
// Individual block structure
interface OutputBlockData {
  id?: string;        // Unique identifier (auto-generated)
  type: string;       // Tool name (e.g., "paragraph", "header")
  data: object;       // Tool-specific data
  tunes?: { [name: string]: BlockTuneData }; // Optional block tunes/metadata
  parent?: string;    // Id of the parent block (flat-with-references nesting)
  content?: string[]; // Ids of child blocks (flat-with-references nesting)
  indent?: number;    // Nesting/indent level
  lastEditedAt?: number; // Timestamp (ms since epoch) of the last edit to this block
  lastEditedBy?: string; // Id of the user who last edited this block (from user.id config)
}

// Example blocks:
const paragraphBlock: OutputBlockData = {
  id: "p6QK0Xz1Ab",
  type: "paragraph",
  data: { "text": "Hello, world!" }
};

const headerBlock: OutputBlockData = {
  id: "hM3lTn9RdC",
  type: "header",
  data: { "text": "Chapter 1", "level": 1 }
};

// Each list item is its own block — the list tool saves a single item,
// not an items[] array
const listItemBlock: OutputBlockData = {
  id: "wY7bV2sQ8e",
  type: "list",
  data: {
    "text": "Item 1",
    "style": "unordered"
  }
};

BlockData

PropertyDescription
idstring (optional)The structure of each block in the blocks array.
typestringThe structure of each block in the blocks array.
dataobjectThe structure of each block in the blocks array.
tunes{ [name: string]: BlockTuneData }The structure of each block in the blocks array.
parentstring (optional)The structure of each block in the blocks array.
contentstring[] (optional)The structure of each block in the blocks array.
indentnumber (optional)The structure of each block in the blocks array.
lastEditedAtnumber (optional)The structure of each block in the blocks array.
lastEditedBystring (optional)The structure of each block in the blocks array.