# Trạng thái hệ thống

## **`GET https://status.caresoft.vn/api/v1/heartbeat`**

Endpoint cung cấp **trạng thái hiện thời** của tất cả dịch vụ CareSoft được giám sát.\
Dữ liệu đã được gộp & rút gọn, sẵn sàng cho hệ thống giám sát của khách hàng.

***

### 1. Yêu cầu (HTTP Request)

<table><thead><tr><th width="231.29296875">Thuộc tính</th><th>Giá trị</th></tr></thead><tbody><tr><td><strong>Phương thức</strong></td><td><code>GET</code></td></tr><tr><td><strong>Đường dẫn</strong></td><td><code>https://status.caresoft.vn/api/v1/heartbeat</code></td></tr><tr><td><strong>Tham số query</strong></td><td><code>pretty</code> (tùy chọn) – trả JSON có thụt dòng (dễ đọc thủ công).</td></tr><tr><td><strong>Header</strong></td><td>Không bắt buộc</td></tr></tbody></table>

**Ví dụ**

<pre><code><strong>GET https://status.caresoft.vn/api/v1/heartbeat
</strong></code></pre>

***

### 2. Phản hồi (HTTP Response)

#### 2.1. Mã trạng thái

| Mã                  | Ý nghĩa                          |
| ------------------- | -------------------------------- |
| **200 OK**          | Thành công & trả về JSON hợp lệ. |
| **502 Bad Gateway** | Dữ liệu tạm thời chưa có.        |

#### 2.2. Headers nổi bật

| Header              | Kiểu                | Mô tả                                         |
| ------------------- | ------------------- | --------------------------------------------- |
| `Content-Type`      | `application/json`  | Luôn là JSON UTF‑8.                           |
| `X-Cache-Generated` | `RFC3339 timestamp` | Thời điểm dữ liệu vừa được hệ thống tổng hợp. |

#### 2.3. Nội dung (JSON)

```jsonc
{
  "generated_at": "2025-07-21 12:15:03",
  "title": "CareSoft",
  "monitors": [
    {
      "id": 1,
      "name": "WEB_APP V2",
      "status": 1,
      "last_ping_ms": 29,
      "last_heartbeat": "2025-07-21 05:06:51.208",
      "uptime_24h": 1.0
    }
    /* …các monitor khác (nếu có) … */
  ]
}
```

| Trường           | Kiểu                         | Giải thích                                           |
| ---------------- | ---------------------------- | ---------------------------------------------------- |
| `generated_at`   | `string`                     | Thời điểm hệ thống tạo bản ghi này.                  |
| `title`          | `string`                     | Tên cụm dịch vụ.                                     |
| `monitors`       | `array<Monitor>`             | Danh sách tất cả dịch  vụ đang public giám sát.      |
| `id`             | `int`                        | Định danh dịch vụ.                                   |
| `name`           | `string`                     | Tên thân thiện của dịch vụ.                          |
| `status`         | `int` (`1` = UP, `0` = DOWN) | Trạng thái mới nhất.                                 |
| `last_ping_ms`   | `int`                        | Thời gian phản hồi (millisecond) của heartbeat cuối. |
| `last_heartbeat` | `string`                     | Thời điểm heartbeat cuối (theo múi giờ server).      |
| `uptime_24h`     | `float` (0 – 1)              | Tỉ lệ uptime 24 giờ qua (1 = 100%).                  |

***

### 3. Ví dụ sử dụng

#### 3.1. cURL

```bash
curl https://status.caresoft.vn/api/v1/heartbeat | jq .
```

#### 3.2. JavaScript

```js
fetch('https://status.caresoft.vn/api/v1/heartbeat')
  .then(r => r.json())
  .then(({ monitors }) => {
    monitors.forEach(m => {
      console.log(`${m.name}: ${m.status ? 'UP ✅' : 'DOWN ❌'} (${m.last_ping_ms}ms)`);
    });
  });
```

***

### 4. Cập nhật API

| Phiên bản         | Thay đổi           |
| ----------------- | ------------------ |
| **1.0** (07‑2025) | Phát hành lần đầu. |

Mọi thay đổi sau này (nếu có) sẽ **luôn** bổ sung trường mới, không xoá trường cũ – bảo toàn tương thích ngược.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/trang-thai-he-thong.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
