# Create a downtime reason code (/docs/api-reference/downtime/DowntimeController_createReason)

`POST /api/factories/{factoryId}/downtime/reasons`

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

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

## Parameters

| Name | In | Required | Type | Description |
| --- | --- | --- | --- | --- |
| `factoryId` | path | yes | string | Factory slug |

## 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
    }
  },
  "required": [
    "code",
    "name"
  ]
}
```

## Responses

### 201