# Update a scrap reason code (edit or deactivate) (/docs/api-reference/quality/QualityController_updateScrapReasonCode)

`PATCH /api/factories/{factoryId}/quality/scrap-reasons/{id}`

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

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

## Parameters

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

## Request body

Required.

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "code": {
      "type": "string",
      "description": "Short reason code.",
      "example": "TOOL_WEAR"
    },
    "description": {
      "type": "string",
      "description": "Human-readable description."
    },
    "category": {
      "type": "string",
      "description": "Category for Pareto reporting.",
      "enum": [
        "material",
        "process",
        "equipment",
        "operator"
      ]
    },
    "isActive": {
      "type": "boolean",
      "description": "Set false to deactivate the code (preserves FK history)."
    },
    "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
    }
  }
}
```

## Responses

### 200