# Cancel a service

`POST https://console.advinservers.com/api/v1/client/billing/managed-services/{service}/cancel`

### Overview

Requests cancellation of the service and stops its automatic payments. **Cancelling a server permanently deletes the server and its data.** Cancellation can take effect immediately or at the end of the paid period.

Send `type` using a value from `cancellation_types`. For a server, optionally send `delete_floating_ip_uuids` containing attached secondary floating IPs to cancel too. An empty or omitted list preserves the IPs and their billing. Selected rentals use the chosen cancellation timing and their own billing periods; granted IPs are released when the server is deleted. Cancelling rentals requires `billing.purchase`; deleting granted IPs requires `network.delete`. Primary addresses cannot be selected.

A server that is busy with another operation, such as an upgrade, cannot be cancelled until that operation finishes. The same applies to a floating IP attached to such a server. A suspended server can still be cancelled.

This call records the request; server deletion happens later. If billing fails partway through, completed IP cancellations remain in effect. Returns the service with its pending cancellation.

### Permissions

Requires the `billing.manage` (Manage service billing) permission for the selected team. Resources outside that team return 404.

## Authorization

Send `Authorization: Bearer <token>` with the request. Your API key, sent as a bearer token. Create one in the control panel under API Keys, give it only the permissions the integration needs, and copy it when it is created. It cannot be shown again. Each key is restricted to one owned team. The key determines the team for every request.

## Path parameters

- `service` (string, required): The service ID returned by the billing endpoints.

## Body

Sent as `application/json`.

- `type` (string, required): The type of operation or resource. One of: `immediate`, `end_of_billing`.
- `delete_floating_ip_uuids` (string<uuid>[]): The value of `delete_floating_ip_uuids`. At most 100 items

## Response 200

The record, as a JSON object. There is no envelope.

- `service_id` (integer, required): The service id ID.
- `name` (string, required): The name shown to customers.
- `hostname` (string | null, required): The fully qualified hostname.
- `status` (string | null, required): The value of `status`.
- `billing_cycle` (string | null, required): How often the service renews and is billed.
- `recurring_amount` (string | null, required): The amount charged each billing cycle.
- `currency` (string | null, required): The three-letter currency code used for monetary amounts.
- `server_id` (string | null, required): The server id ID.
- `next_due_date` (string | null, required): The value of `next_due_date`.
- `period` (object | null, required): The value of `period`.
  - `starts_at` (string, required): The date and time for starts at, in UTC.
  - `ends_at` (string, required): The date and time for ends at, in UTC.
  - `total_days` (integer, required): The value of `total_days`.
  - `days_remaining` (integer, required): The value of `days_remaining`.
  - `days_overdue` (integer, required): Zero rather than a negative `days_remaining`, so a caller never has to decide which of the two fields to believe.
  - `remaining_fraction` (number, required): The share of the period still to run.
  - `state` (string, required): `healthy`, `due_soon`, `critical` or `overdue`, named on the server so every surface showing a term agrees about when one has become worth worrying about.
- `autopay` (boolean, required): Whether anything will be charged automatically. The tick or the cross in the Autopay column.
- `autopay_ending` (boolean, required): Autopay that has been turned off but has not stopped yet. Its own state, drawn between the tick and the cross.
- `subscription` (object | null, required): The value of `subscription`.
  - `uuid` (string, required): The uuid UUID.
  - `uuid_short` (string, required): The value of `uuid_short`.
  - `status` (string, required): The payment provider's current status.
  - `next_charge_at` (string | null, required): Null once nothing further will be charged, including for a subscription that is merely winding down.
  - `ends_at` (string | null, required): When an agreed cancellation actually takes effect.
  - `amount` (string | null, required): Excludes tax.
  - `currency` (string | null, required): The three-letter currency code used for monetary amounts.
  - `paypal_account` (string | null, required): The email address of the saved PayPal account it is charged to, when it is one.
  - `payment_card` (string | null, required): The saved card it is charged to, such as "Visa ending 4242", when it is one.
- `cancellation` (object | null, required): The value of `cancellation`.
  - `requested_at` (string | null, required): The date and time for requested at, in UTC.
  - `type` (string | null, required): The type of operation or resource.
  - `type_label` (string | null, required): The value of `type_label`.
  - `reason` (string | null, required): The value of `reason`.
- `can_start_subscription` (boolean, required): Whether the customer can start subscription.
- `can_cancel_subscription` (boolean, required): Whether the customer can cancel subscription.
- `can_change_cycle` (boolean, required): Whether the customer can change cycle.
- `can_cancel_service` (boolean, required): Whether the customer can cancel service.
- `can_withdraw_cancellation` (boolean, required): Whether the customer can withdraw cancellation.
- `immediate_refund` (string | null, required): What stopping this service today would put back on the account, in the currency beside it.
- `pays_from_credit` (boolean, required): Whether renewals of this service are paid out of the account's credit balance where there is one. True unless the customer has turned it off, which is what the balance does by default.
- `can_change_credit` (boolean, required): Whether that can be changed from here. False where the installation does not offer account credit at all, or cannot enforce the answer per service.
- `autopay_provider` (string | null, required): The value of `autopay_provider`.
- `autopay_details` (string | null, required): The value of `autopay_details`.
- `suspension_reason` (string | null, required): The value of `suspension_reason`.
- `autopay_by_account` (boolean, required): Whether it is charged because automatic payments are on for the whole account, which is where they are turned off.
- `credit_by_account` (boolean, required): Whether the credit setting is the account's, chosen on Billing while automatic payments are on for the whole account, rather than this service's own.
- `postpaid_monthly_price` (string | null, required): The value of `postpaid_monthly_price`.

```json
{
  "service_id": 7312,
  "name": "Standard 4 GB",
  "hostname": "lambda-core.blackmesa.example.com",
  "status": "Active",
  "billing_cycle": "Monthly",
  "recurring_amount": "12.00",
  "currency": "USD",
  "server_id": "ecc6f4f1",
  "next_due_date": "2026-10-02",
  "period": {
    "starts_at": "2026-09-02",
    "ends_at": "2026-10-02",
    "total_days": 30,
    "days_remaining": 18,
    "days_overdue": 0,
    "remaining_fraction": 0.6,
    "state": "healthy"
  },
  "autopay": true,
  "autopay_ending": true,
  "subscription": {
    "uuid": "a216c52c-ccea-430f-b3bf-09aaf1025a44",
    "status": "active",
    "next_charge_at": null,
    "ends_at": "2026-10-02T19:15:08+00:00",
    "amount": "12.00",
    "currency": "USD"
  },
  "cancellation": {
    "requested_at": "2026-09-14T16:42:09+00:00",
    "type": "end_of_billing",
    "type_label": "At the end of the billing period",
    "reason": "Consolidating the test chamber workloads onto sector-c-db."
  },
  "can_start_subscription": true,
  "can_cancel_subscription": false,
  "can_change_cycle": true,
  "can_cancel_service": false,
  "can_withdraw_cancellation": true,
  "immediate_refund": "7.20",
  "pays_from_credit": true,
  "can_change_credit": true,
  "autopay_provider": "card",
  "autopay_details": "active",
  "suspension_reason": null,
  "autopay_by_account": true,
  "credit_by_account": true,
  "postpaid_monthly_price": null
}
```

## Errors

- `401`: The key was missing, malformed, revoked, or belongs to an account that no longer exists.
- `403`: Access denied. Check the key's team, permissions and allowed IP addresses. Some actions, such as managing API keys, require a browser session. The response message explains the reason.
- `404`: The resource was not found in the selected team. Resources in another account or team also return 404.
- `422`: A field is missing or invalid, or the resource cannot accept this change in its current state. Check `message` for details. Field validation also includes an `errors` object keyed by field name.
- `429`: Too many requests. The `Retry-After` header says how many seconds to wait. Limits are per account, so several keys on one account share them.

## Example request

```bash
curl --request POST \
  --url 'https://console.advinservers.com/api/v1/client/billing/managed-services/{service}/cancel' \
  --header 'Authorization: Bearer <token>' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{
  "type": "end_of_billing",
  "delete_floating_ip_uuids": []
}'
```
