跳到正文

创建应用 POST ​

创建新应用,用于组织和分类你的消息。

端点 ​

POST https://api.pocketalert.app/v1/applications

身份验证 ​

必填

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

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

请求 ​

请求头 ​

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

请求体参数 ​

参数类型必填说明
namestring✅应用名称
colorstring❌应用颜色(十六进制)

请求示例 ​

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

应用创建成功

字段类型说明
tidstring应用的唯一标识符
namestring应用名称
colorstring应用颜色
is_activeboolean应用是否处于启用状态
created_atstring创建时间戳
json
{
  "tid": "iemkz2tlbakj4lgns961ohx0o",
  "name": "Production Monitoring",
  "color": "#FF0000",
  "is_active": true,
  "created_at": "18.01.2026 15:29:02"
}

错误响应 ​

状态码说明
401未授权 — 令牌无效或缺失
400请求错误 — 请求体无效

Pocket Alert 文档