Build a table block with the Notion API

I’m using the Notion API to add a table block but encounter a missing children error. Using a header block works. New attempts below:

auth_headers = {
    'Authorization': f"Bearer {access_token}",
    'Accept': 'application/json',
    'Content-Type': 'application/json',
    'Notion-Version': '2022-06-28'
}

payload_table = {
    'children': [{
        'object': 'block',
        'type': 'table',
        'table': {'width': 5}  # Missing required 'children' field
    }]
}

result = requests.patch('https://api.notion.com/v1/blocks/xyz789/children', headers=auth_headers, json=payload_table)
payload_header = {
    'children': [{
        'object': 'block',
        'type': 'header',
        'header': {'rich_text': [{'text': {'content': 'Example Header'}}]}
    }]
}

success = requests.patch('https://api.notion.com/v1/blocks/xyz789/children', headers=auth_headers, json=payload_header)

I recently encountered a similar issue when trying to add a table block using the Notion API. From my experience, the key was to recognize that table blocks expect a nested structure containing table_row blocks for their content. Simply missing the required children field leads to errors. I ended up creating an array of table_row objects under the children key, even if they started empty, which resolved the problem. It might be helpful to refer to the API documentation carefully to ensure all required fields are present.