# Connect a machine (/docs/guides/connect-machine)



Factory OS ingests telemetry over MQTT or REST. MQTT is preferred for high-frequency sample data; REST is fine for low-rate integrations or batch backfills.

## 1. Register the machine [#1-register-the-machine]

Create a machine record via the dashboard or API:

```bash
curl -X POST https://api.xentr.ai/api/factories/[factory-slug]/machines \
  -H "Authorization: Bearer $XENTR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "code": "CNC-001",
    "name": "Haas VF-2",
    "type": "cnc"
  }'
```

## 2. Provision credentials [#2-provision-credentials]

Request MQTT credentials for the machine:

```bash
curl -X POST https://api.xentr.ai/api/provisioning/machines/CNC-001/credentials \
  -H "Authorization: Bearer $XENTR_TOKEN"
```

You'll receive an MQTT username, password, and topic prefix.

## 3. Publish telemetry [#3-publish-telemetry]

Publish samples to `factories/<slug>/machines/<code>/telemetry`:

```json
{
  "ts": "2026-04-18T12:00:00Z",
  "metrics": {
    "spindle_rpm": 4500,
    "feed_rate": 1200,
    "state": "running"
  }
}
```

Samples are written to TimescaleDB and made available to OEE, quality, and dashboard queries in real time.

## 4. Verify in dashboard [#4-verify-in-dashboard]

Open your factory in the Xentr dashboard — the machine should show live data within 10 seconds of the first publish.

***

<Callout>
  For PLC, OPC-UA, or FOCAS (Fanuc CNC) integrations, Xentr provides edge drivers. See [Provisioning](/docs/api-reference/provisioning) or contact support.
</Callout>
