Overview
One client-mode connector, MachineMetrics, for the MachineMetrics cloud APIs athttps://api.machinemetrics.com. MachineMetrics collects data from CNC and other shop-floor machines and turns it into machine state, alarms, downtime, part counts and OEE. This connector brings that data into your Unified Namespace and keeps planned breaks and holidays in sync.
The API has two parts:
- GraphQL (
POST /graphql, read-only): live machine data such as current execution state, active alarms, open downtime annotations, part counts and any other object in the published schema. - REST: production and quality report rollups (OEE, good and rejected parts, cycle time, downtime) with optional CSV download, scheduled time per machine, and the work schedule events API for breaks and holidays.
Topics are
mes/machinemetrics/<object>/<verb>; every reply goes to <topic>/response.
The three Machines... events send the same request as GraphqlQuery. They exist so state, alarms and downtime replies land on their own topics; the query you put in body decides what comes back.
Authentication
Every event except the two CSV downloads sendsAuthorization: Bearer {api_token}. Create the key in MachineMetrics under Settings → API Keys (https://app.machinemetrics.com/app/settings/api-keys). A key belongs to the company it was created in and is shown only once.
Choose the scopes when you create the key:
Use a separate key for each integration and give it only the scopes it needs. Keep it in a broker secret (suggested
MACHINEMETRICS_API_TOKEN) and map it in with GET SECRET. A missing or wrong key returns 401 with AuthenticationError, and a key without the scope returns 403.
The CSV downloads authenticate differently: call GetCsvToken for a JWT, then pass it as token=<jwt> in query.
Basic Syntax
MachinemetricsRestApi.lot in the REST API app. GovCloud tenants set BASE_ADDRESS to https://api.machinemetrics-us-gov.com.
MQTT examples
Request bodies go underbody, so control fields like api_token, machine_ref and query are not sent to MachineMetrics.
Current execution state of every machine: publish to mes/machinemetrics/machine-state/get:
{"data": {"machines": [...]}}, one entry per machine with its MasterExecution state (for example ACTIVE) and when that state started. Leave out the where filter to get every current state metric.
Active alarms: publish to mes/machinemetrics/machine-alarm/get:
mes/machinemetrics/machine-downtime/get:
mes/machinemetrics/production-report/create:
totalParts, rejectedParts, timeInCycle, timeInCut, setupTime and utilizationRate; other groups include day, shift, operator and jobOperation. Add "csv": true and the reply carries csv.url; download it with GetCsvToken and GetProductionCsv, using the id at the end of that URL as resource_id.
Scheduled time for one machine: publish to mes/machinemetrics/machine-scheduled-time/get. The query string must be URL-encoded:
"query": "" on GET events when you do not need options.
Add a plant holiday: publish to mes/machinemetrics/work-schedule-event/create with a key that has the user scope:
work-schedule-event/assign (event_ref plus {"workScheduleRefs": [...], "startRRule": {...}}).
Helper actions
Keep the key in a broker secret, poll machine state every minute, and request a day’s OEE from any topic:mes/machinemetrics/# with a rule: its payloads carry the API key, and the work schedule events change planned production time.
Notes
- The GraphQL API is read-only. Limits: 1000 operations per minute per company, query depth 5, at most 5 object nodes, 10 seconds per query. GraphQL errors come back as
200with anerrorsarray, so check the reply body. - Times are UTC. Report
startDay/endDayare dates (YYYY-MM-DD);startAt/endAtare ISO 8601 date-times. machineRef,workScheduleRefand the other refs are MachineMetrics integer ids. Get machine refs from amachines { machineRef name }query.- Not covered by this connector:
POST /jobs/import(multipart CSV upload), MachineMetrics webhooks (MachineMetrics calls your URL when a workflow fires, for example on categorized downtime; receive them with a server-mode connector or another HTTP endpoint), and edge data collection (MTConnect, MQTT and adapter scripts run on the MachineMetrics edge device, not through this API).

