# Set shift targets (https://docs.pulsarml.com/v1/api-reference/shifts/put-shifts-targets)

Set the production target of existing shifts, for upcoming or past days. The body is a JSON
**array** of up to 1,000 rows, so a whole plan (or a CSV export of one) fits in one call.

Each row names a shift by its machine (`uuid` or `name`), the `date` it starts on in the
company's timezone, and its `title` (for example `Morning`). Sending the same values again is
harmless: the target is overwritten, not added to.

Every row comes back with a `status`, and only `updated` rows changed anything:

* `updated`: the shift's target is now `targetQuantity`.
* `machineNotFound` / `ambiguousMachine`: no machine, or more than one, matches `machine`.
* `shiftNotFound` / `ambiguousShift`: the machine has no shift, or more than one, with that
  title starting on that date.
* `duplicateShift`: another row in the same request points at the same shift, so neither was
  applied.

Targets are read live from the shift, so realtime and shift views show the new value right
away. Nothing is recalculated: the target is not an input to OEE.

## `PUT /v1/shifts/targets`

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: array of object

- `machine` (object, required) — The machine the shift belongs to.
  - `uuid` (string (uuid), optional, nullable, e.g. `"0190c1c2-7a3e-7cc1-9b2f-1d2e3f4a5b6c"`) — The machine's `uuid`, as returned by `GET /v1/machines`.
  - `name` (string, optional, nullable, min length 1, e.g. `"Line 1"`) — The machine's name (or external name), matched exactly and case-insensitively.
- `date` (string (date), required, e.g. `"2026-10-12"`) — The date the shift starts on, in the company's timezone (`YYYY-MM-DD`). A night shift that starts at 22:00 on the 12th and ends on the 13th is addressed with the 12th.
- `title` (string, required, min length 1, e.g. `"Morning"`) — The shift's name, matched exactly and case-insensitively.
- `targetQuantity` (integer, required, >= 0, e.g. `1200`) — The production target for the shift, in units.

### Responses

#### 200 — One result per row, in request order

Type: array of object

- `machine` (object, required) — The machine the shift belongs to.
  - `uuid` (string (uuid), optional, nullable, e.g. `"0190c1c2-7a3e-7cc1-9b2f-1d2e3f4a5b6c"`) — The machine's `uuid`, as returned by `GET /v1/machines`.
  - `name` (string, optional, nullable, min length 1, e.g. `"Line 1"`) — The machine's name (or external name), matched exactly and case-insensitively.
- `date` (string (date), required, e.g. `"2026-10-12"`) — The date the shift starts on, in the company's timezone (`YYYY-MM-DD`). A night shift that starts at 22:00 on the 12th and ends on the 13th is addressed with the 12th.
- `title` (string, required, min length 1, e.g. `"Morning"`) — The shift's name, matched exactly and case-insensitively.
- `targetQuantity` (integer, required, >= 0, e.g. `1200`) — The production target for the shift, in units.
- `status` ("updated" | "machineNotFound" | "ambiguousMachine" | "shiftNotFound" | "ambiguousShift" | "duplicateShift", required, e.g. `"updated"`) — What happened to this row. Only `updated` rows changed a shift; see the endpoint description for the others.
- `machineId` (integer, optional, nullable, e.g. `12`) — The id of the machine the row resolved to, when it resolved to exactly one.
- `shiftId` (integer, optional, nullable, e.g. `48213`) — The id of the shift the row resolved to, when it resolved to exactly one.

#### 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 PUT 'https://draco.prod.pulsarml.com/v1/shifts/targets' \
  -H 'x-api-key: <YOUR_API_KEY>' \
  -H 'Content-Type: application/json' \
  -d '[
    {
      "machine": {
        "uuid": "0190c1c2-7a3e-7cc1-9b2f-1d2e3f4a5b6c",
        "name": "Line 1"
      },
      "date": "2026-10-12",
      "title": "Morning",
      "targetQuantity": 1200
    }
  ]'
```