# Lifecycle

> Plan changes, cancellation and termination.

Source: https://docs.clouduxe.com/api/reference/lifecycle/

Base URL: `https://api.clouduxe.com/v1`. Generated from the API contract, version 2026-12-01.

## The Service object

A VPS, a Dedicated server or a protected proxy on your account.

### Attributes

- `object` (string, required): The object's type. Always "service".
- `id` (string (uuid), required): The service's id.
- `type` (string, required): vps, dedicated or proxy. One of `vps`, `dedicated`, `proxy`.
- `status` (string, required): pending (paid and waiting for set-up to start), provisioning, active, suspended, failed (set-up failed; staff are on it), terminating (deletion scheduled at deletesAt) or terminated. One of `pending`, `provisioning`, `active`, `suspended`, `failed`, `terminating`, `terminated`.
- `suspensionReason` (string or null, required): Why the service is suspended: overdue (an unpaid invoice) or other (contact support). Null unless suspended. One of `overdue`, `other`.
- `deletesAt` (string (date-time) or null, required): When a terminating service's server will be deleted, or null.
- `planId` (string, required): The plan's id.
- `planName` (string or null, required): The plan's name.
- `region` (string or null, required): The region, or null for a proxy. One of `mumbai`, `singapore`, `limburg`.
- `label` (string or null, required): Your label for the service. max length 253.
- `reference` (string or null, required): Your own identifier for this object, such as your client's id in your billing system. 1 to 100 printable characters, or null. Not unique: several objects may share one. Filter lists by it with the reference query parameter. min length 1, max length 100.
- `metadata` (object, required): Your own key-value data on this object. max 20 keys.
- `firewallAvailable` (boolean, required): True when the service has a Shield firewall you can manage through the firewall operations.
- `billing` (object or null, required): Billing details, for the account owner's tokens. Null for a delegate's token.
  - `cycleMonths` (integer, required): The billing cycle in months.
  - `price` (object or null, required): The renewal price per cycle, excluding GST, locked when the service was bought. Null when it cannot be read.
    - `amount` (integer, required): The amount in the currency's smallest unit. For INR and USD that is one hundredth of the unit. min -9007199254740991, max 9007199254740991.
    - `currency` (string, required): The ISO 4217 currency code, upper case. pattern ^[A-Z]{3}$.
  - `currentPeriodStart` (string (date), required): The first day of the current period, a UTC calendar day.
  - `paidThrough` (string (date), required): The last day paid for, a UTC calendar day. The renewal invoice for the next period is issued before it.
  - `cancelAtPeriodEnd` (boolean, required): True when the service will end on paidThrough instead of renewing.
  - `endsOn` (string (date) or null, required): The day the service ends, when cancelAtPeriodEnd is true; otherwise null.
- `server` (object or null, required): For vps and dedicated; null for proxy.
  - `powerState` (string, required): running, stopped, building (being built or reinstalled), suspended, missing (the server cannot be found; staff are notified) or unknown. One of `running`, `stopped`, `building`, `suspended`, `missing`, `unknown`.
  - `hostname` (string or null, required): The hostname you set at order or reinstall.
  - `ipv4` (array of string, required): The server's IPv4 addresses, primary first.
  - `ipv6` (array of string, required): The server's IPv6 addresses.
  - `image` (object or null, required): The installed image, or null when not known.
    - `object` (string, required): The object's type. Always "image".
    - `id` (string, required): The image's id. Pass it as imageId.
    - `name` (string, required): The image's name, for showing to people.
    - `family` (string, required): linux or windows. A root password reset sets the password of Administrator on windows and of root otherwise. One of `linux`, `windows`.
  - `resources` (object or null, required): The server's resources, or null when not known.
    - `cpuCores` (integer or null, required): Virtual CPU cores, or null when not known.
    - `memoryMb` (integer or null, required): Memory in MiB, or null.
    - `diskGb` (integer or null, required): Disk in GB, or null.
    - `trafficGb` (integer or null, required): Monthly traffic allowance in GB, or null for unmetered or unknown.
  - `statusUpdatedAt` (string (date-time) or null, required): When this state was read.
  - `stale` (boolean, required): True when the state is more than 5 minutes old.
- `proxy` (object or null, required): For proxy; null otherwise.
  - `profile` (string, required): The protection profile.
  - `ports` (array of ProxyPort, required): The protected ports.
    - `protocol` (string, required): tcp or udp. One of `tcp`, `udp`.
    - `portStart` (integer, required): The first port. min 1, max 65535.
    - `portEnd` (integer, required): The last port, equal to portStart for one port. min 1, max 65535.
- `createdAt` (string (date-time), required): When the service was created.
- `livemode` (boolean, required): True for objects of your live account.

### Example

```json
{
  "object": "service",
  "id": "c3a1f6d2-8b4e-4a9c-b7d5-2e1f0a3c6b8d",
  "type": "vps",
  "status": "active",
  "suspensionReason": null,
  "deletesAt": null,
  "planId": "vps-nvme-4-mumbai",
  "planName": "NVMe VPS 4 GB",
  "region": "mumbai",
  "label": "node1",
  "reference": "client-4471",
  "metadata": {
    "whmcsServiceId": "18342",
    "plan": "starter"
  },
  "firewallAvailable": true,
  "billing": {
    "cycleMonths": 1,
    "price": {
      "amount": 129900,
      "currency": "INR"
    },
    "currentPeriodStart": "2026-12-04",
    "paidThrough": "2027-01-03",
    "cancelAtPeriodEnd": false,
    "endsOn": null
  },
  "server": {
    "powerState": "running",
    "hostname": "node1.acme.example",
    "ipv4": [
      "203.0.113.24"
    ],
    "ipv6": [
      "2001:db8:4f2a::24"
    ],
    "image": {
      "object": "image",
      "id": "ubuntu-24.04",
      "name": "Ubuntu 24.04 LTS",
      "family": "linux"
    },
    "resources": {
      "cpuCores": 2,
      "memoryMb": 4096,
      "diskGb": 80,
      "trafficGb": 4000
    },
    "statusUpdatedAt": "2026-12-04T10:02:41Z",
    "stale": false
  },
  "proxy": null,
  "createdAt": "2026-12-04T09:15:24Z",
  "livemode": true
}
```

## Change a service's plan

`POST /services/{serviceId}/plan-change`

Use this to upgrade a service. The charge for the rest of the period is invoiced and paid from wallet credit in one step; if credit does not cover it, nothing is written (insufficient_credit). Answers a plan_change action: it stays queued while the change waits to be applied (by Clouduxe's team when automatic apply is off), and succeeds once the platform has the new plan. A VPS gets its new memory and disk at its next power cycle.

Token scope: `services:lifecycle`.

### Path parameters

- `serviceId` (string (uuid), required): The service's id.

### Headers

- `Clouduxe-Version` (string): The API version to use, such as 2026-12-01. Omit it to use your token's version. pattern ^[0-9]{4}-[0-9]{2}-[0-9]{2}$.
- `Idempotency-Key` (string, required): A unique key for this logical request, 1 to 128 characters of letters, digits, underscore, dot, colon or hyphen; a UUID is best. Retrying with the same key is safe: the change happens once and the retry gets the same answer. Keys are kept 48 hours. pattern ^[A-Za-z0-9_.:-]{1,128}$.

### Body (required)

- `planId` (string, required): The target plan's id, from listServicePlanOptions.

### Responses

- `202`: The plan change, started.
- `400`: The request is not valid. Codes: version_invalid, idempotency_key_required, idempotency_key_invalid, invalid_json, parameter_missing, parameter_invalid, parameter_unknown.
- `401`: Authentication failed. Codes: token_missing, token_invalid, token_expired, token_revoked.
- `402`: Payment from wallet credit is not possible. Codes: insufficient_credit, credit_currency_mismatch.
- `403`: The token is not allowed to do this. Codes: forbidden, ip_not_allowed, api_access_disabled, scope_missing.
- `404`: Not found. Codes: not_found.
- `409`: The request conflicts with the object's current state. Codes: service_not_ready, plan_change_open, previous_change_pending, plan_change_too_soon, renewal_in_progress, currency_not_offered, account_closed, idempotency_in_progress.
- `413`: The request body is too large. Codes: request_too_large.
- `415`: Unsupported media type. Codes: unsupported_media_type.
- `422`: The request is well formed but cannot be carried out. Codes: plan_change_not_allowed, quote_incomplete, idempotency_mismatch.
- `423`: The service is locked. Codes: service_locked.
- `429`: A rate limit was reached. Codes: rate_limited.
- `500`: Unexpected error. Codes: internal_error.
- `503`: Temporarily unavailable. Codes: plan_change_unavailable, unavailable, outcome_unknown, limits_unavailable.

### Request

curl:
```bash
curl -X POST https://api.clouduxe.com/v1/services/c3a1f6d2-8b4e-4a9c-b7d5-2e1f0a3c6b8d/plan-change \
  -H "Authorization: Bearer $CLOUDUXE_API_KEY" \
  -H "Idempotency-Key: 6f1c2e9a-4b7d-4e3a-9c8f-1a2b3c4d5e6f" \
  -H "Content-Type: application/json" \
  -d '{"planId":"vps-nvme-8-mumbai"}'
```

Node SDK:
```javascript
import { Clouduxe } from "@clouduxe/sdk";

const cx = new Clouduxe({ apiKey: process.env.CLOUDUXE_API_KEY });

const action = await cx.services.changePlan("c3a1f6d2-8b4e-4a9c-b7d5-2e1f0a3c6b8d", { planId: "vps-nvme-8-mumbai" });
```

Python:
```python
import os
import requests

res = requests.post(
    "https://api.clouduxe.com/v1/services/c3a1f6d2-8b4e-4a9c-b7d5-2e1f0a3c6b8d/plan-change",
    headers={
        "Authorization": f"Bearer {os.environ['CLOUDUXE_API_KEY']}",
        "Idempotency-Key": "6f1c2e9a-4b7d-4e3a-9c8f-1a2b3c4d5e6f",
    },
    json={
        "planId": "vps-nvme-8-mumbai",
    },
)
action = res.json()
```

PHP SDK:
```php
<?php
require 'vendor/autoload.php';

$cx = new \Clouduxe\Clouduxe(['apiKey' => getenv('CLOUDUXE_API_KEY')]);

$action = $cx->services->changePlan('c3a1f6d2-8b4e-4a9c-b7d5-2e1f0a3c6b8d', ['planId' => 'vps-nvme-8-mumbai']);
```

fetch:
```javascript
const res = await fetch("https://api.clouduxe.com/v1/services/c3a1f6d2-8b4e-4a9c-b7d5-2e1f0a3c6b8d/plan-change", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.CLOUDUXE_API_KEY}`,
    "Idempotency-Key": "6f1c2e9a-4b7d-4e3a-9c8f-1a2b3c4d5e6f",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    planId: "vps-nvme-8-mumbai"
  }),
});
const action = await res.json();
```

### Response (`202`)

```json
{
  "object": "action",
  "id": "f5c8b2a1-6e3d-4c9f-b1a7-3d2e9c0f4b6a",
  "type": "plan_change",
  "status": "running",
  "serviceId": "c3a1f6d2-8b4e-4a9c-b7d5-2e1f0a3c6b8d",
  "orderId": null,
  "invoiceId": "b2c7e4a9-5f1d-4e8b-9a3c-6d0f2e7b1c5a",
  "failure": null,
  "secretAvailable": false,
  "secretExpiresAt": null,
  "createdAt": "2026-12-04T09:20:11Z",
  "startedAt": "2026-12-04T09:20:11Z",
  "completedAt": null,
  "livemode": true
}
```


## Set cancellation at period end

`PUT /services/{serviceId}/cancellation`

Use this to stop a service renewing: it keeps running until its paidThrough day, then ends. Send false to keep it renewing. No refund is made.

Token scope: `services:lifecycle`.

### Path parameters

- `serviceId` (string (uuid), required): The service's id.

### Headers

- `Clouduxe-Version` (string): The API version to use, such as 2026-12-01. Omit it to use your token's version. pattern ^[0-9]{4}-[0-9]{2}-[0-9]{2}$.
- `Idempotency-Key` (string, required): A unique key for this logical request, 1 to 128 characters of letters, digits, underscore, dot, colon or hyphen; a UUID is best. Retrying with the same key is safe: the change happens once and the retry gets the same answer. Keys are kept 48 hours. pattern ^[A-Za-z0-9_.:-]{1,128}$.

### Body (required)

- `cancelAtPeriodEnd` (boolean, required): true to end the service on its paidThrough day; false to keep it renewing.
- `reason` (string or null): Why, for our records. Optional. max length 2000.

### Responses

- `200`: The service.
- `400`: The request is not valid. Codes: version_invalid, idempotency_key_required, idempotency_key_invalid, invalid_json, parameter_missing, parameter_invalid, parameter_unknown.
- `401`: Authentication failed. Codes: token_missing, token_invalid, token_expired, token_revoked.
- `403`: The token is not allowed to do this. Codes: forbidden, ip_not_allowed, api_access_disabled, scope_missing.
- `404`: Not found. Codes: not_found.
- `409`: The request conflicts with the object's current state. Codes: termination_pending, service_ended, cancellation_final, idempotency_in_progress.
- `413`: The request body is too large. Codes: request_too_large.
- `415`: Unsupported media type. Codes: unsupported_media_type.
- `422`: The request is well formed but cannot be carried out. Codes: idempotency_mismatch.
- `423`: The service is locked. Codes: service_locked.
- `429`: A rate limit was reached. Codes: rate_limited.
- `500`: Unexpected error. Codes: internal_error.
- `503`: Temporarily unavailable. Codes: unavailable, outcome_unknown, limits_unavailable.

### Request

curl:
```bash
curl -X PUT https://api.clouduxe.com/v1/services/c3a1f6d2-8b4e-4a9c-b7d5-2e1f0a3c6b8d/cancellation \
  -H "Authorization: Bearer $CLOUDUXE_API_KEY" \
  -H "Idempotency-Key: 6f1c2e9a-4b7d-4e3a-9c8f-1a2b3c4d5e6f" \
  -H "Content-Type: application/json" \
  -d '{"cancelAtPeriodEnd":true,"reason":"Customer moved to another plan."}'
```

Node SDK:
```javascript
import { Clouduxe } from "@clouduxe/sdk";

const cx = new Clouduxe({ apiKey: process.env.CLOUDUXE_API_KEY });

const service = await cx.services.setCancellation("c3a1f6d2-8b4e-4a9c-b7d5-2e1f0a3c6b8d", { cancelAtPeriodEnd: true, reason: "Customer moved to another plan." });
```

Python:
```python
import os
import requests

res = requests.put(
    "https://api.clouduxe.com/v1/services/c3a1f6d2-8b4e-4a9c-b7d5-2e1f0a3c6b8d/cancellation",
    headers={
        "Authorization": f"Bearer {os.environ['CLOUDUXE_API_KEY']}",
        "Idempotency-Key": "6f1c2e9a-4b7d-4e3a-9c8f-1a2b3c4d5e6f",
    },
    json={
        "cancelAtPeriodEnd": True,
        "reason": "Customer moved to another plan.",
    },
)
service = res.json()
```

PHP SDK:
```php
<?php
require 'vendor/autoload.php';

$cx = new \Clouduxe\Clouduxe(['apiKey' => getenv('CLOUDUXE_API_KEY')]);

$service = $cx->services->setCancellation('c3a1f6d2-8b4e-4a9c-b7d5-2e1f0a3c6b8d', ['cancelAtPeriodEnd' => true, 'reason' => 'Customer moved to another plan.']);
```

fetch:
```javascript
const res = await fetch("https://api.clouduxe.com/v1/services/c3a1f6d2-8b4e-4a9c-b7d5-2e1f0a3c6b8d/cancellation", {
  method: "PUT",
  headers: {
    Authorization: `Bearer ${process.env.CLOUDUXE_API_KEY}`,
    "Idempotency-Key": "6f1c2e9a-4b7d-4e3a-9c8f-1a2b3c4d5e6f",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    cancelAtPeriodEnd: true,
    reason: "Customer moved to another plan."
  }),
});
const service = await res.json();
```

### Response (`200`)

```json
{
  "object": "service",
  "id": "c3a1f6d2-8b4e-4a9c-b7d5-2e1f0a3c6b8d",
  "type": "vps",
  "status": "active",
  "suspensionReason": null,
  "deletesAt": null,
  "planId": "vps-nvme-4-mumbai",
  "planName": "NVMe VPS 4 GB",
  "region": "mumbai",
  "label": "node1",
  "reference": "client-4471",
  "metadata": {
    "whmcsServiceId": "18342",
    "plan": "starter"
  },
  "firewallAvailable": true,
  "billing": {
    "cycleMonths": 1,
    "price": {
      "amount": 129900,
      "currency": "INR"
    },
    "currentPeriodStart": "2026-12-04",
    "paidThrough": "2027-01-03",
    "cancelAtPeriodEnd": true,
    "endsOn": "2027-01-03"
  },
  "server": {
    "powerState": "running",
    "hostname": "node1.acme.example",
    "ipv4": [
      "203.0.113.24"
    ],
    "ipv6": [
      "2001:db8:4f2a::24"
    ],
    "image": {
      "object": "image",
      "id": "ubuntu-24.04",
      "name": "Ubuntu 24.04 LTS",
      "family": "linux"
    },
    "resources": {
      "cpuCores": 2,
      "memoryMb": 4096,
      "diskGb": 80,
      "trafficGb": 4000
    },
    "statusUpdatedAt": "2026-12-04T10:02:41Z",
    "stale": false
  },
  "proxy": null,
  "createdAt": "2026-12-04T09:15:24Z",
  "livemode": true
}
```


## Terminate a service

`POST /services/{serviceId}/terminate`

Use this to end a service immediately, for example when your customer leaves. The current period is not refunded. A renewal already issued for a later period is credited, and any wallet credit it took is returned to the wallet. The service becomes terminating with deletesAt, and its server and data are deleted at that time. Answers a terminate action.

Token scope: `services:destructive`.

### Path parameters

- `serviceId` (string (uuid), required): The service's id.

### Headers

- `Clouduxe-Version` (string): The API version to use, such as 2026-12-01. Omit it to use your token's version. pattern ^[0-9]{4}-[0-9]{2}-[0-9]{2}$.
- `Idempotency-Key` (string, required): A unique key for this logical request, 1 to 128 characters of letters, digits, underscore, dot, colon or hyphen; a UUID is best. Retrying with the same key is safe: the change happens once and the retry gets the same answer. Keys are kept 48 hours. pattern ^[A-Za-z0-9_.:-]{1,128}$.

### Body (required)

- `confirm` (string (uuid), required): The service's own id, to confirm you mean this service.

### Responses

- `202`: The termination, started.
- `400`: The request is not valid. Codes: version_invalid, idempotency_key_required, idempotency_key_invalid, invalid_json, parameter_missing, parameter_invalid, parameter_unknown.
- `401`: Authentication failed. Codes: token_missing, token_invalid, token_expired, token_revoked.
- `403`: The token is not allowed to do this. Codes: forbidden, ip_not_allowed, api_access_disabled, scope_missing.
- `404`: Not found. Codes: not_found.
- `409`: The request conflicts with the object's current state. Codes: termination_pending, account_closed, idempotency_in_progress.
- `413`: The request body is too large. Codes: request_too_large.
- `415`: Unsupported media type. Codes: unsupported_media_type.
- `422`: The request is well formed but cannot be carried out. Codes: confirmation_mismatch, idempotency_mismatch.
- `429`: A rate limit was reached. Codes: rate_limited.
- `500`: Unexpected error. Codes: internal_error.
- `503`: Temporarily unavailable. Codes: unavailable, outcome_unknown, limits_unavailable.

### Request

curl:
```bash
curl -X POST https://api.clouduxe.com/v1/services/c3a1f6d2-8b4e-4a9c-b7d5-2e1f0a3c6b8d/terminate \
  -H "Authorization: Bearer $CLOUDUXE_API_KEY" \
  -H "Idempotency-Key: 6f1c2e9a-4b7d-4e3a-9c8f-1a2b3c4d5e6f" \
  -H "Content-Type: application/json" \
  -d '{"confirm":"c3a1f6d2-8b4e-4a9c-b7d5-2e1f0a3c6b8d"}'
```

Node SDK:
```javascript
import { Clouduxe } from "@clouduxe/sdk";

const cx = new Clouduxe({ apiKey: process.env.CLOUDUXE_API_KEY });

const action = await cx.services.terminate("c3a1f6d2-8b4e-4a9c-b7d5-2e1f0a3c6b8d", { confirm: "c3a1f6d2-8b4e-4a9c-b7d5-2e1f0a3c6b8d" });
```

Python:
```python
import os
import requests

res = requests.post(
    "https://api.clouduxe.com/v1/services/c3a1f6d2-8b4e-4a9c-b7d5-2e1f0a3c6b8d/terminate",
    headers={
        "Authorization": f"Bearer {os.environ['CLOUDUXE_API_KEY']}",
        "Idempotency-Key": "6f1c2e9a-4b7d-4e3a-9c8f-1a2b3c4d5e6f",
    },
    json={
        "confirm": "c3a1f6d2-8b4e-4a9c-b7d5-2e1f0a3c6b8d",
    },
)
action = res.json()
```

PHP SDK:
```php
<?php
require 'vendor/autoload.php';

$cx = new \Clouduxe\Clouduxe(['apiKey' => getenv('CLOUDUXE_API_KEY')]);

$action = $cx->services->terminate('c3a1f6d2-8b4e-4a9c-b7d5-2e1f0a3c6b8d', ['confirm' => 'c3a1f6d2-8b4e-4a9c-b7d5-2e1f0a3c6b8d']);
```

fetch:
```javascript
const res = await fetch("https://api.clouduxe.com/v1/services/c3a1f6d2-8b4e-4a9c-b7d5-2e1f0a3c6b8d/terminate", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.CLOUDUXE_API_KEY}`,
    "Idempotency-Key": "6f1c2e9a-4b7d-4e3a-9c8f-1a2b3c4d5e6f",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    confirm: "c3a1f6d2-8b4e-4a9c-b7d5-2e1f0a3c6b8d"
  }),
});
const action = await res.json();
```

### Response (`202`)

```json
{
  "object": "action",
  "id": "f5c8b2a1-6e3d-4c9f-b1a7-3d2e9c0f4b6a",
  "type": "terminate",
  "status": "running",
  "serviceId": "c3a1f6d2-8b4e-4a9c-b7d5-2e1f0a3c6b8d",
  "orderId": null,
  "invoiceId": null,
  "failure": null,
  "secretAvailable": false,
  "secretExpiresAt": null,
  "createdAt": "2026-12-04T09:20:11Z",
  "startedAt": "2026-12-04T09:20:11Z",
  "completedAt": null,
  "livemode": true
}
```
