පරිපාලක API
පරිපාලක API බලඇණිය මත ක්රියාත්මක වේ. එයට ක්රියාකරු සැසියක් හෝ - වඩාත් සුදුසු - විෂය පථය සහිත API යතුරක් අවශ්ය වේ. සෑම ලිවීමක්ම යතුර හෝ ක්රියාකරුගේ අනන්යතාවය සමඟ විගණන ලොගයට ලියා ඇත.
අන්ත ලක්ෂ්ය
| ක්රමය | මාර්ගය | විෂය පථය |
|---|---|---|
GET | /api/admin/users | users:read |
POST | /api/admin/users | users:write |
GET | /api/admin/users/{id} | users:read |
PATCH | /api/admin/users/{id} | users:write |
POST | /api/admin/users/{id}/suspend | users:write |
GET | /api/admin/nodes | nodes:read |
POST | /api/admin/nodes | nodes:write |
GET | /api/admin/packages | packages:read |
POST | /api/admin/packages | packages:write |
GET | /api/admin/orders | orders:read |
POST | /api/admin/orders/{id}/refund | orders:write |
GET | /api/admin/api-keys | keys:read |
POST | /api/admin/api-keys | keys:write |
GET | /api/admin/logs | logs:read |
පරිශීලකයන් ලැයිස්තුගත කරන්න
GET /api/admin/users?status=active&package=business&per_page=50
Authorization: Bearer <api-key>{
"ok": true,
"data": [
{
"id": 1042,
"email": "owner@acme.example",
"package": "business",
"node": "fra-01",
"status": "active",
"usage": { "disk_gb": 12.4, "sites": 6, "databases": 9, "mailboxes": 18 },
"created_at": "2026-04-11T08:20:00Z"
}
],
"meta": { "page": 1, "per_page": 50, "total": 1 }
}පරිශීලකයෙකු සාදන්න
POST /api/admin/users
Idempotency-Key: 9b2f1c4d-6a3e-4f8b-9d1c-7e5a2b6f8c30
{
"email": "new@acme.example",
"package": "business",
"node": "fra-01",
"send_invite": true
}ඉල්ලීම ගිණුම් වස්තුව සහ provisioning තත්ත්වය සමඟ 201 ලබා දෙයි. status active වන තෙක් පරිශීලක වාර්තාව මත විමසන්න.
අත්හිටුවීම සහ ප්රතිෂ්ඨාපනය කිරීම
POST /api/admin/users/1042/suspend
{ "reason": "overdue_invoice" }PATCH /api/admin/users/1042
{ "status": "active" }අත්හිටුවීම වෙබ් අඩවි සහ තැපැල් නතර කරන නමුත් දත්ත තබා ගනී. හේතුව අභ්යන්තරව ගබඩා කර ඇති අතර විගණන ප්රවේශයට ඇතුළත් කර ඇත.
නෝඩ්
GET /api/admin/nodes{
"ok": true,
"data": [
{
"id": "fra-01",
"region": "eu-central",
"state": "healthy",
"capacity": { "cpu": 8, "memory_gb": 32, "disk_gb": 500 },
"usage": { "cpu_pct": 41, "memory_pct": 58, "disk_pct": 63 },
"last_seen": "2026-12-01T09:15:12Z"
}
]
}නව ගිණුම් උපලේඛනගත කිරීමට පෙර degraded හෝ offline තත්වයේ නෝඩයක් විමර්ශනය කළ යුතුය.
පැකේජ
POST /api/admin/packages
{
"name": "Business",
"price_cents": 2900,
"currency": "USD",
"cycle": "monthly",
"limits": { "disk_gb": 50, "sites": 25, "databases": 50, "mailboxes": 100 },
"features": { "ssh": true, "git_deploy": true, "api": true }
}ප්රතිසන්ධාන කාර්යයක් පෝලිම් කරන apply_to_existing true නම් මිස පැකේජ වෙනස් කිරීම් පවතින ගිණුම් ප්රතික්රියාශීලීව නැවත ලියන්නේ නැත.
ආපසු ගෙවීම්
POST /api/admin/orders/8812/refund
{ "amount_cents": 2900, "reason": "duplicate_charge" }ඇණවුම සහ මුදල අනුව මුදල් ආපසු ගෙවිය නොහැක. දෙවන සමාන ඇමතුමක් අලුත් එකක් නිකුත් කරනවාට වඩා මුල් මුදල් ආපසු ලබා දෙයි.
API යතුරු
POST /api/admin/api-keys
{
"name": "billing-sync",
"scopes": ["orders:read", "users:read"],
"expires_in_days": 90
}රහස හරියටම වරක් ආපසු එයි. එය රහස් කළමනාකරුවෙකු තුළ ගබඩා කරන්න; පැනලය හෑෂ් එකක් පමණක් තබා ගනී.
විගණන සටහන
GET /api/admin/logs?action=user.suspend&from=2026-11-01&to=2026-12-01{
"ok": true,
"data": [
{
"actor": "ops@example.com",
"action": "user.suspend",
"target": "customer:1042",
"before": { "status": "active" },
"after": { "status": "suspended" },
"ip": "203.0.113.9",
"at": "2026-12-01T09:14:22Z"
}
]
}දෝෂ හැසිරවීම
පරිපාලක ලිවීම් scope_missing, forbidden, conflict හෝ provisioning_failed සමඟ අසාර්ථක විය හැක. ප්රතිපාදන අසාර්ථක වීමකට job_id ඇතුළත් වේ; හේතුව නිවැරදි කිරීමෙන් පසු එම idempotency යතුර සමඟ නැවත උත්සාහ කරන්න.
{
"ok": false,
"error": {
"code": "scope_missing",
"message": "API key lacks users:write",
"request_id": "req_01J8Z5C1"
}
}සම්බන්ධයි
- සත්යාපනය සහ අනුපාත සීමාවන් සඳහා API දළ විශ්ලේෂණය.
- කොන්සෝල කාර්ය ප්රවාහ සඳහා පරිශීලකයින් සහ පාරිභෝගිකයින්.
- ප්රධාන ප්රතිපත්තිය සඳහා ආරක්ෂාව සහ සැකසීම්.