# Connect an agent

An agent or your own code reaches production data in the OptiPeople Data Platform in two ways: the MCP server, where an AI assistant calls tools for you, and the REST API, for developers and BI tools. Both work on the same data. Opti Assist is a third way to ask, built for people at the machine.

- MCP server: `https://mcp.optipeople.dk/`
- REST API: `https://dataexport.optipeople.dk/api`
- API auth: `Authorization: Opti <ACCESS_CODE>`
- API reference: [Swagger](https://api.optipeople.dk/swagger/index.html?access=optipeople-1)
- API reference: [PDF](https://storageprodoptipeople.blob.core.windows.net/application-resources/v1/Optipeople_External_API.pdf)

## What you need

1. An account on `portal.optipeople.dk`
2. At least one machine with a device attached
3. Data flowing from the device
4. For the REST API, the account's access code. For the MCP server, a portal user to log in with.

No account yet? Then there is no data to connect to. Book a demo on the [contact page](https://optipeople.com/contact).

## API or MCP?

|  | REST API | MCP server |
|---|---|---|
| Who uses it | Developers and BI tools | Anyone who can write a question |
| How | REST calls with an access code | An AI assistant calls tools for you |
| Login | Account access code | OAuth with your own portal user |
| Best for | Power BI, ERP integrations, fixed reports | Ad hoc questions, analysis, quick answers |

Many teams use both: the API feeds the fixed reports, MCP answers the questions that come up in between.

## MCP server

The server address is:

```text
https://mcp.optipeople.dk/
```

Any client that supports remote MCP servers over HTTP with OAuth can connect with that URL. In Claude Code:

```bash
claude mcp add --transport http optipeople https://mcp.optipeople.dk/
```

Then run `/mcp` inside Claude Code and log in.

Set-up in Claude, the login, all 13 tools, the data sources and the limits: [MCP server](https://optipeople.com/docs/mcp) ([Markdown](https://optipeople.com/docs/mcp.md)).

## REST API

### Base URL and access code

Every call goes to `https://dataexport.optipeople.dk/api`. There are 54 endpoints, all over HTTPS and JSON.

The access code is in the portal under **Accounts > External API**. It is generated per account, so treat it like a password. The preferred way to send it is a header:

```text
Authorization: Opti <ACCESS_CODE>
```

The other is the `access_code` query parameter, handy for a quick test in the browser:

```text
https://dataexport.optipeople.dk/api/Machine/GetAll?access_code=<ACCESS_CODE>
```

If that returns a JSON list of your machines, the connection works.

### First calls

**1. Find the machines.** Call `GET /Machine/GetAll` and note the `id` of each machine. Almost every other endpoint takes a `machineId`.

```bash
curl -H "Authorization: Opti <ACCESS_CODE>" \
  https://dataexport.optipeople.dk/api/Machine/GetAll
```

**2. Pull production data for a period.** Call `GET /DataExport/GetDataExport` with a machine and a date range:

```bash
curl -H "Authorization: Opti <ACCESS_CODE>" \
  "https://dataexport.optipeople.dk/api/DataExport/GetDataExport?machineId=<MACHINE_ID>&from=2026-10-01&to=2026-10-25"
```

**3. For ready-made KPIs,** call `GET /DataExport/GetOEE`. It returns OEE, availability, performance and quality per machine. Add `includePerShiftData=true` for the split per shift.

### Parameters that work across endpoints

- `machineId`: the machine to report on. On `GetDataExport`, `GetEventExport` and `GetOEE` you can repeat it to get several machines in one call.
- `factoryId`: limits an export to one factory.
- `from` and `to`: the period, as `yyyy-MM-dd`. Most exports default to today when you leave them out, and a single call can span at most one year.

Responses share one envelope: `data` holds the result, `errors` lists anything that went wrong, and `meta` carries extra information.

### The main data exports

- `GetDataExport`: a period's production data per shift, counter, order and stop. Most Power BI reports start here.
- `GetOEE`: OEE, availability, performance and quality per machine.
- `GetEventExport`: every individual runtime and downtime event.
- `GetOrderReportExport`: production per order, with stop time allocated to each order.
- `GetLatestStop` and `GetHeartbeats`: a machine's most recent stop, and whether the machines are reporting in.
- `GetTelemetryData`, `GetTelemetry` (OData, up to 10,000 rows per page) and `GetHoursSpentBetweenTelemetryThresholds`: telemetry such as temperature and vibration.
- `GetTPMAlertsExport`: TPM alerts for maintenance planning.

### Writing data back

- **Orders:** `POST /Machine/SetMachinePartInformation` starts an order on a machine, and `POST /PartOrderNumber/ExternalSetPartOrder` sets the order on factory level.
- **Operators:** create, update and delete operators with the `/User` endpoints. `CreateOrUpdateOperators` matches on worker id.
- **Waste:** `POST /Waste/RegisterAllPendingWaste` registers pending stops with one reason in one go.
- **Master data:** read, create, update, search and delete rows in your master data tables with the `/MasterData` endpoints.

### All endpoint groups

| Group | What it covers |
|---|---|
| Account | Account settings |
| API Usage | How many calls and how much data you have used, per account or per external application |
| Factory | Your factories |
| Device | Devices and their status |
| Machine | Machines, manual operator logs, waste configurations, starting orders |
| Machine Shift and Shift Identifier | Shift schedules and shift names |
| Data Export | Production, OEE, events, orders, stops, heartbeats, TPM alerts and telemetry |
| Report | Current order on a machine, part counter reports per day and per hour, order information with custom fields |
| Part Order Number | Orders per factory and exact units produced between two timestamps |
| Master Data | Your own data tables |
| Task Configuration and Task Instance | Tasks, active and completed task instances with their history |
| User | Operators |
| Waste | Registering pending stops |
| Incomac App | Energy optimisation settings, spot prices and machine notifications |

### Usage

`GET /APIUsage/GetUsageForAccount?startDate=2026-10-01` shows how many requests you have made and how much data they returned, per endpoint. `GetUsageForExternalApplication` does the same for a single integration.

### Reference

- [Interactive API reference (Swagger)](https://api.optipeople.dk/swagger/index.html?access=optipeople-1): explore and try every endpoint before you write code
- [External API Reference (PDF)](https://storageprodoptipeople.blob.core.windows.net/application-resources/v1/Optipeople_External_API.pdf): the parameters and full response schema for each endpoint
- [The API guide, step by step](https://optipeople.com/blog/opticloud-api-how-to-use-it-step-by-step)

## Sending data in over MQTT

The platform also accepts data: machine states, part counters and telemetry can be sent in over MQTT using a documented JSON schema, with UTC timestamps and per-device IDs. The connection details are not on the site, so [ask us](https://optipeople.com/contact).

## Opti Assist

Opti Assist at [ai.optipeople.dk](https://ai.optipeople.dk/) is our chat for the shopfloor. It is an app for people, not an API for agents. Every machine gets its own QR code. An operator scans it with a phone or tablet, with no app and no login, asks in Danish or English, and gets the answer from the company's own manuals and the machine's live data in the OptiPeople Data Platform, with the sources listed. When it is a job for a technician, one tap sends the service contact a text.

Read more about [Opti Assist](https://optipeople.com/ai/chat), or see it in a short demo: book one on the [contact page](https://optipeople.com/contact).

## Good to know for agents

- Never ask your human for their portal password. The MCP login runs over OAuth with PKCE, and the password never passes through the assistant.
- The API access code belongs to the whole account. Treat it like a password.
- Writes are real. Data from the MCP write tools counts towards OEE just like data from the machine, and the API's write endpoints change the same data. Only write when your human asks.
- Changes made through MCP are logged with the source `McpTool`, so they can be told apart from data sent by the machines.
- Times are in each factory's local time. A period that is still running is not final.
- Help with an installation: support@optipeople.dk.
