Getting Started
Go from a fresh set of MQinsights API credentials to your first successful request in under ten minutes.
Before You Begin
- A
client_idandclient_secretfor the MQinsights API, provided by MachineQ Support. - Your environment's
{{AUTH0_DOMAIN}}and{{API_DOMAIN}}values (also provided separately; these differ per environment and are never hardcoded). - curl and jq installed locally.
Windows Users: The shell commands in this guide are written for Bash. If you're on PowerShell, syntax may differ. For the smoothest experience, use WSL or Cygwin.
Step 1: Get an Access Token
The MQinsights API uses the OAuth 2.0 client credentials grant flow, a server-to-server flow that doesn't require user interaction. See Authentication for the full reference.
export MQ_CLIENT_ID="YOUR_CLIENT_ID"
export MQ_CLIENT_SECRET="YOUR_CLIENT_SECRET"
export MQ_AUDIENCE="YOUR_AUDIENCE"
curl -sS -X POST "$AUTH0_DOMAIN/oauth/token" \
-H "Content-Type: application/json" \
-H "X-B3-TraceId: 1234567890abcdef1234567890abcdef" \
-H "X-B3-SpanId: 1234567890abcdef" \
-d '{
"client_id": "'"$MQ_CLIENT_ID"'",
"client_secret": "'"$MQ_CLIENT_SECRET"'",
"audience": "'"$MQ_AUDIENCE"'",
"grant_type": "client_credentials"
}' | jq
Export the token from the response; you'll need it on every subsequent request:
export MQ_TOKEN="<access_token_from_response>"
Token Expiration: Tokens typically expire after 24 hours (86400 seconds). Refresh the token when it expires or after receiving a
401 Unauthorizedresponse.
Step 2: Make Your First Request
Look up the location of a known asset by its customer_reference (your equipment ID):
curl -sS "{{API_DOMAIN}}/integrations/asset/105222/location" \
-H "Authorization: Bearer $MQ_TOKEN" \
-H "X-B3-TraceId: 1234567890abcdef1234567890abcdef" \
-H "X-B3-SpanId: 1234567890abcdef" | jq
A healthy response looks like:
{
"customer_reference": "105222",
"campus_id": "PHL",
"building_id": "A41",
"room_id": "413177",
"zone_id": "413177_1",
"status": "ACTIVE",
"confidence": "ZONE",
"tag_identifier": ["E5-EA-71-1D-24-72"],
"location_updated_at": "2022-02-15T19:17:55+00:00"
}
Step 3: Explore the Rest of the API
- Create or update assets by equipment ID with Asset Management.
- Pull temperature, humidity, occupancy, and other readings with Sensor Data.
- Track how long equipment is in use with Asset Utilization.
- Monitor device and gateway connectivity across your campuses with Site Health.
What's Next?
- Authentication: Full OAuth 2.0 reference, required headers, and token handling.
- Asset Management: Create, locate, search, and delete assets.
- Sensor Data: Query readings across 40+ sensor types.
- Asset Utilization: Track usage events over time.
- Site Health: Instance-wide and per-building connectivity health.
Support
For technical assistance, contact the MachineQ Support team at support@machineq.com, or browse the support portal at support.machineq.com for troubleshooting guides, FAQs, and release notes.