跳到正文

更新消息 PUT ​

更新已有消息的内容或已读状态。

接口地址 ​

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

身份验证 ​

必填

请求中须包含以下请求头之一:

  • Token: <your-api-key> — 在 API 密钥 页面获取
  • Authorization: Bearer <jwt-token> — 来自 登录 接口

请求 ​

路径参数 ​

参数类型必填说明
tidstring✅消息的唯一标识符

请求头 ​

请求头必填说明
Token✅你的 API 密钥
Authorization✅Bearer <jwt-token>

请求体参数 ​

参数类型必填说明
titlestring✅消息标题
messagestring✅消息正文
application_idstring❌应用的 TID
device_idstring❌设备的 TID
is_readboolean❌标记为已读或未读

请求示例 ​

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错误请求 — 请求体无效

Pocket Alert 文档