# Nachricht aktualisieren (PUT)

Aktualisiere den Inhalt oder den Lesestatus einer bestehenden Nachricht.

## Endpunkt

```
PUT https://api.pocketalert.app/v1/messages/{tid}
```

## Authentifizierung

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

## Anfrage

### Pfadparameter

| Parameter | Typ | Pflicht | Beschreibung |
|-----------|-----|:-------:|--------------|
| `tid` | string | ✅ | Eindeutige ID der Nachricht |

### Header

| Header | Pflicht | Beschreibung |
|--------|:-------:|--------------|
| `Token` | ✅ | Dein API-Schlüssel |
| `Authorization` | ✅ | `Bearer <jwt-token>` |

### Body-Parameter

| Parameter | Typ | Pflicht | Beschreibung |
|-----------|-----|:-------:|--------------|
| `title` | string | ✅ | Titel der Nachricht |
| `message` | string | ✅ | Text der Nachricht |
| `application_id` | string | ❌ | TID der Anwendung |
| `device_id` | string | ❌ | TID des Geräts |
| `is_read` | boolean | ❌ | Als gelesen/ungelesen markieren |

### Beispielanfrage

**cURL**

```bash
curl -X PUT "https://api.pocketalert.app/v1/messages/jb4xw9elz24c5" \
  -H "Token: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Updated Title",
    "message": "Updated message content",
    "is_read": true
  }'
```

**JavaScript**

```javascript
const tid = 'jb4xw9elz24c5';
const response = await fetch(`https://api.pocketalert.app/v1/messages/${tid}`, {
  method: 'PUT',
  headers: {
    'Token': 'your-api-key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    title: 'Updated Title',
    message: 'Updated message content',
    is_read: true
  })
});
```

**Python**

```python
import requests

tid = 'jb4xw9elz24c5'
response = requests.put(
    f'https://api.pocketalert.app/v1/messages/{tid}',
    headers={'Token': 'your-api-key'},
    json={
        'title': 'Updated Title',
        'message': 'Updated message content',
        'is_read': True
    }
)
print(response.json())
```

**PHP**

```php
$tid = 'jb4xw9elz24c5';
$response = Http::withHeaders([
    'Token' => 'your-api-key',
])->put('https://api.pocketalert.app/v1/messages/'.$tid, [
    'title' => 'Updated Title',
    'message' => 'Updated message content',
    'is_read' => true,
]);

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

## Antwort

### Erfolgreiche Antwort

> **Tip: 200 OK**
>
> Nachricht erfolgreich aktualisiert

```json
{
  "data": "success"
}
```

### Fehlerantworten

| Status | Beschreibung |
|:------:|--------------|
| `401` | Nicht autorisiert — Token ungültig oder fehlt |
| `404` | Nicht gefunden — Nachricht existiert nicht |
| `400` | Ungültige Anfrage — fehlerhafter Request-Body |
