> ## 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.

# 列出应用的出站连接

> 通过 GET /v2/apps/:app_id/network/outbound 查看应用在过去 15 分钟内连接了谁，按主机名列出：平台、连接数、请求频率和发送字节数。

返回应用自身在过去 15 分钟内连接了谁，每个主机名一行，即 Square Shield 所看到的情况。它与[网络日志](https://docs.squarecloud.app/zh/api-reference/endpoint/apps/network/logs.md)方向相反，后者显示经由边缘到达网站的请求；它适用于任何应用（包括机器人）和任何套餐。

> [!NOTE]
>
> 每个应用每分钟最多调用 10 次，超出后会被封锁 60 秒。

**Authorization** `string` *required*

你账户的 API 密钥。你可以在[账户设置](https://squarecloud.app/zh/account/security)中找到它。

需要具有 `apps:read` [权限范围](https://docs.squarecloud.app/zh/api-reference/authentication.md#权限范围)的 API 密钥。在 workspace 共享的应用上，调用者需要具备 `manager` 或 `admin` [角色](https://docs.squarecloud.app/zh/api-reference/endpoint/workspace/members/invite.md#角色)。

可以用它查看机器人在和谁通信，或找出导致 Square Shield 因请求发出[警告或停止](https://docs.squarecloud.app/zh/platform/limitations-and-restrictions.md#超出限制的状态)的代码。最多列出 64 个主机名，其余的计入 `other`。只有 Square Shield 监控的外部 API（例如 Discord）才有请求频率和发送字节数，其他情况为 `null`。已停止的应用返回空的 `hosts`。

## 参数

**app\_id** `string` *required*

应用的 ID。你可以在应用仪表盘的 URL 中找到它。

## 响应

**status** `string`

指示调用是否成功。成功时为 `success`，否则为 `error`。

**response** `object`

响应的内容。

**属性**

**window** `object`

覆盖的 15 分钟，以 `from` 和 `to`（ISO 8601）表示。两者都可能为 `null`。

**hosts** `object[]`

每个主机名一行，最多 64 行。

**属性**

**host** `string`

主机名；当 `source` 为 `ip` 时为 IP 地址本身。

**platform** `string | null`

Square Shield 识别出的平台，例如 `discord`。

**source** `string | null`

名称的来源：`sni`、`quic` 或 `ech`（应用建立连接时发送的 hello）、`dns`（应用进行的一次解析），或 `ip`（两者都没有，因此 `host` 就是地址）。

**protocol** `string | null`

`tcp` 或 `quic`。

**connections** `integer`

时间窗口内的新连接数。

**requests\_per\_second** `number | null`

估算的每秒请求数。仅限 Square Shield 监控的 API。

**bytes\_out** `integer | null`

发送的字节数。仅限 Square Shield 监控的 API。

**first\_seen** `string | null`

时间窗口内的第一次连接（ISO 8601）。

**last\_seen** `string | null`

时间窗口内的最后一次连接（ISO 8601）。

**destinations** `string[]`

最多 3 个目标地址，格式为 `ip:port`。在 `squareweb.app` 或 `squarecloud.app` 主机名背后的 IPv4 地址只显示第一个和最后一个八位组（`104.XXX.XXX.191:443`）。

**approx** `boolean`

计数为近似值时为 `true`。

**other** `object`

未能放入 `hosts` 的部分：其他主机名的数量（`hosts`）及其新连接数（`connections`）。

**connections\_per\_minute** `object[]`

时间窗口内每分钟的新连接数，以 `at`（ISO 8601）和 `count` 表示。

```json theme={"system"}
{
  "status": "success",
  "response": {
    "window": { "from": "2026-11-25T14:05:00.000Z", "to": "2026-11-25T14:20:00.000Z" },
    "hosts": [
      {
        "host": "discord.com",
        "platform": "discord",
        "source": "sni",
        "protocol": "tcp",
        "connections": 42,
        "requests_per_second": 11.8,
        "bytes_out": 1843200,
        "first_seen": "2026-11-25T14:05:02.000Z",
        "last_seen": "2026-11-25T14:19:58.000Z",
        "destinations": ["162.159.135.232:443"],
        "approx": false
      }
    ],
    "other": { "hosts": 12, "connections": 31 },
    "connections_per_minute": [
      { "at": "2026-11-25T14:05:00.000Z", "count": 3 },
      { "at": "2026-11-25T14:06:00.000Z", "count": 5 }
    ]
  }
}
```

## 常见错误

| 代码 | HTTP | 说明 |
| - | - | - |
| `PERMISSION_DENIED` | 403 | 在 workspace 共享的应用上，你的角色既不是 `manager` 也不是 `admin`。 |
| `APP_NOT_FOUND` | 404 | 应用不存在，或你无权访问它。 |
| `OUTBOUND_UNAVAILABLE` | 409 | Square Shield 目前没有在应用所在的服务器上记录出站连接。请稍后再试。 |
| `KEEP_CALM` | 429 | 一分钟内对此应用的调用超过 10 次。请等待一分钟后重试。 |
| `OUTBOUND_FAILED` | 500 | 无法读取连接。请稍后重试。 |

## 相关内容

* [网络日志](https://docs.squarecloud.app/zh/api-reference/endpoint/apps/network/logs.md)：经由边缘到达网站的请求。
* [超出限制的状态](https://docs.squarecloud.app/zh/platform/limitations-and-restrictions.md#超出限制的状态)：Square Shield 会停止或限制什么，以及如何修复。
* MCP：[`get_outbound_connections`](https://docs.squarecloud.app/zh/mcp/tools)


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