# Gerät aktualisieren (PUT)

Aktualisiere den Namen oder die Einstellungen eines Geräts.

## Endpunkt

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

## Authentifizierung

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

## Anfrage

### Pfadparameter

| Parameter | Typ | Pflicht | Beschreibung |
|-----------|-----|:-------:|--------------|
| `tid` | string | ✅ | Eindeutige Kennung des Geräts |

### Header

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

### Body-Parameter

| Parameter | Typ | Pflicht | Beschreibung |
|-----------|-----|:-------:|--------------|
| `name` | string | ✅ | Neuer Gerätename |

### Beispielanfrage

**cURL**

```bash
curl -X PUT "https://api.pocketalert.app/v1/devices/9dc24hqldvv2bfx2nlc6r" \
  -H "Token: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"name": "My iPhone"}'
```

**JavaScript**

```javascript
const tid = '9dc24hqldvv2bfx2nlc6r';
const response = await fetch(`https://api.pocketalert.app/v1/devices/${tid}`, {
  method: 'PUT',
  headers: {
    'Token': 'your-api-key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ name: 'My iPhone' })
});
```

**Python**

```python
import requests

tid = '9dc24hqldvv2bfx2nlc6r'
response = requests.put(
    f'https://api.pocketalert.app/v1/devices/{tid}',
    headers={'Token': 'your-api-key'},
    json={'name': 'My iPhone'}
)
print(response.json())
```

**PHP**

```php
$tid = '9dc24hqldvv2bfx2nlc6r';
$response = Http::withHeaders([
    'Token' => 'your-api-key',
])->put('https://api.pocketalert.app/v1/devices/'.$tid, [
    'name' => 'My iPhone',
]);

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

## Antwort

### Erfolgreiche Antwort

> **Tip: 200 OK**
>
> Gerät erfolgreich aktualisiert

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

### Fehlerantworten

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