Mirra
Mirra APITemplates

Template Examples

Templates enable you to build complete, deployable applications that combine Next.js pages, serverless scripts, and API resources. These examples demonstrate how to create templates for different use cases.

Creating a Cryptocurrency Portfolio Template

This example demonstrates a complete dashboard template that tracks cryptocurrency portfolios in real-time.

Request

curl -X POST https://api.fxn.world/api/sdk/v1/templates \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "repository": "mirra-templates",
    "templatePath": "crypto-portfolio",
    "gitHash": "main",
    "name": "Crypto Portfolio Tracker",
    "description": "Real-time cryptocurrency portfolio tracking dashboard",
    "version": "1.0.0",
    "category": "crypto"
  }'

Response

{
  "success": true,
  "data": {
    "id": "template_abc123",
    "name": "Crypto Portfolio Tracker",
    "status": "draft",
    "createdAt": "2025-11-15T12:00:00Z"
  }
}

Building a Template

Build the template to prepare it for deployment:

Request

curl -X POST https://api.fxn.world/api/sdk/v1/templates/TEMPLATE_ID/build \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "version": "1.0.0"
  }'

Response

{
  "success": true,
  "data": {
    "buildStatus": "success",
    "buildOutput": "Built successfully",
    "cdnUrl": "https://cdn.getmirra.app/templates/crypto-dashboard-v1",
    "logs": [
      "Installing dependencies...",
      "Building Next.js app...",
      "Uploading to CDN...",
      "Build completed"
    ]
  }
}

Installing a Template

Install a template with custom configuration:

Request

curl -X POST https://api.fxn.world/api/sdk/v1/templates/TEMPLATE_ID/install \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "customization": {
      "branding.primaryColor": "#10B981",
      "api.refreshInterval": 30,
      "features.showCharts": true
    }
  }'

Response

{
  "success": true,
  "data": {
    "installationId": "inst_123",
    "templateId": "template_456",
    "pageUrl": "https://crypto-dashboard.user.getmirra.app",
    "installedScripts": ["fetchPrices", "calculatePortfolio"],
    "installedResources": ["crypto-price-api"],
    "customization": {
      "branding.primaryColor": "#10B981",
      "api.refreshInterval": 30,
      "features.showCharts": true
    }
  }
}

Publishing to Marketplace

Make your template available to other users:

Request

curl -X POST https://api.fxn.world/api/sdk/v1/templates/TEMPLATE_ID/publish \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "pricing": {
      "setupFee": 5.0,
      "monthlyFee": 2.0,
      "estimatedUsageCost": {
        "perUse": 0.001,
        "perMonth": 5.0
      }
    }
  }'

Template Repository Structure

A complete template repository includes:

crypto-portfolio/
├── page.tsx              # Next.js page component
├── template.json         # Template manifest
├── customization.json    # Customization schema
├── scripts/
│   ├── fetchPrices.js
│   └── calculatePortfolio.js
├── README.md
└── package.json

View a complete example: Example Template on GitHub


Best Practices

Template Design

Build templates that are easy to install and customize:

Do:

  • Focus on a single, well-defined use case
  • Provide sensible defaults for all customization fields
  • Make customization optional—templates should work out of the box
  • Include comprehensive README with screenshots
  • Test all dependencies and resource integrations

Avoid:

  • Overly complex templates with too many features
  • Too many required resources (increases installation friction)
  • Hard-coded values that should be customizable
  • Poor error handling in scripts
  • Missing or incomplete documentation

Pricing Strategies

Choose a pricing model that reflects your template's value:

  • Setup Fee: One-time cost for installation ($5-50)
  • Monthly Fee: Recurring fee for hosting ($2-20)
  • Usage Cost: Based on script executions ($0.001-0.01 per use)

See Also

On this page