> ## Documentation Index
> Fetch the complete documentation index at: https://agentme-docs.vipcrm.net/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Từ API key đến tin nhắn đầu tiên và webhook đầu tiên.

Mục tiêu: dưới 10 phút. Bạn cần một nick đã kết nối (trạng thái `live`) trong dashboard.

**1. Tạo API key**

Trong dashboard, mở mục **API keys**, tạo key và chọn scope cần dùng. Key dạng `agm_live_...` chỉ hiện **một lần**.

```bash theme={null}
export AGENTME_KEY="agm_live_..."
export AGENTME_API="https://agentme.vipcrm.net/api/v1"
```

**2. Liệt kê nick**

```bash theme={null}
curl -s "$AGENTME_API/accounts" -H "Authorization: Bearer $AGENTME_KEY"
```

Lấy `id` (dạng `acc_...`) của nick có `"status": "live"`.

**3. Chọn hội thoại**

```bash theme={null}
curl -s "$AGENTME_API/accounts/acc_.../conversations?unread=true" \
  -H "Authorization: Bearer $AGENTME_KEY"
```

Lấy `id` hội thoại (`cnv_...`).

**4. Gửi tin**

```bash theme={null}
curl -s -X POST "$AGENTME_API/messages" \
  -H "Authorization: Bearer $AGENTME_KEY" -H "Content-Type: application/json" \
  -d '{
    "account_id": "acc_...",
    "to": { "conversation_id": "cnv_..." },
    "kind": "text",
    "text": "Xin chào từ Agentme",
    "client_msg_id": "quickstart-0001"
  }'
```

`200` = đã gửi. `202` = còn đang gửi sau thời gian chờ: **đừng gửi lại**, đọc lại hội thoại để xem trạng thái cuối. Chạy lại đúng lệnh trên chỉ trả tin cũ, không gửi thêm.

**5. Nhận webhook**

Trong dashboard, thêm **Webhook endpoint** trỏ tới URL https của bạn, chọn event `message.received`. Thử nhanh với [receiver mẫu](#receiver-mau) rồi bấm "Gửi thử". Chi tiết ở [Webhooks](https://agentme-docs.vipcrm.net/webhooks.md).

## Receiver mẫu

Kho mã có sẵn `docs-site/examples/webhook-receiver-node` (Node thuần, không phụ thuộc) và workflow n8n mẫu ở `docs-site/examples/n8n`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.