API tự động hóa
MyPanel có REST API dùng chính cho giao diện. Trang này liệt kê tập endpoint ổn định, hữu ích cho tự động hóa (CI/CD, script vận hành). Xác thực bằng API token (gói Pro).
Xác thực
Phần tiêu đề “Xác thực”Mọi request gửi kèm header:
Authorization: Bearer mpat_xxxxxxxxBase URL là địa chỉ panel của bạn, ví dụ https://panel.example.com. Các ví dụ
dưới dùng hai biến:
PANEL=https://panel.example.comTOKEN=mpat_xxxxxxxxWebsite
Phần tiêu đề “Website”# Liệt kê websitecurl -H "Authorization: Bearer $TOKEN" $PANEL/api/sites
# Tạo website (reverse proxy / 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
# Triển khai (deploy) website theo idcurl -X POST -H "Authorization: Bearer $TOKEN" $PANEL/api/sites/1/deploy
# Xem trạng thái lần triển khai gần nhấtcurl -H "Authorization: Bearer $TOKEN" $PANEL/api/sites/1/deployment
# Xóa websitecurl -X DELETE -H "Authorization: Bearer $TOKEN" $PANEL/api/sites/1Cơ sở dữ liệu
Phần tiêu đề “Cơ sở dữ liệu”# Liệt kê databasecurl -H "Authorization: Bearer $TOKEN" $PANEL/api/databases
# Tạo databasecurl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ -d '{"engine":"MySQL","name":"app_prod"}' $PANEL/api/databases
# Tạo bản backup ngay cho database theo idcurl -X POST -H "Authorization: Bearer $TOKEN" $PANEL/api/databases/1/backupsHệ thống
Phần tiêu đề “Hệ thống”# Thông tin server (hostname, OS, uptime, tải, phiên bản)curl -H "Authorization: Bearer $TOKEN" $PANEL/api/system
# Trạng thái cập nhật (phiên bản hiện tại / mới nhất)curl -H "Authorization: Bearer $TOKEN" $PANEL/api/updateMã trạng thái
Phần tiêu đề “Mã trạng thái”| Mã | Ý nghĩa |
|---|---|
200 / 201 / 202 / 204 | Thành công |
400 | Dữ liệu gửi lên không hợp lệ |
401 | Token sai hoặc thiếu |
402 | Vượt giới hạn gói (kèm {"upgrade":"pro"}) |
403 | Không đủ quyền |
404 | Không tìm thấy tài nguyên |