# メッセージを更新 (PUT)

既存のメッセージの内容や既読状態を更新します。

## エンドポイント

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

## 認証

> **Info: 必須**
>
> リクエストに次のいずれかのヘッダーを含めてください:
> - `Token: <your-api-key>` — [API キー](https://pocketalert.app/account/apikeys)から取得できます
> - `Authorization: Bearer <jwt-token>` — [ログイン](https://info.pocketalert.app/api/user/login.md)から取得できます

## リクエスト

### パスパラメータ

| パラメータ | 型 | 必須 | 説明 |
|-----------|------|:--------:|-------------|
| `tid` | string | ✅ | メッセージの一意の識別子 |

### ヘッダー

| ヘッダー | 必須 | 説明 |
|--------|:--------:|-------------|
| `Token` | ✅ | API キー |
| `Authorization` | ✅ | `Bearer <jwt-token>` |

### ボディパラメータ

| パラメータ | 型 | 必須 | 説明 |
|-----------|------|:--------:|-------------|
| `title` | string | ✅ | メッセージのタイトル |
| `message` | string | ✅ | メッセージの本文 |
| `application_id` | string | ❌ | アプリケーションの TID |
| `device_id` | string | ❌ | デバイスの TID |
| `is_read` | boolean | ❌ | 既読/未読を設定 |

### リクエスト例

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

## レスポンス

### 成功時のレスポンス

> **Tip: 200 OK**
>
> メッセージの更新に成功しました

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

### エラーレスポンス

| ステータス | 説明 |
|:------:|-------------|
| `401` | 認証エラー — トークンが無効または未指定です |
| `404` | Not Found — メッセージが存在しません |
| `400` | Bad Request — リクエストボディが不正です |
