# Assign operator by time (https://docs.pulsarml.com/v1/api-reference/shifts/post-shifts-operator)

Assign an operator to the shift that machine `machineId` was running at `start`. Use it to
record who ran a machine after the shift ended, for example a day later from a planning
system. For a live shift at a floor terminal, `POST /v1/realtime/{machine_id}/operator` is
the shorter call.

The operator takes over at `start` and keeps the machine until the end of the shift, or until
a later assignment. If nobody is assigned to the shift yet, the operator covers the whole
shift. To record several operators in one shift, send them in chronological order: a `start`
before the shift's latest operator change is rejected. Sending the same assignment again is
harmless.

Operator metrics for the shift are recalculated in the background.

Errors:

* `400`: no shift matches, or `start` is outside the shift, in the future, or before the
  shift's latest operator change.
* `403`: the shift has production marked as reviewed, which locks it.
* `404`: the operator does not exist in your company.

## `POST /v1/shifts/operator`

Base URLs:
- `https://draco.prod.pulsarml.com` — Production
- `https://draco.dev.pulsarml.com` — Development (sandbox)

Authentication: send your API key in the `x-api-key` header.

### Request body (`application/json`, required)

Type: object (`AssignOperatorToMachineShiftRequestV1`)

- `machineId` (integer, required, e.g. `12`) — The id of the machine, as returned by `GET /v1/machines`.
- `operatorId` (integer, required, e.g. `1063`) — The id of the operator, as returned by `/v1/operators`.
- `start` (string (date-time), required, e.g. `"2026-10-12T10:00:00Z"`) — When the operator takes over. It selects the machine's shift running at that moment and must not be in the future. A time without a UTC offset is read as UTC.

### Responses

#### 200 — The shift the operator was assigned to

Type: object (`ShiftOperatorAssignmentDtoV1`)

- `shiftId` (integer, required, e.g. `48213`) — The shift the operator was assigned to.
- `machineId` (integer, required, e.g. `12`) — The machine the shift belongs to.
- `operatorId` (integer, required, e.g. `1063`) — The operator that was assigned.
- `start` (string (date-time), required, e.g. `"2026-10-12T10:00:00Z"`) — When the operator took over. They keep the machine until the end of the shift, or until a later assignment.

#### 422 — Validation Error

Type: object (`HTTPValidationError`)

- `detail` (array of object, optional)
  - `loc` (array of string | integer, required)
  - `msg` (string, required)
  - `type` (string, required)

### Example request

```bash
curl -X POST 'https://draco.prod.pulsarml.com/v1/shifts/operator' \
  -H 'x-api-key: <YOUR_API_KEY>' \
  -H 'Content-Type: application/json' \
  -d '{
    "machineId": 12,
    "operatorId": 1063,
    "start": "2026-10-12T10:00:00Z"
  }'
```