MuviaDevelopers
Guides: Agent quickstart

Agent quickstart

This page takes an AI agent from nothing to a first write, using only an mvk_ API key and the domain muviabi.com. Every request below is complete, and every response shows the fields that matter (long lists are cut to one or two items). Read it top to bottom once; you will not have to guess.

The same text is available as Markdown at https://developers.muviabi.com/guides/agent-quickstart.md, and https://developers.muviabi.com/llms.txt indexes every guide.

Endpoints

URL
REST base URL https://api.muviabi.com/api/public
MCP URL https://api.muviabi.com/mcp/v1

A key works only on the Muvia environment that issued it. Each environment has its own addresses:

Environment Muvia REST base URL MCP URL
Production https://app.muviabi.com https://api.muviabi.com/api/public https://api.muviabi.com/mcp/v1
Demo https://app-demo.muviabi.com https://api-demo.muviabi.com/api/public https://api-demo.muviabi.com/mcp/v1

The examples use production. A key issued on the demo environment answers 401 on production, and the other way round.

Keep the key in an environment variable and never paste it into code, logs or prompts:

export MUVIA_API_KEY="mvk_<key_id>_<secret>"

Part 1: the REST API

The REST API is read-only and returns the key's project, its datasets with their rows, and its nodes. A key reads the one project it was issued for.

1. Who am I: GET /v1/whoami

Any valid key answers, whatever its scopes, once the company runs data export (otherwise 403 module_not_active). It counts toward the key's per-minute limit but not toward the company's daily quota, so call it first and whenever you are unsure what the key allows.

curl -s -H "X-Api-Key: $MUVIA_API_KEY" https://api.muviabi.com/api/public/v1/whoami
{
  "key": {
    "id": "<key_id>",
    "name": "<key name>",
    "scopes": ["datasets_read", "nodes_read", "settings_read"],
    "expires_at": "2027-01-15T00:00:00Z"
  },
  "company": { "id": "<company_id>", "name": "<company name>" },
  "limits": {
    "requests_per_minute_per_key": 120,
    "requests_per_day_per_company": 100000,
    "requests_today_company": 412,
    "rows_page_size_max": 1000,
    "page_size_max": 100
  },
  "mcp": { "url": "https://api.muviabi.com/mcp/v1", "available": true, "writes": false },
  "links": {
    "docs": "https://developers.muviabi.com",
    "llms_txt": "https://developers.muviabi.com/llms.txt",
    "openapi": "https://api.muviabi.com/api/public/openapi.json",
    "mcp_tools": "https://api.muviabi.com/api/public/mcp/tools.json"
  }
}

key.scopes is sorted. mcp.available is true when the company's plan includes AI connectors and an administrator has switched them on. links.mcp_tools is the catalogue of the MCP server's tools as JSON; the MCP tools page shows the same catalogue.

2. The company: GET /v1/company

Needs settings_read.

curl -s -H "X-Api-Key: $MUVIA_API_KEY" https://api.muviabi.com/api/public/v1/company
{ "id": "<company_id>", "name": "<company name>" }

mcp.writes in whoami says whether this key may propose or make changes through MCP: true when an administrator has turned on «Can write through assistants» on the key and the key holds a scope that permits writing. REST itself only reads. Even a key that writes always proposes some changes, for a person to confirm: alarm work, analyses, annotations, history imports, a new project and a few more (see Writes by a key).

3. The project: GET /v1/projects

Needs settings_read. The list holds one project: the key's own.

curl -s -H "X-Api-Key: $MUVIA_API_KEY" "https://api.muviabi.com/api/public/v1/projects"
{
  "items": [
    {
      "id": "<project_id>",
      "name": "<project name>",
      "description": null,
      "is_default": false,
      "created_at": "2026-09-28T18:51:14.352000Z",
      "updated_at": "2026-10-12T12:41:19.085000Z"
    }
  ],
  "total": 1,
  "page": 1,
  "size": 50,
  "pages": 1
}

Any other project id answers 404, whether it exists or not.

4. List the project's datasets: GET /v1/projects/{project_id}/datasets

Needs datasets_read. Note each dataset's id and its columns.

curl -s -H "X-Api-Key: $MUVIA_API_KEY" \
  "https://api.muviabi.com/api/public/v1/projects/<project_id>/datasets?size=1"
{
  "items": [
    {
      "id": "<dataset_id>",
      "name": "Line stops",
      "description": "Every period in which the line is stopped, with start and duration.",
      "project_id": "<project_id>",
      "is_physical": false,
      "columns": [
        { "name": "stop_id", "type": "Int64" },
        { "name": "started_at", "type": "DateTime('Europe/Rome')" },
        { "name": "duration_seconds", "type": "Int64" }
      ],
      "created_at": "2026-09-28T18:51:09.626000Z",
      "updated_at": "2026-10-12T12:41:19.444000Z"
    }
  ],
  "total": 14,
  "page": 1,
  "size": 1,
  "pages": 14
}

A column's type is how its values are stored: Int64 and Float64 for numbers, String for text, DateTime('Europe/Rome') for a date and time in that zone. See Datasets, rows and nodes.

5. Read rows: GET /v1/projects/{projectid}/datasets/{datasetid}/rows

Needs datasets_read. Rows are paged with page and size (up to 1000); keep reading while has_more is true. start and end, ISO 8601 instants with an offset, name a period for the datasets that read one. See Pagination.

curl -s -H "X-Api-Key: $MUVIA_API_KEY" \
  "https://api.muviabi.com/api/public/v1/projects/<project_id>/datasets/<dataset_id>/rows?size=2&start=2026-09-29T00:00:00Z&end=2026-09-30T00:00:00Z"
{
  "columns": ["stop_id", "started_at", "duration_seconds"],
  "items": [
    { "stop_id": 2, "started_at": "<timestamp>", "duration_seconds": 21600 },
    { "stop_id": 64, "started_at": "<timestamp>", "duration_seconds": 21600 }
  ],
  "page": 1,
  "size": 2,
  "has_more": true
}

Every request the limits admit carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset; a refused one answers 429 with Retry-After (see Rate limits). If anything fails, the answer is the error envelope, with a hint that says what to do next.

6. What REST cannot do

REST has no query endpoint and no series endpoint. Rows come in the order the dataset's own query returns them, not oldest or newest first, and start and end narrow only the datasets that read a period. For "the latest values", a time range of any dataset, or any query of your own, use MCP: call describe_sql, then query_sql (step 11), which needs execute_queries on the key. For example, the last day of a dataset, newest first:

SELECT started_at, duration_seconds
FROM `Line stops_view`
WHERE started_at >= now() - INTERVAL 1 DAY
ORDER BY started_at DESC
LIMIT 100

Part 2: the MCP server

MCP gives an agent far more than REST: hundreds of tools, a SQL query tool and (with permission) writes. See MCP server for the model; here is the wire exchange. MCP speaks JSON-RPC over HTTP POST. Every request carries these headers:

Authorization: Bearer $MUVIA_API_KEY
Content-Type: application/json
Accept: application/json, text/event-stream

The server answers as a server-sent event: one event: message line, then one data: {...} line holding the JSON-RPC response. The examples show the JSON only.

7. initialize

curl -s https://api.muviabi.com/mcp/v1 \
  -H "Authorization: Bearer $MUVIA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"my-agent","version":"1.0"}}}'
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "protocolVersion": "2025-06-18",
    "capabilities": {
      "experimental": {},
      "logging": {},
      "prompts": { "listChanged": true },
      "resources": { "subscribe": false, "listChanged": true },
      "tools": { "listChanged": true },
      "extensions": { "io.modelcontextprotocol/ui": {} }
    },
    "serverInfo": {
      "name": "muvia",
      "version": "1.0.0",
      "websiteUrl": "https://app.muviabi.com",
      "icons": [
        {
          "src": "https://app.muviabi.com/staticassets/android-chrome-512x512.png",
          "mimeType": "image/png",
          "sizes": ["512x512"]
        }
      ]
    },
    "instructions": "Muvia is an industrial data platform. Tools act as the connected person, in the company they connected, within the scopes they granted.\nCall whoami first, then list_projects: every other tool acts inside one project, whose time zone and rules describe_project tells.\nfind_tools names the tools of an area (datasets, signals, nodes, alarms, dashboards, analyses, reports, documents, predictors) when your client cannot search its tool list.\nPrefer the curated reads; use query_sql, after describe_sql, only when they are not enough."
  }
}

The server also speaks 2025-11-25, 2025-03-26 and 2024-11-05; ask for the one your client implements. Then tell the server you are ready. It answers 202 with no body:

curl -s -o /dev/null -w "%{http_code}\n" https://api.muviabi.com/mcp/v1 \
  -H "Authorization: Bearer $MUVIA_API_KEY" -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","method":"notifications/initialized"}'

8. tools/list

curl -s https://api.muviabi.com/mcp/v1 \
  -H "Authorization: Bearer $MUVIA_API_KEY" -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}'

The answer lists the tools this key may call, each with its name, title, description, inputSchema and annotations. Two entries:

{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "tools": [
      {
        "name": "whoami",
        "title": "Who am I",
        "description": "Who this connection acts as: person or API key, company, scopes granted, client. Call it first.",
        "inputSchema": { "type": "object", "properties": {} },
        "annotations": { "readOnlyHint": true, "openWorldHint": false }
      },
      {
        "name": "annotate_signal",
        "title": "Annotate signals",
        "description": "Propose a note on signals over a stretch.",
        "inputSchema": {
          "type": "object",
          "properties": {
            "project_id": { "type": "string" },
            "signals": { "type": "array", "items": { "type": "string" }, "description": "list_signals ids." },
            "start": { "type": "string", "format": "date-time", "description": "ISO 8601." },
            "end": { "type": "string", "format": "date-time", "description": "ISO 8601." },
            "text": { "type": "string" },
            "label": { "type": "string", "enum": ["event", "maintenance", "anomaly", "note"] },
            "color": { "type": "string", "enum": ["blue", "green", "yellow", "orange", "red", "pink", "purple", "grey"] }
          },
          "required": ["project_id", "signals", "start", "end", "text"]
        },
        "annotations": { "destructiveHint": false, "openWorldHint": false }
      }
    ]
  }
}

readOnlyHint: true marks a read. A write states destructiveHint instead: true for the writes that delete or overwrite something, false for the others. Every tool, with its arguments, is also listed for reading on MCP tools (as Markdown at https://developers.muviabi.com/mcp-tools.md).

9. Call whoami

curl -s https://api.muviabi.com/mcp/v1 \
  -H "Authorization: Bearer $MUVIA_API_KEY" -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"whoami","arguments":{}}}'

A tool answer carries the result twice: as text in content and as an object in structuredContent. Read structuredContent.

{
  "jsonrpc": "2.0",
  "id": 3,
  "result": {
    "content": [{ "type": "text", "text": "{\"kind\":\"api_key\", ...}" }],
    "structuredContent": {
      "kind": "api_key",
      "company": { "id": "<company_id>", "name": "<company name>" },
      "user": null,
      "client": null,
      "scopes": ["analysis_annotate", "datasets_read", "settings_read"],
      "permissions": ["analysis_annotate", "datasets_read", "settings_read"],
      "key": { "name": "<key name>", "created_by": "<email>" },
      "writes": true
    },
    "isError": false
  }
}

writes is a plain boolean: true when an administrator has turned on «Can write through assistants» on this key and it holds a scope that permits writing (here analysis_annotate). For a key, scopes are the ones it may use now, sorted; permissions are sorted. For a key, key holds its name and created_by. See MCP server.

10. Find the project: list_projects

curl -s https://api.muviabi.com/mcp/v1 \
  -H "Authorization: Bearer $MUVIA_API_KEY" -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"list_projects","arguments":{}}}'
{
  "jsonrpc": "2.0",
  "id": 4,
  "result": {
    "structuredContent": {
      "columns": ["id", "name", "description"],
      "rows": [
        ["<project_id>", "<project name>", null]
      ],
      "truncated": false
    },
    "isError": false
  }
}

A key reaches its one project. Tables come back as columns plus rows (arrays in column order); truncated: true means the list was cut short.

11. Run a query: query_sql

query_sql needs execute_queries on the key. Call describe_sql first to learn which tables the project's SQL can read; it answers {"columns":["name","read_in_sql_as"],"rows":[...]}, and the second column is the name to write in FROM, exactly as given and in backticks: a dataset is usually its name, character for character, plus _view (Line stops_view), a source a name of its own. describe_sql is the only source of table names. Then run one SELECT:

curl -s https://api.muviabi.com/mcp/v1 \
  -H "Authorization: Bearer $MUVIA_API_KEY" -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":6,"method":"tools/call","params":{"name":"query_sql","arguments":{"project_id":"<project_id>","sql":"SELECT stop_id, started_at, duration_seconds FROM `Line stops_view` ORDER BY started_at LIMIT 2","limit":2}}}'
{
  "jsonrpc": "2.0",
  "id": 6,
  "result": {
    "structuredContent": {
      "columns": ["stop_id", "started_at", "duration_seconds"],
      "rows": [
        [2, "2026-09-29T03:14:02+02:00", 21600],
        [4, "2026-09-29T15:14:02+02:00", 21600]
      ],
      "truncated": false,
      "zone": "Europe/Rome"
    },
    "isError": false
  }
}

To read a time range, put a WHERE on the time column and ORDER BY it DESC with a LIMIT, as in step 6. truncated: true means more rows matched than limit (100 by default, at most 1000) returned. zone is the project's time zone, in which instants are written. A query that uses {timeFilter(column)} reads the period named by period (time_1_day, time_7_days, all and the others the tool's schema lists). query_sql only ever runs a read-only SELECT.

12. A write: annotate_signal

Writes use the same tools/call. Here the agent asks Muvia to note a planned stop on a signal (signals takes ids from list_signals, step 13):

curl -s https://api.muviabi.com/mcp/v1 \
  -H "Authorization: Bearer $MUVIA_API_KEY" -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":7,"method":"tools/call","params":{"name":"annotate_signal","arguments":{"project_id":"<project_id>","signals":["tag:<node_id>:<driver_id>:line_power"],"start":"2026-09-29T01:14:02Z","end":"2026-09-29T07:14:02Z","text":"Planned stop for filter change","label":"maintenance"}}}'

An annotation records who made it, so a key always proposes it, whatever the company chose (see Writes by a key). Nothing has changed yet: a person approves the proposal in Muvia by opening approve_url, and the note is then theirs. The key cannot approve its own proposal, through the API or the MCP server: hand approve_url and message to a person and follow the action with get_action (step 14).

{
  "jsonrpc": "2.0",
  "id": 7,
  "result": {
    "structuredContent": {
      "status": "pending",
      "action_id": "<action_id>",
      "approve_url": "https://app.muviabi.com/approvals/<action_id>?project=<project_id>",
      "message": "<what to do next>",
      "summary": "<what it would change>",
      "needs_admin": false
    },
    "isError": false
  }
}

Calling the same write again does not write twice. While the first waits for a person, it answers that same proposal; while it is being applied, {"status": "applying", "action_id": "<action_id>"}; within 30 seconds of it being applied, the applied answer again.

13. Worked example: create a dashboard and an analysis

Both tools are writes, so both answer with a proposal or an applied change (see below). First find the ids they need.

Signal ids: list_signals returns one row per signal; the id is what create_analysis and annotate_signal take. Signal ids are long and structured (tag:<node>:<driver>:<name>); copy them exactly.

curl -s https://api.muviabi.com/mcp/v1 \
  -H "Authorization: Bearer $MUVIA_API_KEY" -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":9,"method":"tools/call","params":{"name":"list_signals","arguments":{"project_id":"<project_id>","limit":2}}}'
{
  "columns": ["id", "name", "unit", "last_value", "last_at", "status", "untrackable_reason"],
  "rows": [
    ["tag:<node_id>:<driver_id>:ambient_temperature", "ambient_temperature", "°C", 22.67, "2026-10-19T21:05:34+00:00", "Healthy", null],
    ["tag:<node_id>:<driver_id>:line_power", "line_power", "kW", 870.5, "2026-10-19T21:05:34+00:00", "Healthy", null]
  ],
  "truncated": true,
  "narrow": "More signals match than are listed here: to narrow them, name a signal, a driver or a node in search, or raise limit.",
  "total": 48,
  "states": { "Healthy": 45, "Stopped": 3 },
  "views": { "All": 48, "To fix": 3, "Monitored": 6 },
  "drivers": [ … ]
}

status is the signal's state as Muvia shows it (Healthy, Late, Stopped, Never arrived and others); total, states and views count every signal that matched, however many rows fit. list_signals takes no offset: when truncated is true, it says so in narrow; narrow the list with search (a signal's, driver's or node's name) or raise limit. When a project has many similar signals, the answer may also group them under families.

create_analysis. project_id and title are required; signals (ids from list_signals), start and end (ISO 8601) give one trend; or definition gives a full analysis in the shape get_analysis returns; description and labels are optional. Needs analysis_edit on the key.

{
  "jsonrpc": "2.0",
  "id": 10,
  "method": "tools/call",
  "params": {
    "name": "create_analysis",
    "arguments": {
      "project_id": "<project_id>",
      "title": "Ambient temperature and line power",
      "signals": [
        "tag:<node_id>:<driver_id>:ambient_temperature",
        "tag:<node_id>:<driver_id>:line_power"
      ],
      "start": "2026-10-12T00:00:00Z",
      "end": "2026-10-19T00:00:00Z",
      "description": "Last week, one trend"
    }
  }
}

create_dashboard. project_id, name and widgets are required; needs dashboards_edit on the key. Each widget has a title and a type: CHART, NUMBER, LABEL, ALARM, ENUM, TABLE or RECORD. A widget reads the columns of a dataset: dataset_id is any dataset's id from list_datasets (the same id the REST /datasets routes use), and channels maps what the widget reads to column names of that dataset:

  • a CHART takes a chart_kind, and its channels follow it: x and y (a list) for line, bar and scatter; label and value for bar, pie, funnel, waterfall and pareto; x, y and size for bubble; y for histogram; value for gauge and progress;
  • a TABLE or a RECORD reads columns, a list; the other types read value;
  • a NUMBER also takes suffix (such as " kWh"), decimals (0 to 6), icon and tone_from_bands; reduce says how a column becomes one value.
{
  "jsonrpc": "2.0",
  "id": 11,
  "method": "tools/call",
  "params": {
    "name": "create_dashboard",
    "arguments": {
      "project_id": "<project_id>",
      "name": "Daily energy",
      "widgets": [
        {
          "title": "Energy used per day",
          "type": "CHART",
          "chart_kind": "line",
          "dataset_id": "<dataset_id>",
          "channels": { "x": "bucket", "y": ["consumption"] }
        }
      ]
    }
  }
}

Outcome 1: a proposal awaiting confirmation («Ask for confirmation», the usual autonomy). Nothing is created yet; a person opens approve_url in Muvia and confirms. The change is then applied as that person.

{
  "jsonrpc": "2.0",
  "id": 11,
  "result": {
    "structuredContent": {
      "status": "pending",
      "action_id": "<action_id>",
      "approve_url": "https://app.muviabi.com/approvals/<action_id>?project=<project_id>",
      "message": "<what to do next>",
      "summary": "<what it would change>",
      "needs_admin": false
    },
    "isError": false
  }
}

Outcome 2: applied at once (an administrator chose «Run at once» for this kind of change, in Settings › Company › AI connectors › Autonomy):

{
  "jsonrpc": "2.0",
  "id": 11,
  "result": {
    "structuredContent": {
      "status": "applied",
      "action_id": "<action_id>",
      "id": "<dashboard_id>",
      "url": "https://app.muviabi.com/dashboard/<dashboard_id>?project=<project_id>"
    },
    "isError": false
  }
}

A change made by a key is shown in Muvia as authored by «API key» and the key's name. create_analysis called with a key always answers with Outcome 1, whatever the autonomy: an analysis belongs to a person, so the person who confirms it creates and owns it (see Writes by a key). Through a person's OAuth assistant it answers in either shape, like create_dashboard; once applied, its url opens the analysis (https://app.muviabi.com/analysis/<analysis_id>?project=<project_id>).

14. What became of it: get_action

Ask later what a proposal turned into. A proposal still waiting answers as in step 12. Otherwise status is applying, applied (with its result), failed (with a reason), discarded, expired (nobody decided within seven days) or stale (what it would change has changed since).

curl -s https://api.muviabi.com/mcp/v1 \
  -H "Authorization: Bearer $MUVIA_API_KEY" -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":8,"method":"tools/call","params":{"name":"get_action","arguments":{"action_id":"<action_id>"}}}'

The annotation of step 12, once a person approved it:

{
  "jsonrpc": "2.0",
  "id": 8,
  "result": {
    "structuredContent": {
      "status": "applied",
      "result": {
        "id": "<annotation_id>",
        "url": "https://app.muviabi.com/analysis/explore?project=<project_id>"
      }
    },
    "isError": false
  }
}

A key that may not write gets a refusal instead, with isError: true and the text «This API key can only read. To propose or make changes through an assistant, an administrator must turn on «Can write through assistants» on the key, in Settings › Company › API keys.» Some tools stay a person's even for a writing key; see Writes by a key. Do not retry a refusal unchanged.

Where next