# Create a scrap reason code (/docs/api-reference/quality/QualityController_createScrapReasonCode)

`POST /api/factories/{factoryId}/quality/scrap-reasons`

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": "Short reason code used on scrap tickets.",
      "example": "TOOL_WEAR"
    },
    "description": {
      "type": "string",
      "description": "Human-readable description.",
      "example": "Tool wear beyond allowable limit"
    },
    "category": {
      "type": "string",
      "description": "Category for Pareto reporting.",
      "enum": [
        "material",
        "process",
        "equipment",
        "operator"
      ],
      "example": "equipment"
    },
    "isActive": {
      "type": "boolean",
      "description": "Whether the code is active.",
      "default": true,
      "example": true
    },
    "color": {
      "type": "string",
      "description": "Chip colour (hex). Null inherits the category colour.",
      "example": "#10b981"
    },
    "sortOrder": {
      "type": "number",
      "description": "Manual sort order (lower first).",
      "example": 10
    }
  },
  "required": [
    "code",
    "description"
  ]
}
```

## Responses

### 201: Reason code created