Mirra
Get Started

Quickstart

Get started with Mirra in 5 minutes

Mirra is the infrastructure of ambition. Connect any tool, automate any process, and ship new capability without rebuilding your stack. This guide walks you through creating your first script.

Prerequisites

Before you begin, ensure you have:

Create your first script

Scripts are created through the REST API, shown below. You can also work with them conversationally by asking Mirra in any space, or with the SDK — see Writing Scripts.

Getting your API Key

Generate an API key from the web app (SettingsAPI Keys) or the mobile app (SettingsDeveloper). Copy the key immediately. It's only shown once.

Store your API key securely. Never commit it to version control or expose it in client-side code.

See the Authentication guide for more details.

Create a script via API

Create a script by sending a POST request to the scripts endpoint:

curl https://api.fxn.world/api/sdk/v1/scripts \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My First Script",
    "description": "A simple echo script that returns the input",
    "runtime": "nodejs18",
    "category": "utility",
    "code": "async function main(params) { return { success: true, input: params }; } module.exports = { main };",
    "isPrivate": false,
    "config": {
      "timeout": 30,
      "memory": 256
    },
    "pricing": {
      "model": "free"
    }
  }'

Response:

{
  "success": true,
  "data": {
    "id": "673abc123def456789",
    "name": "My First Script",
    "description": "A simple echo script that returns the input",
    "runtime": "nodejs18",
    "status": "active",
    "createdAt": "2025-11-19T12:00:00Z"
  }
}

Your script is now deployed and ready to execute!

Using the SDK

The Mirra SDK provides type safety and convenience for Node.js and TypeScript applications.

Installation

npm install @mirra-messenger/sdk

Create a script using the SDK

import { MirraSDK } from '@mirra-messenger/sdk';
 
const mirra = new MirraSDK({ apiKey: process.env.MIRRA_API_KEY });
 
const script = await mirra.scripts.create({
  name: 'My Script',
  description: 'A helpful automation script',
  runtime: 'nodejs18',
  code: `
async function main(params) {
  return { success: true, input: params };
}
module.exports = { main };
  `.trim(),
  config: {
    timeout: 30,
    memory: 256
  }
});
 
console.log('Script created:', script.id);

Execute a script

const result = await mirra.scripts.invoke({
  scriptId: script.id,
  payload: { message: 'Hello, Mirra!' }
});
 
console.log('Result:', result);

Troubleshooting

401 Unauthorized

Your API key is missing or invalid.

Check that:

  • You include the X-API-Key header in every request
  • Your API key starts with mirra_
  • The key hasn't been revoked

See Authentication for more details.

400 Validation Error

Your request data failed validation.

Example error response:

{
  "success": false,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "subdomain must be between 3 and 30 characters",
    "details": {
      "field": "subdomain"
    }
  }
}

The details object indicates which field caused the validation error. Verify that all required fields are present and meet the documented constraints.

409 Conflict

The resource already exists (typically a naming conflict).

Example error response:

{
  "success": false,
  "error": {
    "code": "RESOURCE_EXISTS",
    "message": "A script with this name already exists"
  }
}

Choose a different name or verify that you do not already own the resource.

See the Error Codes reference for a complete list of error codes and handling strategies.

Next steps

Now that you have created your first script, explore more features:

  • Scripts Documentation - Learn about event-driven automation, triggers, and advanced features
  • Writing Scripts - Handler signature, the mirra client, and testing
  • Flows - Schedule scripts and wire them to events
  • Integrations - Connect Telegram, Gmail, Calendar, and more
  • Authentication - API key management and security best practices
  • Error Codes - Complete error reference and handling patterns

On this page