# Event erstellen

Ein Ereignis mit Tags, Logs, Actions oder Pipeline anlegen.

`POST /v1/event`

**Authentifizierung:** API-Token des Projekts.

## Body

| Feld | Typ | Erforderlich | Bedeutung |
| --- | --- | --- | --- |
| `project` | string | Ja | Bestehender Projekt-Slug. |
| `channel` | string | Ja | Kanal-Slug; wird bei Bedarf angelegt. |
| `event` | string | Ja | Name des Ereignisses. |
| `description` | string | Nein | Beschreibung. |
| `tags` | object | Nein | Eigene JSON-Eigenschaften. |
| `userId` | string | Nein | Stabile Nutzer-ID für Profilzuordnung. |
| `timestamp` | number | Nein | Unix-Millisekunden; Standard ist die aktuelle Zeit. |
| `logLevel` | string | Nein | `info` (Standard), `warning`, `failed`, `critical`. |
| `notify` | boolean | Nein | Standard false für info/warning, true für failed/critical. |
| `badge` | object | Nein | `title` (max. 80 Zeichen) und `color`. |
| `actions` | array | Nein | Interaktive Komponenten; siehe [Actions](/docs/guides/actions). |
| `logs` | array | Nein | Einträge mit `type`, `message`, optional `details`, `actionId`, `userId`. |
| `steps` | array | Nein | 1–200 eindeutige Pipeline-Steps. |
| `pipeline` | object | Nein | Timeout-Konfiguration; erfordert `steps`. |
| `status` | string | Nein | Wird beim Erstellen vom Server bestimmt. |

Badge-Farben: `primary`, `success`, `danger`, `alert`, `info`, `neutral`.
Log-Typen: `info`, `success`, `warning`, `error`, `manual`.

## Antwort

HTTP `201` mit `{}` für normale Events. Ohne ausführbare Actions ist der Status `completed`, mit Button oder Formular `pending`.

Bei Pipeline-Events enthält die Antwort `id`, den abgeleiteten `status` sowie `pipeline` mit serververwalteten Metadaten. Diese Antwort enthält nicht das gesamte Event. Verwende die `id` für [Step-Updates](/api/update-step).

## Fehler

`400`: Feldtypen oder Pipeline-Graph ungültig, Kanal inaktiv. `401`: API-Token ungültig. `403`: falsches Projekt. `404`: Projekt fehlt.

[Event-Generator](/docs/guides/event-builder) · [Pipeline-Referenz](/docs/concepts/event-pipelines)

## Request

```bash
curl -X POST 'https://api.tracklytic.de/v1/event' \
  -H "Authorization: Bearer $TRACKLYTIC_API_TOKEN" \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "project": "my-project",
  "channel": "deployments",
  "event": "Deployment abgeschlossen",
  "tags": {
    "version": "2.4.0"
  },
  "notify": false
}'
```

```js
const response = await fetch("https://api.tracklytic.de/v1/event", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.TRACKLYTIC_API_TOKEN}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify(
    {
      "project": "my-project",
      "channel": "deployments",
      "event": "Deployment abgeschlossen",
      "tags": {
        "version": "2.4.0"
      },
      "notify": false
    }
  )
});

if (!response.ok) throw new Error(await response.text());
const result = await response.json();
```

```python
import json
import os
from urllib.request import Request, urlopen

payload = {
  "project": "my-project",
  "channel": "deployments",
  "event": "Deployment abgeschlossen",
  "tags": {
    "version": "2.4.0"
  },
  "notify": False
}

request = Request(
    "https://api.tracklytic.de/v1/event",
    method="POST",
    headers={
        "Authorization": "Bearer " + os.environ["TRACKLYTIC_API_TOKEN"],
        "Content-Type": "application/json"
    },
    data=json.dumps(payload).encode("utf-8")
)

with urlopen(request) as response:
    result = json.load(response)
```

## Response (201)

```json
{}
```