# Update a downtime reason code (/docs/api-reference/downtime/DowntimeController_updateReason)

`PATCH /api/factories/{factoryId}/downtime/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 slug |
| `id` | path | yes | string | Reason ID |

## Request body

Required.

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "code": {
      "type": "string",
      "example": "MFAIL",
      "description": "Short upper-case code, unique per factory."
    },
    "name": {
      "type": "string",
      "example": "Machine failure"
    },
    "description": {
      "type": "string",
      "example": "Mechanical or electrical breakdown."
    },
    "category": {
      "type": "string",
      "enum": [
        "planned",
        "unplanned"
      ],
      "default": "unplanned"
    },
    "color": {
      "type": "string",
      "example": "#dc2626",
      "description": "Hex colour for charts; falls back to a deterministic palette if omitted."
    },
    "sortOrder": {
      "type": "number",
      "default": 0
    },
    "isActive": {
      "type": "boolean",
      "default": true
    }
  }
}
```

## Responses

### 200