# Create a defect category (/docs/api-reference/quality/QualityController_createDefectCategory)

`POST /api/factories/{factoryId}/quality/defect-categories`

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": {
    "code": {
      "type": "string",
      "description": "Stable category code stored on defect codes.",
      "example": "material"
    },
    "name": {
      "type": "string",
      "description": "Display name.",
      "example": "Material"
    },
    "color": {
      "type": "string",
      "description": "Hex colour for chips / charts.",
      "example": "#3b82f6"
    },
    "sortOrder": {
      "type": "number",
      "description": "Sort order (lower first).",
      "example": 10
    },
    "isActive": {
      "type": "boolean",
      "default": true
    }
  },
  "required": [
    "code",
    "name"
  ]
}
```

## Responses

### 201: Defect category created