# 获取消息 (GET)

通过唯一标识符获取指定消息的详细信息。

## 端点

```
GET 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>` |

### 请求示例

**cURL**

```bash
curl -X GET "https://api.pocketalert.app/v1/messages/jb4xw9elz24c5" \
  -H "Token: your-api-key"
```

**JavaScript**

```javascript
const tid = 'jb4xw9elz24c5';
const response = await fetch(`https://api.pocketalert.app/v1/messages/${tid}`, {
  headers: { 'Token': 'your-api-key' }
});
const message = await response.json();
```

**Python**

```python
import requests

tid = 'jb4xw9elz24c5'
response = requests.get(
    f'https://api.pocketalert.app/v1/messages/{tid}',
    headers={'Token': 'your-api-key'}
)
print(response.json())
```

**PHP**

```php
$tid = 'jb4xw9elz24c5';
$response = Http::withHeaders([
    'Token' => 'your-api-key',
])->get('https://api.pocketalert.app/v1/messages/'.$tid);

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

## 响应

### 成功响应

> **Tip: 200 OK**
>
> 返回消息对象

| 字段 | 类型 | 描述 |
|-------|------|-------------|
| `tid` | string | 消息唯一标识符 |
| `title` | string | 消息标题 |
| `message` | string | 消息正文 |
| `application` | string | 应用名称 |
| `device` | string | 目标设备 |
| `is_read` | boolean | 消息是否已读 |
| `created_at` | string | 创建时间戳 |

```json
{
  "tid": "jb4xw9elz24c5",
  "title": "Server Alert",
  "message": "CPU usage exceeded 90%",
  "application": "Monitoring",
  "device": "iPhone",
  "is_read": true,
  "created_at": "18.09.2023 17:35:35"
}
```

### 错误响应

| 状态码 | 描述 |
|:------:|-------------|
| `401` | 未授权 — 令牌无效或缺失 |
| `404` | 未找到 — 消息不存在 |
