Create, Update, and Delete Analysis Blocks
Complete CRUD operations for managing analysis blocks within notebooks. Blocks are the fundamental analysis units that perform data transformations, calculations, filtering operations, and alerting.
Get Block Details
GET /api/{tenantId}/{projectId}/block/{blockId}
Retrieves comprehensive information about a specific analysis block including its configuration, execution history, and metadata.
Parameters
| Parameter | Type | Location | Description |
|---|---|---|---|
tenantId |
GUID | Path | The tenant identifier |
projectId |
GUID | Path | The project identifier |
blockId |
GUID | Path | The block identifier |
Response
{
"blockId": "550e8400-e29b-41d4-a716-446655440000",
"notebookId": "660e8400-e29b-41d4-a716-446655440000",
"blockType": "Filter",
"blockTitle": "Date Range Filter",
"blockDescription": "Filters data for the last 30 days",
"blockOrder": 1,
"configuration": {
"filterType": "dateRange",
"startDate": "2024-01-01",
"endDate": "2024-01-31"
},
"isDisabled": false,
"dateCreated": "2024-01-15T10:30:00Z",
"dateModified": "2024-01-15T14:45:00Z",
"createdBy": "user123",
"modifiedBy": "user123",
"lastExecutionDate": "2024-01-15T14:45:00Z",
"lastExecutionStatus": "Success",
"executionCount": 12
}
Update Block
PUT /api/{tenantId}/{projectId}/block/{blockId}
Updates an existing block's configuration and metadata. Preserves execution history while updating the specified fields.
Request Body
{
"blockTitle": "Updated Date Filter",
"blockDescription": "Filters data for custom date range",
"isDisabled": false
}
Response
Returns the updated block object with the same structure as the GET endpoint.
Delete Block
DELETE /api/{tenantId}/{projectId}/block/{blockId}
Permanently removes a block and all its execution history from the notebook. This operation cannot be undone.
Response Codes
204 No Content- Block deleted successfully404 Not Found- Block not found or access denied400 Bad Request- Failed to delete due to dependencies
Create Filter Block
POST /api/{tenantId}/{projectId}/block/filter
Creates a new filter block within a notebook. Filter blocks apply data filtering criteria such as date ranges, value filters, or logical expressions.
Request Body
{
"notebookId": "660e8400-e29b-41d4-a716-446655440000",
"blockTitle": "New Date Filter",
"blockDescription": "Filters data for analysis period"
}
Response
Returns 201 Created with the new block object and Location header pointing to the created resource.
Create Calculator Block
POST /api/{tenantId}/{projectId}/block/calculator
Creates a calculator block for performing mathematical operations, aggregations, and analytical calculations on datasets.
Request Body
{
"notebookId": "660e8400-e29b-41d4-a716-446655440000",
"blockTitle": "Revenue Calculator",
"blockDescription": "Calculates total revenue metrics"
}
Response
Returns 201 Created with the new calculator block object.
Create Alert Block
POST /api/{tenantId}/{projectId}/block/alert
Creates an alert block for monitoring data conditions and triggering notifications when specific criteria are met.
Request Body
{
"notebookId": "660e8400-e29b-41d4-a716-446655440000",
"blockTitle": "Threshold Alert",
"blockDescription": "Alerts when KPI exceeds threshold"
}
Response
Returns 201 Created with the new alert block object.
Example: Complete Block Workflow
This example demonstrates creating, executing, and managing a filter block:
// 1. Create a filter block
const createBlock = async () => {
const response = await fetch('/api/{tenantId}/{projectId}/block/filter', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({
notebookId: notebookId,
blockTitle: 'Date Range Filter',
blockDescription: 'Filter last 30 days of data'
})
});
return await response.json();
};
// 2. Update block configuration
const updateBlock = async (blockId) => {
const response = await fetch(`/api/{tenantId}/{projectId}/block/${blockId}`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({
blockTitle: 'Updated Filter',
blockDescription: 'Filter last 60 days',
isDisabled: false
})
});
return await response.json();
};
// 3. Get block details
const getBlock = async (blockId) => {
const response = await fetch(`/api/{tenantId}/{projectId}/block/${blockId}`, {
headers: {
'Authorization': `Bearer ${token}`
}
});
return await response.json();
};
Python Example
import requests
import json
class BlockManager:
def __init__(self, base_url, tenant_id, project_id, token):
self.base_url = base_url
self.tenant_id = tenant_id
self.project_id = project_id
self.headers = {
'Authorization': f'Bearer {token}',
'Content-Type': 'application/json'
}
def create_filter_block(self, notebook_id, title, description):
"""Create a new filter block"""
url = f"{self.base_url}/api/{self.tenant_id}/{self.project_id}/block/filter"
payload = {
'notebookId': notebook_id,
'blockTitle': title,
'blockDescription': description
}
response = requests.post(url, json=payload, headers=self.headers)
return response.json()
def get_block(self, block_id):
"""Get block details"""
url = f"{self.base_url}/api/{self.tenant_id}/{self.project_id}/block/{block_id}"
response = requests.get(url, headers=self.headers)
return response.json()
def update_block(self, block_id, title=None, description=None, disabled=False):
"""Update block configuration"""
url = f"{self.base_url}/api/{self.tenant_id}/{self.project_id}/block/{block_id}"
payload = {}
if title:
payload['blockTitle'] = title
if description:
payload['blockDescription'] = description
payload['isDisabled'] = disabled
response = requests.put(url, json=payload, headers=self.headers)
return response.json()
def delete_block(self, block_id):
"""Delete a block"""
url = f"{self.base_url}/api/{self.tenant_id}/{self.project_id}/block/{block_id}"
response = requests.delete(url, headers=self.headers)
return response.status_code == 204
# Usage example
manager = BlockManager(
'https://your-mindzie-instance.com',
'tenant-guid',
'project-guid',
'your-auth-token'
)
# Create a filter block
block = manager.create_filter_block(
'notebook-guid',
'Date Filter',
'Filters data for analysis'
)
print(f"Created block: {block['blockId']}")