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

# 网络错误

> 获取应用的 5xx（以及可选的 4xx）边缘错误的聚合明细。

返回应用在某一时间窗口内的聚合边缘错误计数，按状态码、时间分桶、请求路径和 HTTP 方法分组。默认仅包含 5xx 响应；传入 `include_4xx=true` 可同时统计 4xx 响应。

<Info>
  缓存未命中速率限制：每个所有者每 60 秒 15 次请求。当没有匹配的错误，或时间窗口早于应用的创建日期时，返回空明细。
</Info>

<ParamField header="Authorization" type="string" placeholder="API Key" required>
  你账户的 API 密钥。你可以在[账户设置](https://squarecloud.app/zh/account/security)中找到它。
</ParamField>

### 参数

<ParamField path="app_id" type="string" placeholder="Application ID" required>
  应用的 ID。你可以在应用仪表盘的 URL 中找到它。
</ParamField>

<ParamField query="start" type="string" placeholder="ISO 8601 timestamp" required>
  分析窗口的 ISO 8601 起始时间戳。
</ParamField>

<ParamField query="end" type="string" placeholder="ISO 8601 timestamp" required>
  ISO 8601 结束时间戳。必须晚于 `start`。
</ParamField>

<ParamField query="include_4xx" type="string" placeholder="false">
  是否在 5xx 错误之外同时包含 4xx 响应。接受 `true` 或 `false`。默认为 `false`。
</ParamField>

### 响应

<ResponseField name="status" type="string">
  指示调用是否成功。成功时为 `success`，否则为 `error`。
</ResponseField>

<ResponseField name="response" type="object">
  该窗口的聚合错误明细。

  <Expandable title="展开响应对象">
    <ResponseField name="summary" type="object">
      该窗口的高层级总计。

      <Expandable title="展开 summary 对象">
        <ResponseField name="total" type="integer">窗口内错误响应的总数。</ResponseField>

        <ResponseField name="by_class" type="object">
          按 HTTP 状态类别拆分的总计。

          <Expandable title="展开 by_class 对象">
            <ResponseField name="4xx" type="integer">4xx 响应总数（仅在 `include_4xx=true` 时填充）。</ResponseField>
            <ResponseField name="5xx" type="integer">5xx 响应总数。</ResponseField>
          </Expandable>
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="by_status" type="array">
      按观测到的每个单独 HTTP 状态码分组的请求数量。

      <Expandable title="展开 by_status 条目">
        <ResponseField name="status" type="integer">HTTP 状态码（例如 `502`、`504`）。</ResponseField>
        <ResponseField name="requests" type="integer">返回此状态码的请求总数。</ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="timeseries" type="array">
      分析窗口内按时间分桶的计数。

      <Expandable title="展开 timeseries 条目">
        <ResponseField name="date" type="string">分桶起始时间戳，ISO 8601 格式。</ResponseField>
        <ResponseField name="buckets" type="object">以 HTTP 状态码为键、该分桶内观测计数为值的对象。</ResponseField>
        <ResponseField name="total" type="integer">该分桶内观测到的错误总数。</ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="top_paths" type="array">
      在该窗口内产生最多错误的路径。

      <Expandable title="展开 top_paths 条目">
        <ResponseField name="path" type="string">请求路径。</ResponseField>
        <ResponseField name="method" type="string">HTTP 方法。</ResponseField>
        <ResponseField name="total" type="integer">此路径/方法的错误总数。</ResponseField>
        <ResponseField name="by_status" type="object">此路径/方法下观测到的各 HTTP 状态码计数。</ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="by_method" type="array">
      按 HTTP 方法分组的聚合错误总数。

      <Expandable title="展开 by_method 条目">
        <ResponseField name="method" type="string">HTTP 方法。</ResponseField>
        <ResponseField name="total" type="integer">此方法的错误总数。</ResponseField>
        <ResponseField name="by_status" type="object">此方法下观测到的各 HTTP 状态码计数。</ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseExample>
  ```json theme={null}
  {
    "status": "success",
    "response": {
      "summary": {
        "total": 42,
        "by_class": {
          "4xx": 0,
          "5xx": 42
        }
      },
      "by_status": [
        { "status": 502, "requests": 30 },
        { "status": 504, "requests": 12 }
      ],
      "timeseries": [
        {
          "date": "2025-12-01T12:00:00.000Z",
          "buckets": { "502": 5, "504": 2 },
          "total": 7
        }
      ],
      "top_paths": [
        {
          "path": "/api/users",
          "method": "GET",
          "total": 18,
          "by_status": { "502": 15, "504": 3 }
        }
      ],
      "by_method": [
        {
          "method": "GET",
          "total": 30,
          "by_status": { "502": 22, "504": 8 }
        }
      ]
    }
  }
  ```
</ResponseExample>
