VirtFusion Global API
You can use this API to access all Administrator API endpoints, such as the server API to deploy and manage servers, or the system API to configure and manage the system.
The API is organized around REST. All requests should be made over SSL. All request and response bodies, including errors, are encoded in JSON.
Base URL
https://cp.domain.com/api/v1Replace the host with your Control Server's address. Every path in this reference is relative to it.
Authentication
Every request carries an API token as a bearer token. Tokens are created under Configuration → API in the admin area, where each token can be restricted to a list of IP addresses, given a rate limit and an expiry.
Authorization: Bearer <token>
Accept: application/jsonA missing, invalid or expired token returns 401 with no body.
Responses
Successful responses wrap their payload in data. Paged lists use the paginator envelope described under Pagination; the results and page query parameters move through the set. Errors return a JSON body with an errors array, or msg on the older endpoints. Every operation page lists the statuses it can return.
| Status | Meaning |
|---|---|
200 | Done. The payload is under data. |
201 | Created. The new record is under data. |
204 | Done. There is no response body. |
401 | The token is missing, invalid or expired. There is no body. |
403 | The token does not have the permission the endpoint requires. |
404 | The record the path names does not exist. |
409 | The request conflicts with the current state, such as an action on a server that is not in the right state for it. |
422 | The input was rejected. errors names what was wrong. |
423 | The server is locked: tasks are pending in its queue, or Do Not Disturb is on. Retry later. |
424 | A dependent step failed, such as a profile or pack that could not be applied. |
429 | Too many requests. See Rate limiting below. |
503 | The server's hypervisor is in maintenance mode, or a status check failed. |
Token permissions
A token carries a list of permissions, chosen when it is created under Configuration → API. The list is an opt-in set of the operations considered dangerous, and a token is allowed every operation that is not on it. Ticking nothing therefore grants everything except the listed operations, and ticking an operation grants that one as well. An operation that requires a permission says so on its own page and answers 403 without it.
| Permission | Operations it covers |
|---|---|
| Create Server | Create a server |
| Build Server | Build a server |
| Change Server Package | Change a server's package |
| Delete Server | Delete a server |
| Reset Server Password | Reset a server's password |
| Rescue Server | Start and end a rescue session, and read its login details |
| Elevate Server | Elevate a server, commit a drive and discard an elevation |
| Delete Server Disk | Delete a disk from a server |
| Create User | Create a user |
| Reset User Password | Reset a user's password |
| Authenticate User | Create an authentication token for a user or one of their servers |
| Modify User | Modify a user |
| Delete User | Delete a user |
Rate limiting
Two limits apply, both measured per minute.
Requests per token
Each token has a Rate Limit (RPM), set when the token is created or edited under Configuration → API. The default is 5000 requests per minute; 0 removes the limit for that token. Every response carries the token's standing:
| Header | Meaning |
|---|---|
X-RateLimit-Limit | The token's requests per minute. |
X-RateLimit-Remaining | Requests left in the current minute. |
X-RateLimit-Reset | Unix timestamp at which the minute resets. |
Once the limit is reached, requests are refused with 429, the body {"errors": ["Too Many Requests"]} and a Retry-After header giving the seconds to wait. Refused requests do not count against the limit, so a client that honours Retry-After recovers at the reset.
Failed authentication per address
An address that fails authentication 10 times within a minute is refused for the rest of that minute with 429, a Retry-After header and the body {"errors": ["Too many authentication attempts. Try again later."], "retry_after_seconds": 42}. A successful request clears the count.