Lewati ke konten

API Otomasi

MyPanel memiliki REST API yang utamanya menggerakkan UI. Halaman ini mencantumkan endpoint stabil yang berguna untuk otomasi (CI/CD, skrip ops). Autentikasi menggunakan token API (Pro).

Setiap permintaan menyertakan header:

Authorization: Bearer mpat_xxxxxxxx

Base URL adalah alamat panel Anda, mis. https://panel.example.com. Contoh di bawah menggunakan dua variabel:

Terminal window
PANEL=https://panel.example.com
TOKEN=mpat_xxxxxxxx
Terminal window
# Daftar website
curl -H "Authorization: Bearer $TOKEN" $PANEL/api/sites
# Buat 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 website berdasarkan id
curl -X POST -H "Authorization: Bearer $TOKEN" $PANEL/api/sites/1/deploy
# Ambil status deployment terbaru
curl -H "Authorization: Bearer $TOKEN" $PANEL/api/sites/1/deployment
# Hapus website
curl -X DELETE -H "Authorization: Bearer $TOKEN" $PANEL/api/sites/1
Terminal window
# Daftar database
curl -H "Authorization: Bearer $TOKEN" $PANEL/api/databases
# Buat database
curl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{"engine":"MySQL","name":"app_prod"}' $PANEL/api/databases
# Picu backup untuk database berdasarkan id
curl -X POST -H "Authorization: Bearer $TOKEN" $PANEL/api/databases/1/backups
Terminal window
# Info server (hostname, OS, uptime, load, versi)
curl -H "Authorization: Bearer $TOKEN" $PANEL/api/system
# Status pembaruan (versi saat ini / terbaru)
curl -H "Authorization: Bearer $TOKEN" $PANEL/api/update
KodeArti
200 / 201 / 202 / 204Berhasil
400Body permintaan tidak valid
401Token tidak ada atau tidak valid
402Batas paket tercapai (menyertakan {"upgrade":"pro"})
403Izin tidak mencukupi
404Resource tidak ditemukan