Doc Blocks Methods

Method Name Method Type Description
fetch_doc_blocks(doc_id, limit, page) Getter Retrieves metadata for all blocks in a document.
create_doc_block(doc_id, block_type, content, after_block_id) Setter Creates a new block in a document.
update_doc_block(block_id, content) Setter Updates the content of an existing block.
delete_doc_block(block_id) Deleter Deletes a block from a document.

Method Details

fetch_doc_blocks()

fetch_doc_blocks(doc_id, limit, page)

Description: Retrieves metadata for all blocks within a specific document.

Arguments:

  • doc_id (int): ID of the document.
  • limit (int, optional): Number of blocks to retrieve per request (default: 50, max: 100).
  • page (int, optional): Page number to fetch (default: 1).

Returns: JSON response containing block details. None or error message on API call failure.

Example:

blocks = monday.doc_blocks.fetch_doc_blocks(1234567890, limit=25, page=1)

create_doc_block()

create_doc_block(doc_id, block_type, content, after_block_id)

Description: Creates a new block within a specific document.

Arguments:

  • doc_id (int): ID of the document.
  • block_type (str): Type of block (e.g., 'normal_text', 'table').
  • content (str or dict): JSON-formatted string or dictionary representing the block content (required) (for content field information check https://developer.monday.com/api-reference/reference/blocks).
  • after_block_id (int, optional): ID of the block that will be above the new block.

Returns: Created block's ID. None or error message on API call failure.

Example:

new_block = monday.doc_blocks.create_doc_block(1234567890, 
                                               'normal_text', 
                                               {
                                                   "alignment": "left", 
                                                   "direction": "ltr", 
                                                   "deltaFormat": [{"insert": "This is an example of a text block."}]
                                               })

update_doc_block()

update_doc_block(block_id, content)

Description: Updates the content of an existing block.

Arguments:

  • block_id (int): ID of the block to update.
  • content (str or dict): New content for the block. Must be a valid JSON object or string (required) (for content field information check https://developer.monday.com/api-reference/reference/blocks).

Returns: Updated block's ID. None or error message on API call failure.

Example:

updated_block = monday.doc_blocks.update_doc_block("doc-block-id12345", 
                                                   {
                                                       "alignment": "left", 
                                                       "direction": "ltr", 
                                                       "deltaFormat": [{"insert": "UPDATED block."}]
                                                   })

delete_doc_block()

delete_doc_block(block_id)

Description: Deletes a block from a document.

Arguments:

  • block_id (int): ID of the block to delete.

Returns: True if successful. None or error message on API call failure.

Example:

deleted = monday.doc_blocks.delete_doc_block("doc-block-id12345")