创建应用 POST
创建新应用,用于组织和分类你的消息。
端点
POST https://api.pocketalert.app/v1/applications身份验证
请求
请求头
| 请求头 | 必填 | 说明 |
|---|---|---|
Content-Type | ✅ | application/json |
Token | ✅ | 你的 API 密钥 |
Authorization | ✅ | Bearer <jwt-token> |
请求体参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
name | string | ✅ | 应用名称 |
color | string | ❌ | 应用颜色(十六进制) |
请求示例
bash
curl -X POST "https://api.pocketalert.app/v1/applications" \
-H "Token: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"name": "Production Monitoring",
"color": "#FF0000"
}'javascript
const response = await fetch('https://api.pocketalert.app/v1/applications', {
method: 'POST',
headers: {
'Token': 'your-api-key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Production Monitoring',
color: '#FF0000'
})
});
const application = await response.json();
console.log(application);python
import requests
response = requests.post(
'https://api.pocketalert.app/v1/applications',
headers={
'Token': 'your-api-key',
'Content-Type': 'application/json'
},
json={'name': 'Production Monitoring', 'color': '#FF0000'}
)
print(response.json())php
$response = Http::withHeaders([
'Token' => 'your-api-key',
])->post('https://api.pocketalert.app/v1/applications', [
'name' => 'Production Monitoring',
'color' => '#FF0000',
]);
return $response->json();响应
成功响应
201 Created
应用创建成功
| 字段 | 类型 | 说明 |
|---|---|---|
tid | string | 应用的唯一标识符 |
name | string | 应用名称 |
color | string | 应用颜色 |
is_active | boolean | 应用是否处于启用状态 |
created_at | string | 创建时间戳 |
json
{
"tid": "iemkz2tlbakj4lgns961ohx0o",
"name": "Production Monitoring",
"color": "#FF0000",
"is_active": true,
"created_at": "18.01.2026 15:29:02"
}错误响应
| 状态码 | 说明 |
|---|---|
401 | 未授权 — 令牌无效或缺失 |
400 | 请求错误 — 请求体无效 |