batch_append_block_children
Add multiple child blocks to several parent blocks in a single batch operation, simplifying content organization and updates in Notion workflows.
Instructions
Append children to multiple blocks in a single operation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| operations | Yes | Array of append operations to perform in a single batch |
Implementation Reference
- The main handler function for the batch_append_block_children tool. It loops through the provided operations, appends children to each specified block using the Notion API, collects results, and returns a formatted response or handles errors.export const batchAppendBlockChildren = async ( params: BatchAppendBlockChildrenParams ): Promise<CallToolResult> => { try { const results = []; for (const operation of params.operations) { const response = await notion.blocks.children.append({ block_id: operation.blockId, children: operation.children, }); results.push({ blockId: operation.blockId, success: true, response, }); } return { content: [ { type: "text", text: `Successfully completed ${params.operations.length} append operations`, }, { type: "text", text: JSON.stringify(results, null, 2), }, ], }; } catch (error) { return handleNotionError(error); } };
- src/schema/blocks.ts:192-205 (schema)Zod schema defining the input parameters for batch_append_block_children, consisting of an array of operations each with blockId and children.export const BATCH_APPEND_BLOCK_CHILDREN_SCHEMA = { operations: z .array( z.object({ blockId: z .string() .describe("The ID of the block to append children to"), children: z .array(TEXT_BLOCK_REQUEST_SCHEMA) .describe("Array of blocks to append as children"), }) ) .describe("Array of append operations to perform in a single batch"), };
- src/tools/blocks.ts:28-29 (registration)Registration/dispatch case in the blocks operation tool that calls the batchAppendBlockChildren handler when the action is 'batch_append_block_children'.case "batch_append_block_children": return batchAppendBlockChildren(params.payload.params);
- src/schema/blocks.ts:288-295 (schema)Part of the BLOCKS_OPERATION_SCHEMA discriminated union that defines the structure for the batch_append_block_children action including its literal action name and params schema.z.object({ action: z .literal("batch_append_block_children") .describe( "Use this action to perform batch append operations on blocks." ), params: z.object(BATCH_APPEND_BLOCK_CHILDREN_SCHEMA), }),
- src/types/blocks.ts:36-41 (schema)TypeScript type definition and schema wrapper for BatchAppendBlockChildrenParams inferred from the schema.export const batchAppendBlockChildrenSchema = z.object( BATCH_APPEND_BLOCK_CHILDREN_SCHEMA ); export type BatchAppendBlockChildrenParams = z.infer< typeof batchAppendBlockChildrenSchema >;