Vorlagenverwaltung

Vollständige CRUD-Operationen zur Verwaltung von Notebook-Vorlagen. Alle Endpunkte erfordern einen globalen API-Schlüssel.


Liste globale Vorlagen

GET /api/templates

Gibt alle global verfügbaren Vorlagen über alle Mandanten hinweg zurück.

Antwort (200 OK)

{
  "templates": [
    {
      "templateId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
      "name": "Process Discovery",
      "description": "Standard process discovery workflow",
      "category": "Templates",
      "processName": "Order to Cash",
      "tenantId": null,
      "isGlobal": true,
      "hasThumbnail": true,
      "autoAddedDefaultSortOrder": 100,
      "dateModified": "2024-01-15T10:30:00Z"
    }
  ],
  "totalCount": 1
}

Liste Vorlagen für Mandanten

GET /api/templates/tenant/{tenantId}

Gibt alle Vorlagen zurück, die einem bestimmten Mandanten zur Verfügung stehen, einschließlich globaler und mandantenspezifischer Vorlagen.

Pfadparameter

Parameter Typ Erforderlich Beschreibung
tenantId GUID Ja Die Mandanten-ID

Antwort (200 OK)

{
  "templates": [
    {
      "templateId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
      "name": "Process Discovery",
      "description": "Standard process discovery workflow",
      "category": "Templates",
      "processName": "Order to Cash",
      "tenantId": null,
      "isGlobal": true,
      "hasThumbnail": true,
      "autoAddedDefaultSortOrder": 100,
      "dateCreated": "2024-01-01T00:00:00Z",
      "dateModified": "2024-01-15T10:30:00Z",
      "createdByName": "System",
      "modifiedByName": "System"
    },
    {
      "templateId": "bbbbbbbb-cccc-dddd-eeee-ffffffffffff",
      "name": "Custom Analysis",
      "description": "Tenant-specific custom analysis",
      "category": "Custom",
      "processName": null,
      "tenantId": "12345678-1234-1234-1234-123456789012",
      "isGlobal": false,
      "hasThumbnail": false,
      "autoAddedDefaultSortOrder": 0,
      "dateCreated": "2024-02-01T09:00:00Z",
      "dateModified": "2024-02-15T14:30:00Z",
      "createdByName": "API",
      "modifiedByName": "API"
    }
  ],
  "totalCount": 2
}

Liste Vorlagen nach Kategorie

GET /api/templates/category/{category}

Gibt Vorlagen zurück, gefiltert nach Kategorie.

Pfadparameter

Parameter Typ Erforderlich Beschreibung
category string Ja Kategoriename: Templates, Custom oder BaseKnowledge

Abfrageparameter

Parameter Typ Erforderlich Beschreibung
tenantId GUID Nein Filter für Vorlagen eines bestimmten Mandanten

Beispiel

# Alle benutzerdefinierten Vorlagen abrufen
curl -X GET "https://your-mindzie-instance.com/api/templates/category/Custom" \
  -H "Authorization: Bearer YOUR_GLOBAL_API_KEY"

# Benutzerdefinierte Vorlagen für einen bestimmten Mandanten abrufen
curl -X GET "https://your-mindzie-instance.com/api/templates/category/Custom?tenantId=12345678-1234-1234-1234-123456789012" \
  -H "Authorization: Bearer YOUR_GLOBAL_API_KEY"

Vorlage Details abrufen

GET /api/templates/{templateId}

Gibt vollständige Details einer Vorlage einschließlich der MCL-Konfiguration zurück.

Pfadparameter

Parameter Typ Erforderlich Beschreibung
templateId GUID Ja Die Vorlagen-ID

Antwort (200 OK)

{
  "templateId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
  "name": "Process Discovery",
  "description": "Standard process discovery workflow with variant analysis",
  "category": "Templates",
  "processName": "Order to Cash",
  "mclText": "// MCL configuration defining notebook blocks and settings\n{\n  \"blocks\": [...],\n  \"settings\": {...}\n}",
  "tenantId": null,
  "isGlobal": true,
  "hasThumbnail": true,
  "autoAddedDefaultSortOrder": 100,
  "originatingNotebookId": null,
  "dateCreated": "2024-01-01T00:00:00Z",
  "dateModified": "2024-01-15T10:30:00Z",
  "createdBy": null,
  "createdByName": "System",
  "modifiedBy": null,
  "modifiedByName": "System"
}

Antwort-Felder

Feld Typ Beschreibung
templateId GUID Eindeutiger Bezeichner
name string Vorlagenname
description string Vorlagenbeschreibung
category string Kategorie (Templates, Custom, BaseKnowledge)
processName string Zugehöriger Prozessname
mclText string MCL-Konfigurationstext
tenantId GUID Mandanten-ID (null für globale Vorlagen)
isGlobal boolean Gibt an, ob es sich um eine globale Vorlage handelt
hasThumbnail boolean Gibt an, ob ein Miniaturbild vorhanden ist
autoAddedDefaultSortOrder integer Anzeigereihenfolge
originatingNotebookId GUID Quellnotebook, falls von einem bestehenden Notebook erstellt
dateCreated datetime Erstellungszeitpunkt
dateModified datetime Letzter Änderungszeitpunkt
createdBy GUID Ersteller Benutzer-ID
createdByName string Name des Erstellers
modifiedBy GUID Letzter Änderer Benutzer-ID
modifiedByName string Name des letzten Änderers

Fehlerantworten

Nicht gefunden (404)

{
  "error": "Template with ID 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee' not found"
}

Vorlage Miniaturbild abrufen

GET /api/templates/{templateId}/thumbnail

Gibt das Miniaturbild einer Vorlage zurück.

Pfadparameter

Parameter Typ Erforderlich Beschreibung
templateId GUID Ja Die Vorlagen-ID

Antwort (200 OK)

Gibt JPEG-Bilddaten mit Content-Type: image/jpeg zurück.

Fehlerantworten

Nicht gefunden (404)

{
  "error": "Thumbnail not found for template 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'"
}

Vorlage erstellen

POST /api/templates/tenant/{tenantId}

Erstellt eine neue mandantenspezifische Vorlage. Globale Vorlagen können nicht über die API erstellt werden.

Pfadparameter

Parameter Typ Erforderlich Beschreibung
tenantId GUID Ja Die Mandanten-ID

Anfragekörper

{
  "name": "Custom Analysis Template",
  "description": "Custom analysis workflow for monthly reporting",
  "mclText": "// MCL configuration text",
  "category": "Custom",
  "processName": "Monthly Report",
  "isGlobal": false,
  "autoAddedDefaultSortOrder": 0
}

Anfragefelder

Feld Typ Erforderlich Beschreibung
name string Ja Vorlagenname (muss eindeutig sein)
description string Nein Vorlagenbeschreibung
mclText string Ja MCL-Konfigurationstext
category string Nein Kategorie (Standard: "Custom")
processName string Nein Zugehöriger Prozessname
isGlobal boolean Nein Muss für API-Erstellung false sein
autoAddedDefaultSortOrder integer Nein Anzeigereihenfolge

Antwort (201 Created)

{
  "templateId": "cccccccc-dddd-eeee-ffff-000000000000",
  "name": "Custom Analysis Template",
  "description": "Custom analysis workflow for monthly reporting",
  "category": "Custom",
  "processName": "Monthly Report",
  "mclText": "// MCL configuration text",
  "tenantId": "12345678-1234-1234-1234-123456789012",
  "isGlobal": false,
  "hasThumbnail": false,
  "autoAddedDefaultSortOrder": 0,
  "dateCreated": "2024-03-01T10:00:00Z",
  "dateModified": "2024-03-01T10:00:00Z",
  "createdByName": "API"
}

Fehlerantworten

Fehlerhafte Anfrage (400) - Validierung fehlgeschlagen

{
  "error": "Validation failed",
  "validationErrors": ["Name is required", "MclText is required"]
}

Konflikt (409) - Doppelter Name

{
  "error": "A template with this name already exists"
}

Vorlage aktualisieren

PUT /api/templates/{templateId}

Aktualisiert eine bestehende mandantenspezifische Vorlage. Globale Vorlagen können nicht über die API aktualisiert werden.

Pfadparameter

Parameter Typ Erforderlich Beschreibung
templateId GUID Ja Die Vorlagen-ID

Anfragekörper

{
  "name": "Updated Template Name",
  "description": "Updated description",
  "mclText": "// Updated MCL configuration",
  "category": "Custom",
  "processName": "Updated Process",
  "autoAddedDefaultSortOrder": 10
}

Alle Felder sind optional – nur angegebene Felder werden aktualisiert.

Antwort (200 OK)

Gibt die aktualisierten Vorlagendetails zurück.

Fehlerantworten

Fehlerhafte Anfrage (400) - Globale Vorlage

{
  "error": "Cannot update global templates through the API"
}

Nicht gefunden (404)

{
  "error": "Template not found"
}

Konflikt (409) - Doppelter Name

{
  "error": "A template with this name already exists"
}

Vorlage löschen

DELETE /api/templates/{templateId}

Löscht eine mandantenspezifische Vorlage. Globale Vorlagen können nicht über die API gelöscht werden.

Pfadparameter

Parameter Typ Erforderlich Beschreibung
templateId GUID Ja Die Vorlagen-ID

Antwort (200 OK)

{
  "message": "Template deleted successfully"
}

Fehlerantworten

Fehlerhafte Anfrage (400) - Globale Vorlage

{
  "error": "Cannot delete global templates"
}

Nicht gefunden (404)

{
  "error": "Template not found"
}

Implementierungsbeispiele

cURL

# Alle Vorlagen für einen Mandanten auflisten
curl -X GET "https://your-mindzie-instance.com/api/templates/tenant/12345678-1234-1234-1234-123456789012" \
  -H "Authorization: Bearer YOUR_GLOBAL_API_KEY"

# Vorlagendetails abrufen
curl -X GET "https://your-mindzie-instance.com/api/templates/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" \
  -H "Authorization: Bearer YOUR_GLOBAL_API_KEY"

# Vorlage erstellen
curl -X POST "https://your-mindzie-instance.com/api/templates/tenant/12345678-1234-1234-1234-123456789012" \
  -H "Authorization: Bearer YOUR_GLOBAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My Custom Template",
    "description": "Custom analysis workflow",
    "mclText": "// MCL configuration",
    "category": "Custom"
  }'

# Vorlage aktualisieren
curl -X PUT "https://your-mindzie-instance.com/api/templates/cccccccc-dddd-eeee-ffff-000000000000" \
  -H "Authorization: Bearer YOUR_GLOBAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Updated Name"}'

# Vorlage löschen
curl -X DELETE "https://your-mindzie-instance.com/api/templates/cccccccc-dddd-eeee-ffff-000000000000" \
  -H "Authorization: Bearer YOUR_GLOBAL_API_KEY"

Python

import requests

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

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

    def list_templates(self, tenant_id=None):
        """Listet Vorlagen, optional gefiltert nach Mandant."""
        if tenant_id:
            url = f'{BASE_URL}/api/templates/tenant/{tenant_id}'
        else:
            url = f'{BASE_URL}/api/templates'
        response = requests.get(url, headers=self.headers)
        response.raise_for_status()
        return response.json()

    def get_template(self, template_id):
        """Ruft Vorlagendetails einschließlich MCL-Text ab."""
        url = f'{BASE_URL}/api/templates/{template_id}'
        response = requests.get(url, headers=self.headers)
        response.raise_for_status()
        return response.json()

    def create_template(self, tenant_id, name, mcl_text, description=None, category='Custom'):
        """Erstellt eine neue mandantenspezifische Vorlage."""
        url = f'{BASE_URL}/api/templates/tenant/{tenant_id}'
        data = {
            'name': name,
            'mclText': mcl_text,
            'description': description,
            'category': category
        }
        response = requests.post(url, json=data, headers=self.headers)
        response.raise_for_status()
        return response.json()

    def update_template(self, template_id, **kwargs):
        """Aktualisiert eine Vorlage. Nur angegebene Felder werden aktualisiert."""
        url = f'{BASE_URL}/api/templates/{template_id}'
        response = requests.put(url, json=kwargs, headers=self.headers)
        response.raise_for_status()
        return response.json()

    def delete_template(self, template_id):
        """Löscht eine mandantenspezifische Vorlage."""
        url = f'{BASE_URL}/api/templates/{template_id}'
        response = requests.delete(url, headers=self.headers)
        response.raise_for_status()
        return response.json()

# Verwendung
manager = TemplateManager('your-global-api-key')

# Vorlagen auflisten
templates = manager.list_templates(TENANT_ID)
print(f"Gefundene Vorlagen: {templates['totalCount']}")

for t in templates['templates']:
    print(f"  - {t['name']} ({'Global' if t['isGlobal'] else 'Mandant'})")

# Vorlage erstellen
new_template = manager.create_template(
    tenant_id=TENANT_ID,
    name='My Analysis Template',
    mcl_text='// MCL configuration here',
    description='Custom workflow'
)
print(f"Vorlage erstellt: {new_template['templateId']}")

# Vorlage aktualisieren
updated = manager.update_template(
    new_template['templateId'],
    name='Renamed Template'
)

# Vorlage löschen
manager.delete_template(new_template['templateId'])
print("Vorlage gelöscht")

JavaScript/Node.js

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

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

  async listTemplates(tenantId = null) {
    const url = tenantId
      ? `${BASE_URL}/api/templates/tenant/${tenantId}`
      : `${BASE_URL}/api/templates`;
    const response = await fetch(url, { headers: this.headers });
    if (!response.ok) throw new Error(`Failed: ${response.status}`);
    return response.json();
  }

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

  async createTemplate(tenantId, name, mclText, description = null, category = 'Custom') {
    const url = `${BASE_URL}/api/templates/tenant/${tenantId}`;
    const response = await fetch(url, {
      method: 'POST',
      headers: this.headers,
      body: JSON.stringify({ name, mclText, description, category })
    });
    if (!response.ok) throw new Error(`Failed: ${response.status}`);
    return response.json();
  }

  async updateTemplate(templateId, updates) {
    const url = `${BASE_URL}/api/templates/${templateId}`;
    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 deleteTemplate(templateId) {
    const url = `${BASE_URL}/api/templates/${templateId}`;
    const response = await fetch(url, {
      method: 'DELETE',
      headers: this.headers
    });
    if (!response.ok) throw new Error(`Failed: ${response.status}`);
    return response.json();
  }
}

// Verwendung
const manager = new TemplateManager('your-global-api-key');

// Vorlagen auflisten
const templates = await manager.listTemplates(TENANT_ID);
console.log(`Gefundene Vorlagen: ${templates.totalCount}`);

// Vorlage erstellen
const newTemplate = await manager.createTemplate(
  TENANT_ID,
  'My Analysis Template',
  '// MCL configuration',
  'Custom workflow'
);
console.log(`Erstellt: ${newTemplate.templateId}`);

// Vorlage löschen
await manager.deleteTemplate(newTemplate.templateId);

Bewährte Methoden

  1. Globale API-Schlüssel verwenden: Vorlagenoperationen erfordern globale API-Schlüssel
  2. Eindeutige Namen: Vorlagennamen müssen innerhalb ihres Geltungsbereichs eindeutig sein
  3. MCL Text: Speichern Sie die vollständige MCL-Konfiguration für reproduzierbare Notebooks
  4. Kategorien: Verwenden Sie Standardkategorien zur Organisation
  5. Miniaturbilder: Über die API erstellte Vorlagen haben nicht automatisch Miniaturbilder