# Create Production Logs (https://docs.pulsarml.com/v1/api-reference/production-logs/post-production-logs)

Create one or many Production Logs. The body is a JSON **array**, even for a single record.

This is the endpoint an MES, ERP or shop-floor terminal uses to push production into
Pulsar. `machine` and `sku` are references that accept either an `id` or a `name`, so a
system that only knows line names and product codes does not have to resolve Pulsar ids
first.

A Production Log describes a closed interval: `start` and `end` are both required. To
record what is happening in the shift a machine is running right now, use the realtime
endpoints instead.

## `POST /v1/production-logs`

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

- `type` ("correct" | "defects" | "total", optional, default `"total"`, e.g. `"correct"`) — The type of the production log (correct, defects, etc.)
- `count` (integer, required, e.g. `1000`) — The total count of items produced during this production log
- `nominalSpeed` (number, required, e.g. `60`) — The nominal speed of the machine during this production log (using float for speed)
- `start` (string (date-time), required, e.g. `"2024-01-01T08:00:00"`) — The start time of the production log
- `end` (string (date-time), required, e.g. `"2024-01-01T16:00:00"`) — The end time of the production log
- `machine` (object, required) — The machine associated with the production log
  - `id` (integer, optional, nullable, > 0, e.g. `1`) — The id of the machine
  - `name` (string, optional, nullable, e.g. `"Machine 1"`) — The name of the machine
- `sku` (object, required) — The SKU associated with the production log
  - `id` (string, optional, nullable, e.g. `"9ce2c6b4-a1f4-4bf2-b5c8-10436d1018cc"`) — The id of the sku
  - `name` (string, optional, nullable, e.g. `"sku 1"`) — The name of the sku
- `operator` (object, optional, nullable) — The operator involved in this production log
  - `firstName` (string, required, e.g. `"Pérez"`) — The operator's first name
  - `lastName` (string, required, e.g. `"Sánchez"`) — The operator's last name
- `workOrder` (string, optional, nullable, e.g. `"work order 1"`) — The name of the work order associated with this production log

### Responses

#### 200 — The Production Logs that were created

Type: array of object

- `id` (string, required, e.g. `"36f7b519-d93e-4ec8-8245-7f4b8c123456"`) — The unique identifier for the production log
- `type` ("correct" | "defects" | "total", required, e.g. `"correct"`) — The type of production log
- `sensorCount` (number, required, e.g. `500`) — The sensor count recorded for this log
- `count` (number, required, e.g. `1000`) — The total count of items produced during this log
- `nominalSpeed` (number, required, e.g. `60`) — The nominal speed of the machine during this log
- `countingFactor` (number, optional, nullable, e.g. `1`) — The counting factor of the machine during this log
- `start` (string (date-time), required, e.g. `"2024-01-01T00:00:00"`) — The start time of the production log
- `end` (string (date-time), required, e.g. `"2024-01-01T08:00:00"`) — The end time of the production log
- `isReviewed` (boolean, required, e.g. `true`) — Indicates if the production log has been reviewed
- `isAutomated` (boolean, required, e.g. `true`) — Indicates if the production log was automated
- `machineId` (integer, required, e.g. `12`) — The ID of the machine involved in the production log
- `createdAt` (string (date-time), required) — The timestamp when the production log was created
- `updatedAt` (string (date-time), required) — The timestamp when the production log was last updated
- `deletedAt` (string (date-time), optional, nullable) — The timestamp when the production log was deleted, if applicable
- `live` (boolean, required, e.g. `true`) — Indicates if the production log is live
- `machine` (object, required) — The machine involved in the production log
  - `id` (integer, required) — The ID of the machine
  - `name` (string, required) — The name of the machine
  - `isCountEnabled` (boolean, required) — Indicates if counting is enabled
  - `externalName` (string, optional, nullable) — The external name of the machine
- `company` (object, required) — The company involved in the production log
  - `id` (integer, required) — The ID of the company
  - `name` (string, required) — The name of the company
  - `timezone` (string, required) — The company's timezone string (e.g., "America/New_York")
- `shift` (object, required) — The shift during which the production log was recorded
  - `id` (integer, required) — The ID of the shift
  - `name` (string, required) — The name of the shift
  - `start` (string (date-time), required) — The start time of the shift
  - `end` (string (date-time), required) — The end time of the shift
  - `isConsidered` (boolean, required) — Indicates if the shift is considered for metrics
- `operator` (object, optional) — The user who reviewed the production log
  - `id` (integer, required) — The ID of the user/operator
  - `firstName` (string, optional, nullable) — The operator's first name
  - `lastName` (string, optional, nullable) — The operator's last name
  - `email` (string, optional, nullable) — The operator's email
- `sku` (object, required) — The SKU produced during the production log
  - `id` (string, required) — The UUID of the SKU
  - `name` (string, required) — The name of the SKU
  - `description` (string, optional, nullable) — The description of the SKU
  - `unit` (string, required) — The unit of measure for the SKU
- `workOrder` (object | object (any keys), required) — The work order associated with the production log
  - when it is `WorkOrderDetailsDtoV1`:
    - `id` (string, required) — The UUID of the work order
    - `name` (string, required) — The name of the work order
    - `description` (string, required) — The description of the work order
    - `status` ("InProgress" | "Completed" | "Canceled", required) — The status of the work order
- `simpleWorkOrder` (object | object (any keys), required) — The simple work order associated with the production log
  - when it is `SimpleWorkOrderDetailsDtoV1`:
    - `id` (string, required) — The UUID of the simple work order
    - `name` (string, required) — The name of the simple work order

#### 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/production-logs' \
  -H 'x-api-key: <YOUR_API_KEY>' \
  -H 'Content-Type: application/json' \
  -d '[
    {
      "type": "correct",
      "count": 1000,
      "nominalSpeed": 60,
      "start": "2024-01-01T08:00:00",
      "end": "2024-01-01T16:00:00",
      "machine": {
        "id": 1,
        "name": "Machine 1"
      },
      "sku": {
        "id": "9ce2c6b4-a1f4-4bf2-b5c8-10436d1018cc",
        "name": "sku 1"
      },
      "workOrder": "work order 1"
    }
  ]'
```