# Anwendung erstellen (POST)

Erstelle eine neue Anwendung, um deine Nachrichten zu organisieren und zu kategorisieren.

## Endpunkt

```
POST https://api.pocketalert.app/v1/applications
```

## Authentifizierung

> **Info: Erforderlich**
>
> Füge einen dieser Header in deine Anfrage ein:
> - `Token: <your-api-key>` — Hol ihn dir unter [API Keys](https://pocketalert.app/account/apikeys)
> - `Authorization: Bearer <jwt-token>` — Aus [Login](https://info.pocketalert.app/api/user/login.md)

## Anfrage

### Header

| Header | Erforderlich | Beschreibung |
|--------|:--------:|-------------|
| `Content-Type` | ✅ | `application/json` |
| `Token` | ✅ | Dein API-Schlüssel |
| `Authorization` | ✅ | `Bearer <jwt-token>` |

### Body-Parameter

| Parameter | Typ | Erforderlich | Beschreibung |
|-----------|------|:--------:|-------------|
| `name` | string | ✅ | Name der Anwendung |
| `color` | string | ❌ | Farbe der Anwendung (Hex) |

### Beispielanfrage

**cURL**

```bash
curl -X POST "https://api.pocketalert.app/v1/applications" \
  -H "Token: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Production Monitoring",
    "color": "#FF0000"
  }'
```

**JavaScript**

```javascript
const response = await fetch('https://api.pocketalert.app/v1/applications', {
  method: 'POST',
  headers: {
    'Token': 'your-api-key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'Production Monitoring',
    color: '#FF0000'
  })
});

const application = await response.json();
console.log(application);
```

**Python**

```python
import requests

response = requests.post(
    'https://api.pocketalert.app/v1/applications',
    headers={
        'Token': 'your-api-key',
        'Content-Type': 'application/json'
    },
    json={'name': 'Production Monitoring', 'color': '#FF0000'}
)

print(response.json())
```

**PHP**

```php
$response = Http::withHeaders([
    'Token' => 'your-api-key',
])->post('https://api.pocketalert.app/v1/applications', [
    'name' => 'Production Monitoring',
    'color' => '#FF0000',
]);

return $response->json();
```

## Antwort

### Erfolgreiche Antwort

> **Tip: 201 Created**
>
> Anwendung erfolgreich erstellt

| Feld | Typ | Beschreibung |
|-------|------|-------------|
| `tid` | string | Eindeutige Kennung der Anwendung |
| `name` | string | Name der Anwendung |
| `color` | string | Farbe der Anwendung |
| `is_active` | boolean | Ob die Anwendung aktiv ist |
| `created_at` | string | Zeitstempel der Erstellung |

```json
{
  "tid": "iemkz2tlbakj4lgns961ohx0o",
  "name": "Production Monitoring",
  "color": "#FF0000",
  "is_active": true,
  "created_at": "18.01.2026 15:29:02"
}
```

### Fehlerantworten

| Status | Beschreibung |
|:------:|-------------|
| `401` | Nicht autorisiert — Token ungültig oder fehlt |
| `400` | Ungültige Anfrage — ungültiger Request-Body |
