# Create an inspection batch (/docs/api-reference/quality/QualityController_createBatch)

`POST /api/factories/{factoryId}/quality/batches`

Base URL: https://api.xentr.ai

Authentication: bearer token (`Authorization: Bearer <token>`).

## Parameters

| Name | In | Required | Type | Description |
| --- | --- | --- | --- | --- |
| `factoryId` | path | yes | string | Factory ID |

## Request body

Required.

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "productionOrderId": {
      "type": "string",
      "description": "Production order being inspected.",
      "example": "a1b2c3d4-1111-2222-3333-444455556666"
    },
    "batchNumber": {
      "type": "string",
      "description": "Batch number. Auto-generated (B-01, B-02 …) if omitted.",
      "example": "B-01"
    },
    "sampledQty": {
      "type": "number",
      "description": "Total quantity inspected in this batch.",
      "example": 50
    },
    "goodQty": {
      "type": "number",
      "description": "Good (pass) quantity.",
      "example": 48
    },
    "rejectedQty": {
      "type": "number",
      "description": "Rejected (fail) quantity.",
      "example": 2
    },
    "executedBy": {
      "type": "string",
      "description": "User id of the person physically inspecting.",
      "example": "a1b2c3d4-1111-2222-3333-444455556666"
    },
    "executedAt": {
      "type": "string",
      "description": "Time the inspection was carried out.",
      "example": "2026-05-13T07:00:00Z"
    },
    "notes": {
      "type": "string",
      "description": "Free-text notes."
    },
    "reasonCodeId": {
      "type": "string",
      "description": "Scrap-reason code id from /quality/scrap-reasons. Required when rejectedQty > 0.",
      "example": "a1b2c3d4-1111-2222-3333-444455556666"
    }
  },
  "required": [
    "productionOrderId",
    "sampledQty",
    "goodQty",
    "rejectedQty"
  ]
}
```

## Responses

### 201: Batch created