Skip to main content

API keys

An API key lets a program read plant data: a BI tool, a script, a monthly report. A key can never write or change anything. The public API is read-only and GET-only, separate from the internal Console API.

Settings, API keys: list of keys with scopes, owner and state
Settings, API keys: list of keys with scopes, owner and state
API keys versus agent credentials

API keys (mii_pk_...) are for programs and reports and work only on /api/public/v1. AI assistants use agent credentials (mii_ac_...) on the MCP endpoint. See MCP server.

How it works​

  • A key has an owner (a user). The key can never read more than its owner, and it stops working when the owner is disabled.
  • A key has scopes that name what it may read, and an optional limit to part of the plant.
  • A key expires. You choose the validity, 1 to 366 days (default 90).
  • The key secret is shown once. The Console stores only a hash.
  • Values of tags that governance marks as not allowed to leave the plant come back with "withheld": "egress_denied" and no value. See Governance.

Step by step: create a key​

  1. Sign in as a user with manage_users.
  2. Open Settings → API keys.
  3. Enter a Name, for example Monthly report.
  4. Choose the Owner.
  5. Under What it may read, choose the scopes (table below).
  6. Set Valid for (days) (1 to 366, default 90).
  7. Under Limit to part of the plant choose Whole plant, Only these devices or Only below this path (for example DEMOFOODS/IZMIR/BOTTLING).
  8. Create the key. Click Copy key, store it in your secret manager, then click I have saved it.

Optionally click Download API description to fetch the OpenAPI 3.1 document. That download itself needs a key.

Scopes​

ScopeUI labelOwner must holdEndpoints
model:readPlant modelread_configsites, areas, work-centers, equipment, equipment tags
values:readLast valuesread_historyvalues/last
history:readHistoryread_historyhistory/series, history/table, oee, oee/losses
alarms:readAlarmsread_configalarms/active, alarms/journal
kg:readKnowledge graphread_configkg/vocabulary, kg/graph, kg/edges, kg/impact

The equipment state route kg/equipment/{id}/state needs both kg:read and values:read.

Manage keys​

A key is shown as Active, Expires soon (under 14 days), Expired or Revoked.

  • Replace rotates a key. The previous key keeps working for a grace period you choose: not at all, 1 hour, 24 hours or 7 days (API default 24 hours, at most 168 hours).
  • Revoke is immediate and cannot be undone.

API: GET, POST /api/v2/api-keys (body name, ownerUserId, scopes, expiresInDays, deviceIds, pathPrefix; the response has key and secret); POST /api/v2/api-keys/{id}/rotate (body {"graceHours": 24}); DELETE /api/v2/api-keys/{id}.

Call the API​

Send the key as a bearer token.

Authorization: Bearer mii_pk_...
export MII_API_KEY=mii_pk_...
curl -H "Authorization: Bearer $MII_API_KEY" \
"https://<console>/api/public/v1/sites"

Parameters that a route does not list are refused. You can pass at most 100 ids or paths per request. History windows are at most 31 days. Each key may make 300 requests per minute; above that the answer is 429 with MI-4003 and a Retry-After header.

Endpoints​

All are GET.

PathScopeParameters
/keyany keyMetadata of the calling key (id, scopes, expiry).
/openapi.jsonany keyThe OpenAPI description.
/sitesmodel:read
/areasmodel:readsiteId (required)
/work-centersmodel:readareaId (required)
/equipmentmodel:readworkCenterId, workUnitId
/equipment/{id}/tagsmodel:read
/values/lastvalues:readtagIds and/or paths (comma-separated, at least one)
/history/serieshistory:readtagIds or paths, from and to (required, at most 31 days), step (for example 1m), agg (avg, min, max, last, count)
/history/tablehistory:readtagIds or paths, from, to, limit (1 to 5000), offset
/oeehistory:readequipment, group (total, shift, day, order), from, to
/oee/losseshistory:readequipment, from, to
/alarms/activealarms:read
/alarms/journalalarms:readlimit (1 to 5000)
/kg/vocabularykg:read
/kg/graphkg:readroot, depth, rels
/kg/edgeskg:readnode, rel, limit (1 to 1000), offset
/kg/impactkg:readnode (required), depth
/kg/equipment/{id}/statekg:read and values:read

Examples​

The JSON below is illustrative: list responses carry items and count (history uses points), and the fields inside each item can vary by route and version. Rely on value, withheld, quality and time fields; do not hard-code other field names without checking the OpenAPI document of your Console.

Last value of the Filler speed:

curl -G -H "Authorization: Bearer $MII_API_KEY" \
--data-urlencode "paths=DEMOFOODS/IZMIR/BOTTLING/LINE1/FILLER/Speed" \
"https://<console>/api/public/v1/values/last"
{
"items": [
{
"path": "DEMOFOODS/IZMIR/BOTTLING/LINE1/FILLER/Speed",
"value": 120,
"unit": "bottles/min",
"quality": "good",
"timestamp": "2026-12-02T10:15:30.123Z"
}
],
"count": 1
}

One hour of the compressor pressure in 1-minute averages:

curl -G -H "Authorization: Bearer $MII_API_KEY" \
--data-urlencode "tagIds=<tagId>" \
--data-urlencode "step=1m" --data-urlencode "agg=avg" \
--data-urlencode "from=2026-12-02T09:00:00Z" \
--data-urlencode "to=2026-12-02T10:00:00Z" \
"https://<console>/api/public/v1/history/series"
{
"points": [
{ "tagId": "<tagId>", "ts": "2026-12-02T09:00:00Z", "value": 6.82, "qualityState": "good" },
{ "tagId": "<tagId>", "ts": "2026-12-02T09:01:00Z", "value": 6.79, "qualityState": "good" }
],
"count": 2
}

A tag whose data may not leave the plant:

{
"items": [
{ "path": "DEMOFOODS/IZMIR/BOTTLING/LINE1/FILLER/Speed", "withheld": "egress_denied" }
],
"count": 1
}

Active alarms:

curl -H "Authorization: Bearer $MII_API_KEY" \
"https://<console>/api/public/v1/alarms/active"

Errors use the standard envelope: {"error": {"code": "MI-4001", "message": "a valid API key is required"}}.

Audit​

Every call with a key is recorded in the MCP audit with the method public-api and the client api-key: who, when, route, result. Arguments and values are not stored. Retention follows MI_MCP_AUDIT_RETENTION_DAYS. See Audit trail.

Limits and good practice​

  • Use one key per program, the narrowest scopes, and a path or device limit.
  • Rotate with a grace period instead of revoking when a program must keep running.
  • A key sent to any other route fails with 403 "this route is not available to an API key".
  • The public API is read-only. To change something, use the Console or an approved proposal.

Troubleshooting​

SymptomCauseFix
401 MI-4001Missing, wrong, expired or revoked key, or the owner is disabled.Check the key and its state.
403 MI-4002The key's scopes or the owner's roles do not allow this route.Add the scope, or fix the owner's role.
400A parameter is not allowed, the window is over 31 days, or more than 100 ids.Fix the request.
429 MI-4003More than 300 requests per minute.Wait for Retry-After.
Empty or withheld valuesEgress rules or a path limit.See Governance.