# 快速开始

几分钟内即可开始使用 PocketAlert。本指南将带你发送第一条推送通知。

## 前提条件

- 一个 PocketAlert 账户：[注册](https://pocketalert.app/signup) 或 [登录](https://pocketalert.app/signin)
- 在你的设备上安装 PocketAlert 手机应用

---

## 第一步：获取你的 API 密钥

1. 登录 [PocketAlert](https://pocketalert.app/signin)
2. 进入 [API 密钥](https://pocketalert.app/account/apikeys)
3. 点击 **创建新密钥**
4. 复制并妥善保存你的 API 密钥

> **Warning: 重要**
>
> API 密钥仅显示一次，请将其保存在安全的地方。

---

## 第二步：发送你的第一条通知

选择你偏好的方式：

**cURL**

```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**

```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**

```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**

```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**

```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` | 消息发送的时间戳 |

---

## 接下来做什么？

<div class="tip custom-block" style="padding-top: 8px">

**探索更多功能：**

- [创建应用](https://info.pocketalert.app/api/applications/create.md) — 按项目整理消息
- [管理设备](https://info.pocketalert.app/api/devices/get-devices.md) — 发送给指定设备
- [设置 Webhook](https://info.pocketalert.app/api/webhooks/create.md) — 接收来自外部服务的告警
- [使用 CLI](https://info.pocketalert.app/cli.md) — 从终端发送通知

</div>

---

## 需要帮助？

如需进一步协助，或分享你的使用场景：

| 资源 | 链接 |
|----------|------|
| 邮件支持 | [support@pocketalert.app](mailto:support@pocketalert.app) |
| API 参考 | [完整文档](https://info.pocketalert.app/intro.md) |
| CLI 工具 | [下载并安装](https://info.pocketalert.app/cli.md) |
