身份验证
请将 API 密钥作为 bearer 令牌发送。该密钥必须具有 sites.view 权限;缺少该权限的密钥将被拒绝并返回 403 状态码,而非 404。
您的组织 ID 应填在此处
此端点接受 org_id 作为 JSON 正文中的一个字段。
您的组织ID位于控制面板的API密钥屏幕上,就在密钥本身的旁边。这是您在每次调用时使用的相同ID。
免费试用
将尖括号中的内容替换为您自己的值,并将键占位符替换为您仪表板中的一个键。
curl -X POST https://api.zinndigital.com/v1/compute/servers \
-H "Authorization: Bearer zdk_live_…" \
-H "Content-Type: application/json" \
-d '{ "name": <string>, "zone": <string> }'已登录?您仪表板中的 API 控制台会自动填入您真实的组织 ID 和您自己的密钥,并针对实时 API 运行请求,以便您查看实际的响应。 在 API 控制台中打开此端点
详细信息
Buys a machine. `202` and the pending server: the purchase is durable and runs off the request path as a Temporal workflow (§2.9), so the client polls the returned server until `status` leaves `provisioning`. ⛔ **The row is written first and the workflow started second.** The reverse would mean a workflow whose row does not exist yet, and its first activity would fail on a race it can never win. The row's id is also the workflow id and the machine's name at the provider, which is what makes the whole path idempotent. If the workflow service cannot be reached the order is refused `503` with nothing charged — an acceptance is never fabricated, because the customer would watch a spinner for a server that was never ordered and then order it again. Send either `spec` or `plan_code`; neither is `422`, not a `500`. `org_id` is required only of a caller who belongs to more than one organisation, and naming one they cannot create in is `403`. A size, zone or disk/bandwidth pair the provider does not offer, or a name already taken, is `422` in our wording. Requires `sites.view` **and** `billing.entitlement.manage` — ⛔ **not** `sites.create`, which is what this was until #1682. Ordering a machine charges Zinn®'s reseller balance immediately and bills nobody, so it is deliberately a STAFF key; `sites.create` is held by the customer `dev` role.
请求正文
| 名称 | 类型 | 必填 | 内容简介 |
|---|---|---|---|
name | string | 是 | What to call the machine. It is also the name at the provider, which is what lets a retried purchase find the machine it already bought instead of buying a second. |
zone | string | 是 | The data centre, as `getComputeCatalogue` reported it. |
spec | string | 否 | The machine size, as the configurator reported it. ⭐ **Either this or `plan_code`, not both** — and where the provider publishes no sizes the two collapse into one, because the… |
plan_code | string | 否 | The tier to buy, for a catalogue-aware caller. Either this or `spec`. |
org_id | Uuid | 否 | The organisation to buy for. Required only when the caller belongs to more than one — picking "the first org in scope" would buy a server on an arbitrary tenant's balance. Omitt… |
provider | string | 否 | Which platform to place it on. Omitted, the engine resolves the range's default — ⛔ **except on a range priced per data centre** (`ComputeTier.zoned`), where omitting it is refu… |
image | string | 否 | The operating system or one-click application the machine boots, as `getComputeCatalogue` reported it in `ComputeProvider.images`. ⛔ Required — `422` — on any range that publish… |
ssh_keys | string[] | 否 | The ids of the authorised keys to install at build time, from `listComputeSshKeys`. ⛔⛔ **Required on the Zinn® Private Cloud range, and the refusal is a security control rather… |
term_months | integer | 否 | How many months to buy up front. Outside 1…36 is refused `422` before a single vendor write, the same bound `renewComputeServer` applies. |
optimisation | string | 否 | A stack optimisation profile, as the configurator reported it. |
disk | string | 否 | An explicit disk allocation, for a provider whose `supports_disk_and_bandwidth` is true. Sending it to one whose is false is refused. |
bandwidth | string | 否 | An explicit transfer allocation, for a provider whose `supports_disk_and_bandwidth` is true. |
响应
| 名称 | 类型 | 必填 | 内容简介 |
|---|---|---|---|
id | Uuid | 是 | **Ours**, and also the provisioning workflow's id and the machine's name at the provider — which is what makes the whole purchase path idempotent. |
name | string | 是 | What the customer called it. ⛔ At the provider a machine's name is its row id; confusing the two is a cross-tenant defect, so this is the customer's string and nothing else. |
deploy_target | string | 是 | Which compute range the machine belongs to. |
plan_code | string | 是 | The tier it was bought on, or `""` when it was ordered by size alone. |
provider | string | 是 | Our provider id. |
spec | string | 是 | The machine size it currently runs. |
zone | string | 是 | The data centre it runs in. |
status | string<pending, provisioning, active, failed, suspended, terminated> | 是 | How far the order got — **ours**, and a different fact from `power_state`. `pending` is a row with nothing bought and nothing charged; `failed` is the state whose `message` is t… |
message | string | 是 | Why the order failed, in a sentence the customer reads. Blank unless `failed`. |
vendor_status | string | 是 | The provider's own word, verbatim and unrounded. Staff-facing detail; a customer client renders `status` and never this. |
power_state | string<unknown, on, off, starting, stopping, rebooting> | 是 | What the machine is doing right now. ⛔ **Six values, not two, and the four extra ones are the point: a machine mid-transition is not "on".** `unknown` is the honest answer when… |
addresses | string[] | 是 | Public addresses **if the provider states them**. Empty means *not stated*, never "none" — a machine rendered as having no address reads as broken. |
optimisation | string | 是 | The stack optimisation profile it was built with, or `""` for none. |
term_months | integer | 是 | The term it was bought on, or null when the provider states none. |
renews_at | string | 是 | ⛔ **Always null today, and honestly so**: the provider publishes no renewal date, and one computed from the order plus the term would be our arithmetic rendered as the provider'… |
created_at | string | 是 | When the row was created, or `""` when not stated. |
operable | boolean | 是 | Whether the customer may act on this machine — power, resize, renew, rebuild. ⛔ Read rather than re-derived from `status`: the engine refuses every one of those on anything but… |
image | string | 是 | The provider image the machine was built from. Blank on the resold range, which installs one managed image and offers no choice. |
suspended | boolean | 是 | ⛔⛔ **Whether WE stopped it, which is not the same fact as `power_state`.** A stopped machine is the customer's own choice and they may start it again; a suspended one is ours an… |
suspension_reason | string | 是 | Why, verbatim, so the customer reads the same sentence support wrote. Blank when the machine is in good standing. |
capabilities | string[] | 是 | ⭐⭐ **What this machine's provider can actually do** — capability tokens such as `compute:snapshots`, `compute:console`, `compute:firewall`, `compute:backups_manage` and `compute… |
此端点可能返回的错误
401 · 403 · 404 · 422 · 429 · 503