# 查询推送安装（设备）状态

Operation / SDK: `readPushInstallation` · `push.read`

使用设备证明读取当前安装状态。

更新于 2026-11-06

[网页版本](https://www.longplayai.com/zh-hans/docs/api/read-push-installation)

<a id="request"></a>

## 请求

> 这里的公钥、签名和 Token 仅展示格式。实际请求由同一个 SDK 客户端使用本机安装密钥、当前凭据和新时间戳生成，不能重放这个固定示例。

- **凭据**: Customer Token，权限 `messaging:write`。以 Token 对应的 Customer 身份执行。
- **SDK**: JavaScript `createLongplay().push.read`
- **成功状态**: HTTP 200

响应为示例数据。

**cURL: request.sh**

```bash
curl -X POST "$LONGPLAY_API_URL/api/v1/push/installations/read" \
  -H "Authorization: Bearer $LONGPLAY_CUSTOMER_TOKEN" \
  -H "X-Indiana-Protocol: 0.10" \
  -H "Content-Type: application/json" \
  -d '{
  "installationId": "2d64c9df-c94e-4bb2-860b-d786633e5425",
  "publicKey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "issuedAt": "2026-10-03T12:00:00.000Z",
  "signature": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "credentialDigest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}'
```

**请求体: request.json**

```json
{
  "installationId": "2d64c9df-c94e-4bb2-860b-d786633e5425",
  "publicKey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "issuedAt": "2026-10-03T12:00:00.000Z",
  "signature": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "credentialDigest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
```

**响应示例: response.json**

```json
{
  "requestId": "44f5fcb8-6ed8-41b8-818f-7571941c5fd5",
  "scope": {
    "projectId": "df5426d6-b335-403c-8f3e-b0f73d2e3511",
    "environment": "sandbox"
  },
  "installation": {
    "installationId": "2d64c9df-c94e-4bb2-860b-d786633e5425",
    "bound": true,
    "identitySeq": 1,
    "bindingGeneration": 1,
    "addressSeq": 0,
    "addressRevision": 0,
    "connectionId": "b9a0724b-f7c5-4e06-8ccd-aece9059cc39",
    "addressStatus": "active",
    "permission": "unknown"
  }
}
```

<a id="parameters"></a>

## 请求体参数

**application/json**

- `installationId` (uuid, required): 此设备安装实例的 UUID，不是 Customer UUID。
- `publicKey` (string, required): 设备安装用于验证请求签名的公钥。 pattern: ^[A-Za-z0-9_-]{80,200}$
- `issuedAt` (date-time, required): 时间（ISO 8601）。
- `signature` (string, required): 签名。 pattern: ^[A-Za-z0-9_-]{86}$
- `credentialDigest` (string, required): 安装凭据的 SHA-256 摘要，不能代替设备证明。 pattern: ^[a-f0-9]{64}$

<a id="response"></a>

## 响应字段

成功响应都包含 `requestId`（本次请求 ID，排查时提供）和 `scope`（App 与环境）。

**HTTP 200 · application/json**

- `requestId` (uuid, required): 服务端为这次 HTTP 请求生成的 UUID，排查时提供；它不是你的业务 requestId。
- `scope` (object, required): 响应实际所属的 App 和环境。Header 只能核对，不能切换 Key 范围。
- `scope.projectId` (string, required): 凭据绑定的 App ID。 minLength: 1
- `scope.environment` (enum, required): 独立数据范围：sandbox 或 live。 Values: `"sandbox"`, `"live"`.
- `installation` (object, required): 当前安装实例的已验证绑定和地址状态。
- `installation.installationId` (uuid, required): 此设备安装实例的 UUID，不是 Customer UUID。
- `installation.bound` (boolean, required): 该安装是否已绑定当前验证的客户。
- `installation.identitySeq` (integer, required): 最近受理的安装身份操作顺序号。 min: 1 · max: 9007199254740991
- `installation.bindingGeneration` (integer, required): 当前设备与客户绑定的代次，用于隔离旧持有者。 min: 1 · max: 9007199254740991
- `installation.addressSeq` (integer, required): 最近受理的设备地址操作顺序号。 min: 0 · max: 9007199254740991
- `installation.addressRevision` (integer, required): 设备地址状态的当前修订号。 min: 0 · max: 9007199254740991
- `installation.connectionId` (uuid | null, required): 当前 App／环境内已验证的商户消息连接 UUID。
- `installation.addressStatus` (enum | null, required): 已注册地址是否有效；未注册地址时为 null。
- `installation.permission` (enum, required): 设备系统通知权限；不等同于客户同意接收商户消息。 Values: `"unknown"`, `"denied"`, `"provisional"`, `"granted"`.

<a id="errors"></a>

## 错误

失败时返回错误对象，按 `error.code` 与 `error.recovery` 处理。下表是这个接口的凭据、作用域和幂等字段决定的错误；视请求内容还可能返回 `NOT_FOUND`（引用的资源不存在）、`NOT_CONFIGURED`（所需的集成未连接）或 `PAYLOAD_TOO_LARGE`。有些拒绝（如余额不足）不是错误，而是成功响应里的 `reason`。

**可能的错误**

| code | HTTP | 何时 | recovery |
| --- | --- | --- | --- |
| `INVALID_REQUEST` | 400 | 请求不符合本页的参数。缺少或无法解析协议头时分别返回 `UNSUPPORTED_PROTOCOL_VERSION` 或 `INVALID_PROTOCOL_VERSION`。 | `fix_request` |
| `UNAUTHENTICATED` | 401 | 凭据缺失、无效、过期或已撤销。 | `authenticate` |
| `FORBIDDEN` | 403 | 凭据没有 `messaging:write` 权限。 | `check_permissions` |
| `SCOPE_MISMATCH` | 403 | `X-Indiana-Project` 或 `X-Indiana-Environment` 与凭据所属的 App 和环境不一致。 | `check_scope` |
| `RATE_LIMITED` | 429 | 请求过多；按 `Retry-After` 等待后用同一请求重试。 | `retry_same_request` |
| `SERVICE_UNAVAILABLE` | 503 | 服务暂时不可用；用同一请求重试。 | `retry_same_request` |
| `INTERNAL_ERROR` | 500 | 结果未知；稍后重试。 | `recover_operation` |

- [错误码与恢复](https://www.longplayai.com/zh-hans/docs/api/errors.md)
- [请求约定](https://www.longplayai.com/zh-hans/docs/api.md)
- [全部接口](https://www.longplayai.com/zh-hans/docs/api/operations.md#messaging)
