# List a shift's defects (https://docs.pulsarml.com/v1/api-reference/shifts/get-shifts-shift_id-defects)

**Required scope:** `shifts.read`.

Return the defects production logs of a shift (its id as returned by `GET /v1/shifts`), oldest
first, in the same shape the defects `POST` routes return. It lists every `defects` log on the
shift's machine that lies within the shift, including ones created through
`POST /v1/production-logs` for part of the shift, so the shift's defects are the sum of the
`quantity` values.

Use it to check what a shift already has before adding more, for example before resending a
request whose outcome you do not know without its `Idempotency-Key`. The whole list is returned,
not paginated.

Errors:

* `404` `shift_not_found`: the shift is not one of yours.

## `GET /v1/shifts/{shift_id}/defects`

Base URLs:
- `https://draco.prod.pulsarml.com` — Production
- `https://draco.stage.pulsarml.com` — Sandbox (staging)

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

### Path parameters

- `shift_id` (integer, required) — The shift ID.

### Responses

#### 200 — The shift's defects production logs, oldest first

Type: array of object

- `id` (string, required, e.g. `"5b0f6a52-3c1e-4d5b-9f0e-8a7c6d5e4f3a"`) — The id of the defects production log. Pass it to `DELETE /v1/production-logs/{id}` to undo the call that created it.
- `shiftId` (integer, required, e.g. `48213`) — The shift the defects belong to.
- `machineId` (integer, required, e.g. `12`) — The machine the shift belongs to.
- `quantity` (integer, required, e.g. `3`) — How many defective units the log holds.
- `start` (string (date-time), required, e.g. `"2026-10-12T06:00:00Z"`) — When the log starts. Defects added through `/v1/shifts` cover the whole shift, so this is the shift's start.
- `end` (string (date-time), required, e.g. `"2026-10-12T14:00:00Z"`) — When the log ends; the shift's end for defects added through `/v1/shifts`.
- `sku` (object, required) — The SKU the defects are of, as resolved from the request's `id` or `name`. These endpoints never create a SKU.
  - `id` (string, required, e.g. `"9ce2c6b4-a1f4-4bf2-b5c8-10436d1018cc"`) — The SKU's `id`, as `/v1/skus` returns it.
  - `name` (string, required, e.g. `"SKU-1042"`) — The SKU's name.

#### 401 — * `unauthenticated`: The credentials are missing, invalid or expired.

#### 403 — * `missing_scope`: The credentials are valid but lack the scope this endpoint requires.

#### 404 — * `shift_not_found`: No shift of yours matches the request.

Type: object (`ErrorResponse`)

- `code` (string, required, e.g. `"shift_not_found"`) — Stable identifier of the error, such as `shift_not_found`; each endpoint lists its codes. Branch on it; new codes may be added over time, so treat an unknown one by its HTTP status.
- `detail` (string, required) — Human-readable explanation. It may change; do not parse it.

#### 422 — Validation Error

Type: object (`HTTPValidationError`)

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

#### 429 — * `rate_limited`: The API key exceeded its rate limit. Retry after `Retry-After` seconds.

### Example request

```bash
curl -X GET 'https://draco.prod.pulsarml.com/v1/shifts/<shift_id>/defects' \
  -H 'x-api-key: <YOUR_API_KEY>'
```