# Ingest telemetry (/docs/guides/ingest-telemetry)



## MQTT (preferred) [#mqtt-preferred]

For sample rates above 1 Hz, publish to MQTT. Topic convention:

```
factories/<factory-slug>/machines/<machine-code>/telemetry
```

Payload:

```json
{
  "ts": "2026-04-18T12:00:00.123Z",
  "metrics": {
    "temp_c": 72.4,
    "pressure_bar": 120,
    "state": "running"
  }
}
```

Timestamps must be ISO 8601 UTC. Missing `ts` uses server time at receipt.

## REST batch [#rest-batch]

For integrations that can't use MQTT, POST batches of up to 500 samples:

```bash
curl -X POST https://api.xentr.ai/api/monitoring/telemetry \
  -H "Authorization: Bearer $XENTR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "machineCode": "CNC-001",
    "samples": [
      { "ts": "2026-04-18T12:00:00Z", "metrics": { "temp_c": 72.4 } },
      { "ts": "2026-04-18T12:00:05Z", "metrics": { "temp_c": 72.8 } }
    ]
  }'
```

## Backfill [#backfill]

Historical backfills are supported for up to 90 days. Use the same batch endpoint — timestamps older than 90 days are rejected.

## Buffering and gaps [#buffering-and-gaps]

Edge drivers use a write-ahead log and gap-detection. If the network drops, samples buffer locally and flush on reconnect. The [Data Quality API](/docs/api-reference/monitoring) exposes gap reports per machine.
