切换主题
吊销运行时会话
POST /miniapp/v1/apps/{app_id}/runtime/sessions/revoke
主动吊销当前小程序运行时会话。
鉴权与参数
应用后端使用 Authorization: Bearer <本应用服务凭据>。
| 参数 | 位置 | 必填 | 说明 |
|---|---|---|---|
app_id | path | 是 | {"type":"string","pattern":"^[a-z][a-z0-9_-]{2,63}$"} |
X-MiniApp-Run-Instance | header | 是 | 当前小程序运行实例 ID,用于隔离会话和撤销范围。 |
X-MiniApp-Session | header | 是 | 会话交换成功后返回的运行时会话令牌。 |
请求体
无需请求体。
响应
HTTP 204
Session revoked.
HTTP 401
服务凭据或运行时会话无效。
| 字段 | 类型 | 在所属对象中必填 | 说明与约束 |
|---|---|---|---|
error | object | 是 | |
error.code | string | 是 | |
error.message | string | 是 | |
error.details | object | 否 | additionalProperties: false |
error.details.reason | string | 否 |
完整定义
下列定义包含引用、Header 和字段约束,来自同一契约的本接口投影。
查看 JSON Schema 与响应定义
json
{
"openapi": "3.1.0",
"info": {
"title": "MetaEco 应用服务端 API",
"version": "6.0.0"
},
"servers": [
{
"url": "{platformOrigin}",
"description": "导入后填写实际 API 入口;文档域名不承载 API",
"variables": {
"platformOrigin": {
"default": "https://api.example.invalid",
"description": "替换为当前应用分配的 API 网关,示例域名不可访问"
}
}
}
],
"paths": {
"/miniapp/v1/apps/{app_id}/runtime/sessions/revoke": {
"post": {
"summary": "吊销运行时会话",
"description": "主动吊销当前小程序运行时会话。",
"tags": [
"runtime"
],
"security": [
{
"serviceCredential": []
}
],
"parameters": [
{
"$ref": "#/components/parameters/AppID"
},
{
"$ref": "#/components/parameters/RunInstance"
},
{
"$ref": "#/components/parameters/Session"
}
],
"responses": {
"204": {
"description": "Session revoked."
},
"401": {
"$ref": "#/components/responses/RuntimeUnauthorized"
}
}
}
}
},
"components": {
"securitySchemes": {
"serviceCredential": {
"type": "http",
"scheme": "bearer",
"bearerFormat": "MiniAppServiceCredential",
"description": "小程序运行时和内部服务调用使用的短期服务凭据。"
}
},
"parameters": {
"AppID": {
"name": "app_id",
"in": "path",
"required": true,
"schema": {
"type": "string",
"pattern": "^[a-z][a-z0-9_-]{2,63}$"
}
},
"RunInstance": {
"name": "X-MiniApp-Run-Instance",
"in": "header",
"required": true,
"description": "当前小程序运行实例 ID,用于隔离会话和撤销范围。",
"schema": {
"type": "string",
"minLength": 8,
"maxLength": 128
}
},
"Session": {
"name": "X-MiniApp-Session",
"in": "header",
"required": true,
"description": "会话交换成功后返回的运行时会话令牌。",
"schema": {
"type": "string",
"minLength": 1,
"maxLength": 4096
}
}
},
"responses": {
"RuntimeUnauthorized": {
"description": "服务凭据或运行时会话无效。",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
},
"schemas": {
"ErrorResponse": {
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "object",
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"details": {
"type": "object",
"additionalProperties": false,
"properties": {
"reason": {
"type": "string"
}
}
}
}
}
}
}
}
}
}