FunctionThe options for appending blocks.
The ID of the parent block to append children to. Can be a page ID.
An array of child blocks to append.
Optionalclient?: ObjectThe Notion client object. Either this or apiCall must be provided.
OptionalapiCall?: FunctionA custom function for making API calls. Receives { type: 'append_blocks', data: { block_id, children, after } } as argument. Either this or client must be provided.
OptionalgetResults?: FunctionA function to extract results from the API response. Defaults to response => response.results, which will work if you pass a client object created with the Notion SDK: https://github.com/makenotion/notion-sdk-js. If you're passing a custom apiCall function, you should provide a matching getResults function that can handle the response and return the results array, which contains the created blocks.
An object containing the API responses and the total number of API calls made.
// Using with Notion SDK client
const notion = new Client({ auth: NOTION_TOKEN });
const childBlocks = createNotion().paragraph("A paragraph").build()
const { apiResponses, apiCallCount } = await appendBlocks({
block_id: 'your-block-id',
children: childBlocks.content,
client: notion
});
// Using with custom API call function (using ky)
import ky from 'ky';
const NOTION_TOKEN = 'your-notion-token';
const apiCall = async ({ type, data }) => {
const { block_id, children, after } = data;
const response = await ky.patch(
`https://api.notion.com/v1/blocks/${block_id}/children`,
{
json: { children, ...(after && { after }) },
headers: {
'Authorization': `Bearer ${NOTION_TOKEN}`,
'Notion-Version': '2025-09-03',
},
}
).json();
return response;
};
const childBlocks = createNotion().paragraph("Hello, World!").build();
const { apiResponses, apiCallCount } = await appendBlocks({
block_id: 'your-block-id',
children: childBlocks.content,
apiCall
});
Appends a children block array to a parent block (or page). Handles nested blocks to any level via recursion.