# Create and publish a notification (/docs/api-reference/notifications/NotificationsController_create)

`POST /api/factories/{factoryId}/notifications`

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": {
    "userId": {
      "type": "string",
      "description": "User id of the recipient.",
      "example": "a1b2c3d4-1111-2222-3333-444455556666"
    },
    "type": {
      "type": "string",
      "description": "Notification type — controls icon and routing.",
      "enum": [
        "production_alert",
        "idle_alert",
        "offline_alert",
        "error_alert",
        "completion_alert"
      ],
      "example": "idle_alert"
    },
    "title": {
      "type": "string",
      "description": "Short notification title.",
      "example": "Machine idle for 15 minutes"
    },
    "message": {
      "type": "string",
      "description": "Notification message body.",
      "example": "CNC-001 has been idle since 14:05. Check on the operator."
    },
    "metadata": {
      "type": "object",
      "description": "Additional metadata (orderId, machineId, etc.).",
      "example": {
        "machineId": "CNC-001",
        "orderId": "a1b2c3d4-..."
      }
    }
  },
  "required": [
    "userId",
    "type",
    "title",
    "message"
  ]
}
```

## Responses

### 201: Notification created