更新消息 PUT
更新已有消息的内容或已读状态。
接口地址
PUT https://api.pocketalert.app/v1/messages/{tid}身份验证
请求
路径参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
tid | string | ✅ | 消息的唯一标识符 |
请求头
| 请求头 | 必填 | 说明 |
|---|---|---|
Token | ✅ | 你的 API 密钥 |
Authorization | ✅ | Bearer <jwt-token> |
请求体参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
title | string | ✅ | 消息标题 |
message | string | ✅ | 消息正文 |
application_id | string | ❌ | 应用的 TID |
device_id | string | ❌ | 设备的 TID |
is_read | boolean | ❌ | 标记为已读或未读 |
请求示例
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
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
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
$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();响应
成功响应
200 OK
消息更新成功
json
{
"data": "success"
}错误响应
| 状态码 | 说明 |
|---|---|
401 | 未授权 — 令牌无效或缺失 |
404 | 未找到 — 消息不存在 |
400 | 错误请求 — 请求体无效 |