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.

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
- Sign in as a user with
manage_users. - Open Settings → API keys.
- Enter a Name, for example
Monthly report. - Choose the Owner.
- Under What it may read, choose the scopes (table below).
- Set Valid for (days) (1 to 366, default 90).
- Under Limit to part of the plant choose Whole plant, Only these devices or Only below this path (for example
DEMOFOODS/IZMIR/BOTTLING). - 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
| Scope | UI label | Owner must hold | Endpoints |
|---|---|---|---|
model:read | Plant model | read_config | sites, areas, work-centers, equipment, equipment tags |
values:read | Last values | read_history | values/last |
history:read | History | read_history | history/series, history/table, oee, oee/losses |
alarms:read | Alarms | read_config | alarms/active, alarms/journal |
kg:read | Knowledge graph | read_config | kg/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.
| Path | Scope | Parameters |
|---|---|---|
/key | any key | Metadata of the calling key (id, scopes, expiry). |
/openapi.json | any key | The OpenAPI description. |
/sites | model:read | |
/areas | model:read | siteId (required) |
/work-centers | model:read | areaId (required) |
/equipment | model:read | workCenterId, workUnitId |
/equipment/{id}/tags | model:read | |
/values/last | values:read | tagIds and/or paths (comma-separated, at least one) |
/history/series | history:read | tagIds or paths, from and to (required, at most 31 days), step (for example 1m), agg (avg, min, max, last, count) |
/history/table | history:read | tagIds or paths, from, to, limit (1 to 5000), offset |
/oee | history:read | equipment, group (total, shift, day, order), from, to |
/oee/losses | history:read | equipment, from, to |
/alarms/active | alarms:read | |
/alarms/journal | alarms:read | limit (1 to 5000) |
/kg/vocabulary | kg:read | |
/kg/graph | kg:read | root, depth, rels |
/kg/edges | kg:read | node, rel, limit (1 to 1000), offset |
/kg/impact | kg:read | node (required), depth |
/kg/equipment/{id}/state | kg: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
| Symptom | Cause | Fix |
|---|---|---|
401 MI-4001 | Missing, wrong, expired or revoked key, or the owner is disabled. | Check the key and its state. |
403 MI-4002 | The key's scopes or the owner's roles do not allow this route. | Add the scope, or fix the owner's role. |
| 400 | A parameter is not allowed, the window is over 31 days, or more than 100 ids. | Fix the request. |
429 MI-4003 | More than 300 requests per minute. | Wait for Retry-After. |
Empty or withheld values | Egress rules or a path limit. | See Governance. |