Import & Export

Export projects as portable .mpz files for backup or transfer, and import them into other tenants. Also manage project thumbnail images.

Project Packages (.mpz)

The .mpz format is a mindzie Package Zip containing:

  • Project settings and metadata
  • All datasets and their configurations
  • Investigations and notebooks
  • Dashboards and panels
  • Blob storage files (event logs, attachments)

Export Project

GET /api/{tenantId}/project/{projectId}/download

Exports the project as a .mpz (mindzie Package Zip) file.

Path Parameters

Parameter Type Required Description
tenantId GUID Yes The tenant identifier
projectId GUID Yes The project to export

Response

Returns a binary file download with:

  • Content-Type: application/octet-stream
  • Filename: {projectName}.mpz

Use Cases

  • Backup: Create regular backups of important projects
  • Migration: Move projects between tenants or instances
  • Templates: Export a configured project as a template for new analyses

Import Project

POST /api/{tenantId}/project/import

Imports a project from a .mpz file.

Path Parameters

Parameter Type Required Description
tenantId GUID Yes The target tenant

Request

  • Content-Type: multipart/form-data
  • File parameter: file (the .mpz file)

Constraints

Constraint Value
Maximum file size 1 GB
File extension Must be .mpz
File format Must be a valid mindzie project export

Response (200 OK)

{
  "success": true,
  "projectId": "99999999-9999-9999-9999-999999999999",
  "projectName": "Imported Project",
  "datasetsImported": 2,
  "investigationsImported": 3,
  "dashboardsImported": 1,
  "message": "Project imported successfully"
}

Response Fields

Field Type Description
success boolean Whether import succeeded
projectId GUID ID of the newly created project
projectName string Name of the imported project
datasetsImported integer Number of datasets imported
investigationsImported integer Number of investigations imported
dashboardsImported integer Number of dashboards imported
message string Human-readable status

Error Responses

Bad Request (400):

{
  "success": false,
  "errorMessage": "Invalid file format. Expected .mpz file."
}

Thumbnail Management

Project thumbnails are displayed in the project list and provide visual identification.

Get Thumbnail

GET /api/{tenantId}/project/{projectId}/thumbnail

Retrieves the project's thumbnail image.

Response (200 OK)

{
  "projectId": "87654321-4321-4321-4321-210987654321",
  "hasThumbnail": true,
  "base64Image": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD..."
}

Response Fields

Field Type Description
projectId GUID Project identifier
hasThumbnail boolean Whether a thumbnail exists
base64Image string Base64-encoded image with data URI prefix

Update Thumbnail

POST /api/{tenantId}/project/{projectId}/thumbnail

Updates the project's thumbnail image.

Request Body

{
  "base64Image": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD..."
}

Note: The base64 string should include the data URI prefix (e.g., data:image/jpeg;base64, or data:image/png;base64,).

Response (200 OK)

{
  "message": "Thumbnail updated successfully"
}

Remove Thumbnail

DELETE /api/{tenantId}/project/{projectId}/thumbnail

Removes the project's thumbnail image.

Response (200 OK)

{
  "message": "Thumbnail removed successfully"
}

Implementation Examples

cURL

# Export project to file
curl -X GET "https://your-mindzie-instance.com/api/12345678-1234-1234-1234-123456789012/project/87654321-4321-4321-4321-210987654321/download" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  --output project_backup.mpz

# Import project from file
curl -X POST "https://your-mindzie-instance.com/api/12345678-1234-1234-1234-123456789012/project/import" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -F "file=@project_backup.mpz"

# Get thumbnail
curl -X GET "https://your-mindzie-instance.com/api/12345678-1234-1234-1234-123456789012/project/87654321-4321-4321-4321-210987654321/thumbnail" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

# Update thumbnail (from base64 file)
curl -X POST "https://your-mindzie-instance.com/api/12345678-1234-1234-1234-123456789012/project/87654321-4321-4321-4321-210987654321/thumbnail" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"base64Image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUg..."}'

# Remove thumbnail
curl -X DELETE "https://your-mindzie-instance.com/api/12345678-1234-1234-1234-123456789012/project/87654321-4321-4321-4321-210987654321/thumbnail" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Python

import requests
import base64
from pathlib import Path

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

class ProjectExportManager:
    def __init__(self, token):
        self.headers = {
            'Authorization': f'Bearer {token}'
        }

    def export_project(self, project_id, output_path):
        """Export project to .mpz file."""
        url = f'{BASE_URL}/api/{TENANT_ID}/project/{project_id}/download'
        response = requests.get(url, headers=self.headers, stream=True)
        response.raise_for_status()

        with open(output_path, 'wb') as f:
            for chunk in response.iter_content(chunk_size=8192):
                f.write(chunk)

        print(f"Exported to {output_path}")
        return output_path

    def import_project(self, file_path):
        """Import project from .mpz file."""
        url = f'{BASE_URL}/api/{TENANT_ID}/project/import'

        with open(file_path, 'rb') as f:
            files = {'file': (Path(file_path).name, f, 'application/octet-stream')}
            response = requests.post(url, headers=self.headers, files=files)

        response.raise_for_status()
        result = response.json()

        print(f"Imported: {result['projectName']}")
        print(f"  Datasets: {result['datasetsImported']}")
        print(f"  Investigations: {result['investigationsImported']}")
        print(f"  Dashboards: {result['dashboardsImported']}")

        return result

    def get_thumbnail(self, project_id):
        """Get project thumbnail as base64."""
        url = f'{BASE_URL}/api/{TENANT_ID}/project/{project_id}/thumbnail'
        response = requests.get(url, headers=self.headers)
        response.raise_for_status()
        return response.json()

    def set_thumbnail(self, project_id, image_path):
        """Set project thumbnail from image file."""
        url = f'{BASE_URL}/api/{TENANT_ID}/project/{project_id}/thumbnail'

        # Read and encode image
        with open(image_path, 'rb') as f:
            image_data = f.read()

        # Determine MIME type
        ext = Path(image_path).suffix.lower()
        mime_type = 'image/jpeg' if ext in ['.jpg', '.jpeg'] else 'image/png'

        # Create base64 data URI
        base64_data = base64.b64encode(image_data).decode('utf-8')
        data_uri = f'data:{mime_type};base64,{base64_data}'

        headers = {**self.headers, 'Content-Type': 'application/json'}
        response = requests.post(url, json={'base64Image': data_uri}, headers=headers)
        response.raise_for_status()

        print(f"Thumbnail updated for project {project_id}")
        return response.json()

    def remove_thumbnail(self, project_id):
        """Remove project thumbnail."""
        url = f'{BASE_URL}/api/{TENANT_ID}/project/{project_id}/thumbnail'
        response = requests.delete(url, headers=self.headers)
        response.raise_for_status()
        return response.json()

# Usage
manager = ProjectExportManager('your-auth-token')
project_id = '87654321-4321-4321-4321-210987654321'

# Export project for backup
manager.export_project(project_id, 'my_project_backup.mpz')

# Import into same or different tenant
result = manager.import_project('my_project_backup.mpz')
new_project_id = result['projectId']

# Set a thumbnail
manager.set_thumbnail(project_id, 'project_thumbnail.png')

# Get thumbnail
thumbnail = manager.get_thumbnail(project_id)
if thumbnail['hasThumbnail']:
    print("Thumbnail exists")

JavaScript/Node.js

const fs = require('fs');
const path = require('path');
const FormData = require('form-data');

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

class ProjectExportManager {
  constructor(token) {
    this.headers = {
      'Authorization': `Bearer ${token}`
    };
  }

  async exportProject(projectId, outputPath) {
    const url = `${BASE_URL}/api/${TENANT_ID}/project/${projectId}/download`;
    const response = await fetch(url, { headers: this.headers });

    if (!response.ok) {
      throw new Error(`Export failed: ${response.status}`);
    }

    const buffer = await response.arrayBuffer();
    fs.writeFileSync(outputPath, Buffer.from(buffer));
    console.log(`Exported to ${outputPath}`);
  }

  async importProject(filePath) {
    const url = `${BASE_URL}/api/${TENANT_ID}/project/import`;

    const formData = new FormData();
    formData.append('file', fs.createReadStream(filePath));

    const response = await fetch(url, {
      method: 'POST',
      headers: {
        ...this.headers,
        ...formData.getHeaders()
      },
      body: formData
    });

    if (!response.ok) {
      throw new Error(`Import failed: ${response.status}`);
    }

    const result = await response.json();
    console.log(`Imported: ${result.projectName}`);
    return result;
  }

  async setThumbnail(projectId, imagePath) {
    const url = `${BASE_URL}/api/${TENANT_ID}/project/${projectId}/thumbnail`;

    // Read and encode image
    const imageBuffer = fs.readFileSync(imagePath);
    const ext = path.extname(imagePath).toLowerCase();
    const mimeType = ext === '.png' ? 'image/png' : 'image/jpeg';
    const base64Data = imageBuffer.toString('base64');
    const dataUri = `data:${mimeType};base64,${base64Data}`;

    const response = await fetch(url, {
      method: 'POST',
      headers: {
        ...this.headers,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({ base64Image: dataUri })
    });

    if (!response.ok) {
      throw new Error(`Thumbnail update failed: ${response.status}`);
    }

    return await response.json();
  }
}

// Usage
const manager = new ProjectExportManager('your-auth-token');

// Export and import
await manager.exportProject('project-id', 'backup.mpz');
const imported = await manager.importProject('backup.mpz');

// Set thumbnail
await manager.setThumbnail('project-id', 'thumbnail.png');

Best Practices

  1. Regular Backups: Schedule regular exports of important projects
  2. Version Naming: Include dates in export filenames (e.g., project_2024-01-15.mpz)
  3. Test Imports: Test imports in a non-production tenant before production
  4. Thumbnail Size: Keep thumbnails under 100KB for fast loading
  5. Thumbnail Format: Use JPEG for photos, PNG for graphics with transparency