自動化 API
MyPanel には主に UI を動かすための REST API があります。このページでは、自動化(CI/CD、運用スクリプト)に役立つ安定したエンドポイント を一覧します。認証には API トークン(Pro)を使用します。
すべてのリクエストには次のヘッダーを含めます。
Authorization: Bearer mpat_xxxxxxxxベース URL はパネルのアドレスです(例: https://panel.example.com)。以下の例では 2 つの変数を使用します。
PANEL=https://panel.example.comTOKEN=mpat_xxxxxxxxウェブサイト
Section titled “ウェブサイト”# List websitescurl -H "Authorization: Bearer $TOKEN" $PANEL/api/sites
# Create a website (reverseproxy / static / nixpacks / dockerfile / image / wordpress)curl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ -d '{"domain":"app.example.com","buildKind":"reverseproxy","source":"http://127.0.0.1:3000"}' \ $PANEL/api/sites
# Deploy a website by idcurl -X POST -H "Authorization: Bearer $TOKEN" $PANEL/api/sites/1/deploy
# Get the latest deployment statuscurl -H "Authorization: Bearer $TOKEN" $PANEL/api/sites/1/deployment
# Delete a websitecurl -X DELETE -H "Authorization: Bearer $TOKEN" $PANEL/api/sites/1データベース
Section titled “データベース”# List databasescurl -H "Authorization: Bearer $TOKEN" $PANEL/api/databases
# Create a databasecurl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ -d '{"engine":"MySQL","name":"app_prod"}' $PANEL/api/databases
# Trigger a backup for a database by idcurl -X POST -H "Authorization: Bearer $TOKEN" $PANEL/api/databases/1/backups# Server info (hostname, OS, uptime, load, version)curl -H "Authorization: Bearer $TOKEN" $PANEL/api/system
# Update status (current / latest version)curl -H "Authorization: Bearer $TOKEN" $PANEL/api/updateステータスコード
Section titled “ステータスコード”| コード | 意味 |
|---|---|
200 / 201 / 202 / 204 | 成功 |
400 | リクエストボディが不正 |
401 | トークンが欠落または無効 |
402 | プランの上限に到達({"upgrade":"pro"} を含む) |
403 | 権限が不足 |
404 | リソースが見つからない |