3x-ui3x-ui
参考API 参考

API 令牌

管理用于程序化认证的 Bearer 令牌(机器人、代表本节点操作的中心面板、CI)。每个令牌都有唯一的名称和一个启用标志——禁用即可在不删除的情况下吊销,删除则为永久吊销。令牌以 SHA-256 哈希形式存储,明文仅在创建响应中返回一次——此后无法再次获取,因此请当场复制保存。在任意 /panel/api/* 请求中以 <code>Authorization: Bearer &lt;token&gt;</code> 的形式发送令牌——该令牌是一份完全管理员凭据。

GET
/panel/api/setting/apiTokens

Authorization

AuthorizationBearer <token>

API token from Settings → Security → API Token. Send as Authorization: Bearer <token>.

In: header

Response Body

application/json

curl -X GET "https://example.com/panel/api/setting/apiTokens"
{  "success": true,  "obj": [    {      "id": 1,      "name": "default",      "enabled": true,      "createdAt": 1736000000    }  ]}
POST
/panel/api/setting/apiTokens/create

Authorization

AuthorizationBearer <token>

API token from Settings → Security → API Token. Send as Authorization: Bearer <token>.

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

curl -X POST "https://example.com/panel/api/setting/apiTokens/create" \  -H "Content-Type: application/json" \  -d '{    "name": "central-panel-a"  }'
{  "success": true,  "obj": {    "createdAt": 1736000000,    "enabled": true,    "id": 2,    "name": "central-panel-a",    "token": "new-token-string"  }}
{  "success": false,  "msg": "a token with that name already exists"}
POST
/panel/api/setting/apiTokens/delete/{id}

Authorization

AuthorizationBearer <token>

API token from Settings → Security → API Token. Send as Authorization: Bearer <token>.

In: header

Path Parameters

id*integer

Token row ID.

Response Body

application/json

curl -X POST "https://example.com/panel/api/setting/apiTokens/delete/0"
{  "success": true}
POST
/panel/api/setting/apiTokens/setEnabled/{id}

Authorization

AuthorizationBearer <token>

API token from Settings → Security → API Token. Send as Authorization: Bearer <token>.

In: header

Path Parameters

id*integer

Token row ID.

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

curl -X POST "https://example.com/panel/api/setting/apiTokens/setEnabled/0" \  -H "Content-Type: application/json" \  -d '{    "enabled": false  }'
{  "success": true}