# Create an inspection plan (/docs/api-reference/quality/QualityController_createPlan)

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

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": {
    "productId": {
      "type": "string",
      "description": "Product the inspection plan applies to.",
      "example": "a1b2c3d4-1111-2222-3333-444455556666"
    },
    "name": {
      "type": "string",
      "description": "Display name of the plan.",
      "example": "First-article dimensional check"
    },
    "inspectionType": {
      "type": "string",
      "description": "When this plan runs during the production lifecycle.",
      "enum": [
        "first_article",
        "in_process",
        "final",
        "incoming"
      ],
      "example": "first_article"
    },
    "characteristics": {
      "description": "Measurement characteristics to check. Each item defines a feature, target, and tolerance.",
      "example": [
        {
          "name": "OD",
          "target": 10,
          "tolerance": 0.05,
          "unit": "mm"
        },
        {
          "name": "Length",
          "target": 25,
          "tolerance": 0.1,
          "unit": "mm"
        }
      ],
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "sampleSize": {
      "type": "number",
      "description": "Sample size per inspection.",
      "default": 5,
      "example": 5
    },
    "frequency": {
      "type": "string",
      "description": "How often the plan is triggered.",
      "enum": [
        "every_part",
        "hourly",
        "per_batch",
        "per_shift"
      ],
      "example": "per_batch"
    },
    "isActive": {
      "type": "boolean",
      "description": "Whether the plan is active.",
      "default": true,
      "example": true
    }
  },
  "required": [
    "productId",
    "name",
    "inspectionType",
    "characteristics"
  ]
}
```

## Responses

### 201: Plan created