# Manually log a downtime event (optionally pre-categorised). Used to log a current stoppage before the watcher catches it. (/docs/api-reference/downtime/DowntimeController_createEvent)

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

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": {
    "machineId": {
      "type": "string",
      "description": "Machine code (e.g. IDHC-007)"
    },
    "startedAt": {
      "type": "string",
      "description": "When the stoppage started (ISO timestamp).",
      "example": "2026-04-23T01:30:00Z"
    },
    "endedAt": {
      "type": "string",
      "description": "When the stoppage ended. Omit for ongoing."
    },
    "stateCode": {
      "type": "string",
      "description": "State that tripped the event (IDLE / ALARM / OFF / SETUP)."
    },
    "reasonId": {
      "type": "string",
      "description": "Optional reason to assign immediately — one-shot create+categorize."
    },
    "notes": {
      "type": "string"
    }
  },
  "required": [
    "machineId",
    "startedAt"
  ]
}
```

## Responses

### 201