# Update Device (PUT)

Update a device's name or settings.

## Endpoint

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

## Authentication

> **Info: Required**
>
> Include one of these headers in your request:
> - `Token: <your-api-key>` — Get it from [API Keys](https://pocketalert.app/account/apikeys)
> - `Authorization: Bearer <jwt-token>` — From [Login](https://info.pocketalert.app/api/user/login.md)

## Request

### Path Parameters

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `tid` | string | ✅ | Device unique identifier |

### Headers

| Header | Required | Description |
|--------|:--------:|-------------|
| `Token` | ✅ | Your API key |
| `Authorization` | ✅ | `Bearer <jwt-token>` |

### Body Parameters

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `name` | string | ✅ | New device name |

### Example Request

**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();
```

## Response

### Success Response

> **Tip: 200 OK**
>
> Device updated successfully

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

### Error Responses

| Status | Description |
|:------:|-------------|
| `401` | Unauthorized — Invalid or missing token |
| `404` | Not Found — Device does not exist |
| `422` | Validation Error — Invalid parameters |
