快速开始
几分钟内即可开始使用 PocketAlert。本指南将带你发送第一条推送通知。
前提条件
第一步:获取你的 API 密钥
- 登录 PocketAlert
- 进入 API 密钥
- 点击 创建新密钥
- 复制并妥善保存你的 API 密钥
重要
API 密钥仅显示一次,请将其保存在安全的地方。
第二步:发送你的第一条通知
选择你偏好的方式:
bash
curl -X POST "https://api.pocketalert.app/v1/messages" \
-H "Token: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"title": "Hello from API",
"message": "This is my first notification!"
}'javascript
const response = await fetch('https://api.pocketalert.app/v1/messages', {
method: 'POST',
headers: {
'Token': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
title: 'Hello from API',
message: 'This is my first notification!'
})
});
const data = await response.json();
console.log('Message sent:', data.tid);python
import requests
response = requests.post(
'https://api.pocketalert.app/v1/messages',
headers={
'Token': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
json={
'title': 'Hello from API',
'message': 'This is my first notification!'
}
)
print('Message sent:', response.json()['tid'])php
$response = Http::withHeaders([
'Token' => 'YOUR_API_KEY',
])->post('https://api.pocketalert.app/v1/messages', [
'title' => 'Hello from API',
'message' => 'This is my first notification!',
]);
echo 'Message sent: ' . $response['tid'];go
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
payload := map[string]string{
"title": "Hello from API",
"message": "This is my first notification!",
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST",
"https://api.pocketalert.app/v1/messages",
bytes.NewBuffer(body))
req.Header.Set("Token", "YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
client.Do(req)
}第三步:检查响应
请求成功后将返回:
json
{
"tid": "cq4k7rml9m2qqmuw44ypoos93",
"title": "Hello from API",
"message": "This is my first notification!",
"application": "",
"device": "",
"created_at": "18.01.2026 15:30:00"
}| 字段 | 说明 |
|---|---|
tid | 消息的唯一标识符 |
title | 你的通知标题 |
message | 你的通知正文 |
created_at | 消息发送的时间戳 |
接下来做什么?
探索更多功能:
- 创建应用 — 按项目整理消息
- 管理设备 — 发送给指定设备
- 设置 Webhook — 接收来自外部服务的告警
- 使用 CLI — 从终端发送通知
需要帮助?
如需进一步协助,或分享你的使用场景:
| 资源 | 链接 |
|---|---|
| 邮件支持 | [email protected] |
| API 参考 | 完整文档 |
| CLI 工具 | 下载并安装 |