# Update Message (PUT)

Perbarui konten atau status baca sebuah pesan.

## Endpoint

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

## Autentikasi

> **Info: Wajib**
>
> Sertakan salah satu header berikut dalam permintaan Anda:
> - `Token: <your-api-key>` — Dapatkan dari [Kunci API](https://pocketalert.app/account/apikeys)
> - `Authorization: Bearer <jwt-token>` — Dari [Masuk](https://info.pocketalert.app/api/user/login.md)

## Permintaan

### Path Parameters

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `tid` | string | ✅ | Pengenal unik pesan |

### Headers

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

### Body Parameters

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `title` | string | ✅ | Judul pesan |
| `message` | string | ✅ | Isi teks pesan |
| `application_id` | string | ❌ | TID aplikasi |
| `device_id` | string | ❌ | TID perangkat |
| `is_read` | boolean | ❌ | Tandai sudah/belum dibaca |

### Contoh Permintaan

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

## Respons

### Respons Sukses

> **Tip: 200 OK**
>
> Pesan berhasil diperbarui

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

### Respons Error

| Status | Description |
|:------:|-------------|
| `401` | Unauthorized — Token tidak valid atau tidak ada |
| `404` | Not Found — Pesan tidak ditemukan |
| `400` | Bad Request — isi permintaan tidak valid |
