Action Management

Full CRUD operations for managing actions in your mindzieStudio project. Actions are workflow components that can be executed to perform automated tasks.


API Endpoints

Method Endpoint Description
GET /api/{tenantId}/{projectId}/action List all actions
GET /api/{tenantId}/{projectId}/action/{actionId} Get action details
POST /api/{tenantId}/{projectId}/action Create action
PUT /api/{tenantId}/{projectId}/action/{actionId} Update action
DELETE /api/{tenantId}/{projectId}/action/{actionId} Delete action
POST /api/{tenantId}/{projectId}/action/{actionId}/enable Enable action
POST /api/{tenantId}/{projectId}/action/{actionId}/disable Disable action

List All Actions

GET /api/{tenantId}/{projectId}/action

Retrieve all actions configured for a project.

Path Parameters

Parameter Type Required Description
tenantId GUID Yes Your tenant identifier
projectId GUID Yes Your project identifier

Response (200 OK)

{
  "actions": [
    {
      "actionId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
      "projectId": "87654321-4321-4321-4321-210987654321",
      "name": "Daily Data Refresh",
      "description": "Refreshes data from source systems daily",
      "isEnabled": true,
      "maxRunTime": 3600,
      "actionStatus": "Idle",
      "nextRunTime": "2024-01-16T06:00:00Z",
      "lastRunTime": "2024-01-15T06:00:00Z",
      "lastRunResult": "Success",
      "dateCreated": "2024-01-01T10:00:00Z",
      "dateModified": "2024-01-15T14:30:00Z",
      "createdBy": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "modifiedBy": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "triggers": [...],
      "steps": [...]
    }
  ],
  "totalCount": 1
}

Get Action Details

GET /api/{tenantId}/{projectId}/action/{actionId}

Retrieve detailed information about a specific action.

Path Parameters

Parameter Type Required Description
tenantId GUID Yes Your tenant identifier
projectId GUID Yes Your project identifier
actionId GUID Yes The action to retrieve

Response (200 OK)

{
  "actionId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
  "projectId": "87654321-4321-4321-4321-210987654321",
  "name": "Daily Data Refresh",
  "description": "Refreshes data from source systems daily",
  "isEnabled": true,
  "maxRunTime": 3600,
  "actionStatus": "Idle",
  "nextRunTime": "2024-01-16T06:00:00Z",
  "lastRunTime": "2024-01-15T06:00:00Z",
  "lastRunResult": "Success",
  "dateCreated": "2024-01-01T10:00:00Z",
  "dateModified": "2024-01-15T14:30:00Z",
  "createdBy": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "modifiedBy": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "triggers": [
    {
      "triggerId": "11111111-1111-1111-1111-111111111111",
      "actionId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
      "triggerType": "DailyScheduler",
      "settings": "{}",
      "frequency": 1,
      "eventName": null,
      "startDate": "2024-01-01",
      "dateCreated": "2024-01-01T10:00:00Z"
    }
  ],
  "steps": [
    {
      "stepId": "22222222-2222-2222-2222-222222222222",
      "actionId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
      "stepNumber": 1,
      "stepType": "Python",
      "description": "Execute data refresh script",
      "settings": "{\"script\": \"refresh_data.py\"}",
      "dateCreated": "2024-01-01T10:00:00Z"
    }
  ]
}

Response Fields

Field Type Description
actionId GUID Unique action identifier
projectId GUID Project this action belongs to
name string Display name
description string Action description
isEnabled boolean Whether the action is enabled
maxRunTime integer Maximum run time in seconds
actionStatus string Current status (Idle, Running, etc.)
nextRunTime datetime Next scheduled execution
lastRunTime datetime Last execution time
lastRunResult string Result of last execution
triggers array Trigger configurations
steps array Action step definitions

Create Action

POST /api/{tenantId}/{projectId}/action

Create a new action in the project.

Path Parameters

Parameter Type Required Description
tenantId GUID Yes Your tenant identifier
projectId GUID Yes Your project identifier

Request Body

{
  "name": "Weekly Report",
  "description": "Generate weekly analysis report",
  "isEnabled": true,
  "maxRunTime": 1800,
  "steps": [
    {
      "stepNumber": 1,
      "stepType": "Python",
      "description": "Generate report",
      "settings": "{\"script\": \"generate_report.py\"}"
    },
    {
      "stepNumber": 2,
      "stepType": "Email",
      "description": "Send report via email",
      "settings": "{\"recipients\": [\"team@company.com\"]}"
    }
  ],
  "triggers": [
    {
      "triggerType": "WeeklyScheduler",
      "frequency": 1,
      "startDate": "2024-01-08"
    }
  ]
}

Request Fields

Field Type Required Description
name string Yes Action name (must be unique in project)
description string No Action description
isEnabled boolean No Whether action is enabled (default: true)
maxRunTime integer No Max run time in seconds (default: 3600)
steps array Yes At least one step is required
triggers array No Optional trigger configurations

Step Object

Field Type Required Description
stepNumber integer No Execution order (auto-assigned if not provided)
stepType string Yes Type: Python, Email, Webhook, etc.
description string No Step description
settings string Yes JSON configuration for the step

Trigger Object

Field Type Required Description
triggerType string Yes Type: HourlyScheduler, DailyScheduler, WeeklyScheduler, MonthlyScheduler, EventTrigger
frequency integer No Frequency multiplier
startDate date No When to start the schedule
eventName string No Event name (for EventTrigger)
settings string No Additional trigger settings

Response (201 Created)

Returns the created action with assigned IDs.

Error Responses

Conflict (409) - Duplicate Name

{
  "Error": "An action with this name already exists in the project"
}

Update Action

PUT /api/{tenantId}/{projectId}/action/{actionId}

Update an existing action.

Path Parameters

Parameter Type Required Description
tenantId GUID Yes Your tenant identifier
projectId GUID Yes Your project identifier
actionId GUID Yes The action to update

Request Body

{
  "name": "Updated Weekly Report",
  "description": "Updated description",
  "isEnabled": true,
  "maxRunTime": 2400,
  "steps": [
    {
      "stepId": "22222222-2222-2222-2222-222222222222",
      "stepNumber": 1,
      "stepType": "Python",
      "description": "Updated step",
      "settings": "{\"script\": \"updated_report.py\"}"
    }
  ],
  "triggers": [
    {
      "triggerId": "11111111-1111-1111-1111-111111111111",
      "triggerType": "DailyScheduler",
      "frequency": 1,
      "startDate": "2024-02-01"
    }
  ]
}

All fields are optional - only provided fields will be updated.

Response (200 OK)

Returns the updated action.


Delete Action

DELETE /api/{tenantId}/{projectId}/action/{actionId}

Permanently delete an action.

Path Parameters

Parameter Type Required Description
tenantId GUID Yes Your tenant identifier
projectId GUID Yes Your project identifier
actionId GUID Yes The action to delete

Response (204 No Content)

Empty response on success.


Enable Action

POST /api/{tenantId}/{projectId}/action/{actionId}/enable

Enable a disabled action.

Response (200 OK)

Returns the updated action with isEnabled: true.


Disable Action

POST /api/{tenantId}/{projectId}/action/{actionId}/disable

Disable an action.

Response (200 OK)

Returns the updated action with isEnabled: false.


Implementation Examples

cURL

# List all actions
curl -X GET "https://your-mindzie-instance.com/api/{tenantId}/{projectId}/action" \
  -H "Authorization: Bearer YOUR_API_KEY"

# Create an action
curl -X POST "https://your-mindzie-instance.com/api/{tenantId}/{projectId}/action" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Daily Report",
    "description": "Generate daily report",
    "isEnabled": true,
    "steps": [
      {
        "stepNumber": 1,
        "stepType": "Python",
        "description": "Run report script",
        "settings": "{\"script\": \"daily_report.py\"}"
      }
    ],
    "triggers": [
      {
        "triggerType": "DailyScheduler",
        "frequency": 1,
        "startDate": "2024-01-15"
      }
    ]
  }'

# Update an action
curl -X PUT "https://your-mindzie-instance.com/api/{tenantId}/{projectId}/action/{actionId}" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Updated Daily Report"}'

# Delete an action
curl -X DELETE "https://your-mindzie-instance.com/api/{tenantId}/{projectId}/action/{actionId}" \
  -H "Authorization: Bearer YOUR_API_KEY"

# Enable/Disable action
curl -X POST "https://your-mindzie-instance.com/api/{tenantId}/{projectId}/action/{actionId}/enable" \
  -H "Authorization: Bearer YOUR_API_KEY"

curl -X POST "https://your-mindzie-instance.com/api/{tenantId}/{projectId}/action/{actionId}/disable" \
  -H "Authorization: Bearer YOUR_API_KEY"

Python

import requests

BASE_URL = 'https://your-mindzie-instance.com'
TENANT_ID = '12345678-1234-1234-1234-123456789012'
PROJECT_ID = '87654321-4321-4321-4321-210987654321'

class ActionManager:
    def __init__(self, api_key):
        self.headers = {
            'Authorization': f'Bearer {api_key}',
            'Content-Type': 'application/json'
        }

    def list_actions(self):
        """List all actions."""
        url = f'{BASE_URL}/api/{TENANT_ID}/{PROJECT_ID}/action'
        response = requests.get(url, headers=self.headers)
        response.raise_for_status()
        return response.json()

    def get_action(self, action_id):
        """Get action details."""
        url = f'{BASE_URL}/api/{TENANT_ID}/{PROJECT_ID}/action/{action_id}'
        response = requests.get(url, headers=self.headers)
        response.raise_for_status()
        return response.json()

    def create_action(self, name, steps, description=None, triggers=None):
        """Create a new action."""
        url = f'{BASE_URL}/api/{TENANT_ID}/{PROJECT_ID}/action'
        data = {
            'name': name,
            'description': description,
            'isEnabled': True,
            'steps': steps,
            'triggers': triggers or []
        }
        response = requests.post(url, json=data, headers=self.headers)
        response.raise_for_status()
        return response.json()

    def update_action(self, action_id, **kwargs):
        """Update an action."""
        url = f'{BASE_URL}/api/{TENANT_ID}/{PROJECT_ID}/action/{action_id}'
        response = requests.put(url, json=kwargs, headers=self.headers)
        response.raise_for_status()
        return response.json()

    def delete_action(self, action_id):
        """Delete an action."""
        url = f'{BASE_URL}/api/{TENANT_ID}/{PROJECT_ID}/action/{action_id}'
        response = requests.delete(url, headers=self.headers)
        response.raise_for_status()

    def enable_action(self, action_id):
        """Enable an action."""
        url = f'{BASE_URL}/api/{TENANT_ID}/{PROJECT_ID}/action/{action_id}/enable'
        response = requests.post(url, headers=self.headers)
        response.raise_for_status()
        return response.json()

    def disable_action(self, action_id):
        """Disable an action."""
        url = f'{BASE_URL}/api/{TENANT_ID}/{PROJECT_ID}/action/{action_id}/disable'
        response = requests.post(url, headers=self.headers)
        response.raise_for_status()
        return response.json()

# Usage
manager = ActionManager('your-api-key')

# Create an action
action = manager.create_action(
    name='Daily Report',
    description='Generate daily analysis report',
    steps=[
        {
            'stepNumber': 1,
            'stepType': 'Python',
            'description': 'Generate report',
            'settings': '{"script": "daily_report.py"}'
        }
    ],
    triggers=[
        {
            'triggerType': 'DailyScheduler',
            'frequency': 1,
            'startDate': '2024-01-15'
        }
    ]
)
print(f"Created action: {action['actionId']}")

# Disable then enable
manager.disable_action(action['actionId'])
print("Action disabled")

manager.enable_action(action['actionId'])
print("Action enabled")

# Update the action
updated = manager.update_action(action['actionId'], name='Updated Daily Report')

# Delete the action
manager.delete_action(action['actionId'])
print("Action deleted")

JavaScript/Node.js

const BASE_URL = 'https://your-mindzie-instance.com';
const TENANT_ID = '12345678-1234-1234-1234-123456789012';
const PROJECT_ID = '87654321-4321-4321-4321-210987654321';

class ActionManager {
  constructor(apiKey) {
    this.headers = {
      'Authorization': `Bearer ${apiKey}`,
      'Content-Type': 'application/json'
    };
  }

  async listActions() {
    const url = `${BASE_URL}/api/${TENANT_ID}/${PROJECT_ID}/action`;
    const response = await fetch(url, { headers: this.headers });
    if (!response.ok) throw new Error(`Failed: ${response.status}`);
    return response.json();
  }

  async createAction(name, steps, description = null, triggers = []) {
    const url = `${BASE_URL}/api/${TENANT_ID}/${PROJECT_ID}/action`;
    const response = await fetch(url, {
      method: 'POST',
      headers: this.headers,
      body: JSON.stringify({ name, description, isEnabled: true, steps, triggers })
    });
    if (!response.ok) throw new Error(`Failed: ${response.status}`);
    return response.json();
  }

  async updateAction(actionId, updates) {
    const url = `${BASE_URL}/api/${TENANT_ID}/${PROJECT_ID}/action/${actionId}`;
    const response = await fetch(url, {
      method: 'PUT',
      headers: this.headers,
      body: JSON.stringify(updates)
    });
    if (!response.ok) throw new Error(`Failed: ${response.status}`);
    return response.json();
  }

  async deleteAction(actionId) {
    const url = `${BASE_URL}/api/${TENANT_ID}/${PROJECT_ID}/action/${actionId}`;
    const response = await fetch(url, {
      method: 'DELETE',
      headers: this.headers
    });
    if (!response.ok) throw new Error(`Failed: ${response.status}`);
  }

  async enableAction(actionId) {
    const url = `${BASE_URL}/api/${TENANT_ID}/${PROJECT_ID}/action/${actionId}/enable`;
    const response = await fetch(url, { method: 'POST', headers: this.headers });
    if (!response.ok) throw new Error(`Failed: ${response.status}`);
    return response.json();
  }

  async disableAction(actionId) {
    const url = `${BASE_URL}/api/${TENANT_ID}/${PROJECT_ID}/action/${actionId}/disable`;
    const response = await fetch(url, { method: 'POST', headers: this.headers });
    if (!response.ok) throw new Error(`Failed: ${response.status}`);
    return response.json();
  }
}

// Usage
const manager = new ActionManager('your-api-key');

// Create action
const action = await manager.createAction(
  'Daily Report',
  [{ stepNumber: 1, stepType: 'Python', description: 'Run script', settings: '{}' }],
  'Generate daily report',
  [{ triggerType: 'DailyScheduler', frequency: 1, startDate: '2024-01-15' }]
);

// Toggle enable/disable
await manager.disableAction(action.actionId);
await manager.enableAction(action.actionId);

// Delete
await manager.deleteAction(action.actionId);

Best Practices

  1. Unique Names: Action names must be unique within a project
  2. Step Order: Steps execute in stepNumber order
  3. Enable/Disable: Use enable/disable endpoints rather than deleting and recreating
  4. Triggers: Use appropriate trigger types for your scheduling needs
  5. MaxRunTime: Set reasonable timeouts to prevent runaway actions