Skip to content
WasFor
Hoki ki te kainga
Tuhinga/Kaiwhakawhanake API

API Kaiwhakahaere

Ko te kaiwhakahaere API e mahi ana i runga i te waka. Me whai waahi kaiwhakahaere, he pai ake ranei - he taviri API. Ko ia tuhi ka tuhia ki te raarangi kaute me te matua, te tuakiri kaiwhakahaere ranei.

Nga Whakamutunga

TikangaAraTe whānuitanga
GET/api/admin/usersusers:read
POST/api/admin/usersusers:write
GET/api/admin/users/{id}users:read
PATCH/api/admin/users/{id}users:write
POST/api/admin/users/{id}/suspendusers:write
GET/api/admin/nodesnodes:read
POST/api/admin/nodesnodes:write
GET/api/admin/packagespackages:read
POST/api/admin/packagespackages:write
GET/api/admin/ordersorders:read
POST/api/admin/orders/{id}/refundorders:write
GET/api/admin/api-keyskeys:read
POST/api/admin/api-keyskeys:write
GET/api/admin/logslogs:read

Whakarārangihia nga kaiwhakamahi

http
GET /api/admin/users?status=active&package=business&per_page=50
Authorization: Bearer <api-key>
json
{
  "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 }
}

Waihangahia he kaiwhakamahi

http
POST /api/admin/users
Idempotency-Key: 9b2f1c4d-6a3e-4f8b-9d1c-7e5a2b6f8c30

{
  "email": "new@acme.example",
  "package": "business",
  "node": "fra-01",
  "send_invite": true
}

Ka whakahokia e te tono te 201 me te ahanoa kaute me te mana provisioning. Pootihia te rekoata kaiwhakamahi kia huri ra ano a status hei active.

Whakatarewa me te whakaora

http
POST /api/admin/users/1042/suspend
{ "reason": "overdue_invoice" }
http
PATCH /api/admin/users/1042
{ "status": "active" }

Ko te whakatārewatanga ka aukati i nga paetukutuku me nga mēra engari ka pupuri raraunga. Ko te take kei te rongoa i roto, ka whakauruhia ki te urunga kaute.

Nodes

http
GET /api/admin/nodes
json
{
  "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"
    }
  ]
}

Me tirotirohia he node i te degraded, offline ranei i mua i te whakarite i nga kaute hou.

Mōkī

http
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 }
}

Ko nga huringa kete karekau e tuhi whakamuri i nga kaute o mua mena ko te apply_to_existing te true, e tutira ana i te mahi houhanga rongo.

Nga moni whakahoki

http
POST /api/admin/orders/8812/refund
{ "amount_cents": 2900, "reason": "duplicate_charge" }

Ko nga moni whakahoki he tohu mo ia ota me te nui. Ko te waea tuarua ka whakahoki i te moni whakahoki taketake kaua ki te tuku i tetahi mea hou.

API mau taviri

http
POST /api/admin/api-keys
{
  "name": "billing-sync",
  "scopes": ["orders:read", "users:read"],
  "expires_in_days": 90
}

Kotahi tonu te whakahokinga mai o te mea ngaro. Whakaorangia i roto i te kaiwhakahaere ngaro; he hash noa iho te panui.

Takitaki kaute

http
GET /api/admin/logs?action=user.suspend&from=2026-11-01&to=2026-12-01
json
{
  "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"
    }
  ]
}

Hapa whakahaere

Ka rahua te tuhi a te Kaiwhakahaere me scope_missing, forbidden, conflict, provisioning_failed ranei. Ko te rahua o te whakaratonga he job_id; ngana ano me te taviri idempotency kotahi i muri i te whakatika i te take.

json
{
  "ok": false,
  "error": {
    "code": "scope_missing",
    "message": "API key lacks users:write",
    "request_id": "req_01J8Z5C1"
  }
}

E pa ana

Whakahoutanga whakamutunga: 2026-12-01