# Long-running actions

> Restarts, reinstalls, plan changes and new servers answer an action at once; how to follow one to its final state, and how to read a password once.

Source: https://docs.clouduxe.com/api/actions/

Some work takes longer than a request should wait: a restart, a reinstall, a
plan change, a termination, a new server. These answer at once with an
**action**, and the work carries on in the background. You follow the action
until it reaches a final state.

Service actions answer `202` with the action. A new order answers `201`, with
one provision action for each server it creates.

## An action's states

*Figure: An action starts queued, runs, and ends in one of three final states. It can also fail while still queued, when it is refused before it is sent. Unknown means the result was not confirmed in time: check the service itself. Final states never change.*

| Status | Meaning | Final |
| --- | --- | --- |
| `queued` | Recorded, not sent yet. A new Dedicated server or proxy waits here for our team, which can take hours. A paid plan change waits here until it is applied. | no |
| `running` | Sent; waiting for the server to show the result. | no |
| `succeeded` | Confirmed by the server's state. | yes |
| `failed` | Refused or failed. `failure.code` says why. | yes |
| `unknown` | The result was not confirmed within the action's window. Check the service. | yes |

The windows, after which a `running` action becomes `unknown`:

| Action | Window |
| --- | --- |
| Boot, shut down, restart, power off | 2 minutes |
| Reset the root password | 2 minutes |
| Terminate | 10 minutes (the server is then deleted at the service's `deletesAt`) |
| Reinstall | 30 minutes |
| Provision a VPS | 2 hours |
| Provision a Dedicated server or a proxy | none: it waits for our team |
| Plan change | none while queued; it runs once it is applied |

A VPS gets the memory and disk of a new plan at its next power cycle.

`failure.code` is one of `platform_refused`, `platform_unavailable`,
`provisioning_failed`, `order_rejected`, `order_cancelled` or `service_locked`.

## Follow an action

Read it back by its id, at most once every 2 seconds, until its status is final:

`GET /actions/{actionId}` (reference: https://docs.clouduxe.com/api/reference/server-actions/get-action/)

```bash
curl https://api.clouduxe.com/v1/actions/f5c8b2a1-6e3d-4c9f-b1a7-3d2e9c0f4b6a \
  -H "Authorization: Bearer $CLOUDUXE_API_KEY"
```

##### Response (`200`)

```json
{
  "object": "action",
  "id": "f5c8b2a1-6e3d-4c9f-b1a7-3d2e9c0f4b6a",
  "type": "restart",
  "status": "succeeded",
  "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": "2026-12-04T09:20:39Z",
  "livemode": true
}
```

Or list a service's actions:

`GET /services/{serviceId}/actions` (reference: https://docs.clouduxe.com/api/reference/server-actions/list-service-actions/)

```bash
curl https://api.clouduxe.com/v1/services/c3a1f6d2-8b4e-4a9c-b7d5-2e1f0a3c6b8d/actions \
  -H "Authorization: Bearer $CLOUDUXE_API_KEY"
```

#

Instead of polling, you can listen for the `action.completed` webhook, which
carries the action in its final state; see [Webhooks](https://docs.clouduxe.com/api/webhooks/). The SDKs
also have `waitForAction`, which polls every 2 seconds and returns the final
state.

## One-time secrets

Some actions set a server password:

- provisioning a VPS without SSH keys, or with a Windows image;
- reinstalling without SSH keys, or with Windows;
- resetting the root password with `delivery: "api"`.

No write ever answers that password. When the action succeeds, it carries
`secretAvailable: true`, and you read the password from the action:

`GET /actions/{actionId}/secret` (reference: https://docs.clouduxe.com/api/reference/server-actions/get-action-secret/)

```bash
curl https://api.clouduxe.com/v1/actions/f5c8b2a1-6e3d-4c9f-b1a7-3d2e9c0f4b6a/secret \
  -H "Authorization: Bearer $CLOUDUXE_API_KEY"
```

##### Response (`200`)

```json
{
  "object": "action_secret",
  "actionId": "f5c8b2a1-6e3d-4c9f-b1a7-3d2e9c0f4b6a",
  "kind": "server_password",
  "username": "root",
  "password": "hV4qW9zL2mRt8KxP",
  "readsLeft": 4,
  "expiresAt": "2026-12-04T10:20:39Z"
}
```

- Only an owner's token can read it.
- You can read it up to 5 times, so a retry after a lost answer still works,
  until it expires 60 minutes after the action succeeded. Every read is audited.
  After that it answers `410`
  [`secret_unavailable`](https://docs.clouduxe.com/api/errors/#secret_unavailable), which is final.
- As soon as you have stored it, delete it, so it can never be read again:

`DELETE /actions/{actionId}/secret` (reference: https://docs.clouduxe.com/api/reference/server-actions/delete-action-secret/)

```bash
curl -X DELETE https://api.clouduxe.com/v1/actions/f5c8b2a1-6e3d-4c9f-b1a7-3d2e9c0f4b6a/secret \
  -H "Authorization: Bearer $CLOUDUXE_API_KEY" \
  -H "Idempotency-Key: 6f1c2e9a-4b7d-4e3a-9c8f-1a2b3c4d5e6f"
```

#
