Device API
Manage devices (servers, virtual machines, etc.) programmatically
Overview
The Device API allows you to retrieve information about devices (dedicated servers, virtual machines, and other infrastructure) in your account. Devices can be filtered by various criteria including customer, data center, IP address, and more.
GET Get Device
Retrieve a single device by its ID.
Request
{
"cmd": "device.get",
"id": 123
}
<?php
$ch = curl_init('https://api.rackcorp.net/api/rest/v2.9/json.php?cmd=device.get&id=123');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_JWT_TOKEN'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
?>
import requests
response = requests.get(
'https://api.rackcorp.net/api/rest/v2.9/json.php',
params={
'cmd': 'device.get',
'id': 123
},
headers={
'Authorization': 'Bearer YOUR_JWT_TOKEN'
}
)
data = response.json()
curl -X GET "https://api.rackcorp.net/api/rest/v2.9/json.php?cmd=device.get&id=123" \ -H "Authorization: Bearer YOUR_JWT_TOKEN"
GET https://api.rackcorp.net/api/rest/v2.9/json.php?cmd=device.get&id=123 Authorization: Bearer YOUR_JWT_TOKEN
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
cmd |
string | Yes | Must be "device.get" |
id |
integer | Yes | Device ID |
Response
{
"code": "OK",
"device": {
"id": 123,
"name": "server-01",
"type": "VIRTUAL_VMW",
"primaryIP": "203.0.113.10",
"stdName": "Example Corp",
"customerid": 456,
"dcName": "SYD01",
"hostDeviceName": "host-01",
"vmhostName": "vmhost-01",
"status": "ACTIVE",
"operationalStatus": "RUNNING",
"cpu": 4,
"ram": 8192,
"storage": 100,
"dateCreated": 1699123456,
"dateModified": 1699123456
}
}
GET List Devices
Retrieve a list of devices with optional filtering, pagination, and sorting.
Request
{
"cmd": "device.getall",
"resStart": 0,
"resWindow": 50,
"displaymode": true,
"skipassets": true,
"includeDetails": true,
"keyword": "search term",
"stdName": "Example Corp",
"name": "server-01",
"ipAddress": "203.0.113.10",
"hostDeviceName": "host-01",
"dcName": "SYD01",
"ordering": [
{
"field": "name",
"dir": "ASC"
}
]
}
<?php
$params = http_build_query([
'cmd' => 'device.getall',
'resStart' => 0,
'resWindow' => 50,
'displaymode' => 'true',
'skipassets' => 'true',
'includeDetails' => 'true',
'keyword' => 'search term',
'dcName' => 'SYD01'
]);
$ch = curl_init('https://api.rackcorp.net/api/rest/v2.9/json.php?' . $params);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_JWT_TOKEN'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
?>
import requests
response = requests.get(
'https://api.rackcorp.net/api/rest/v2.9/json.php',
params={
'cmd': 'device.getall',
'resStart': 0,
'resWindow': 50,
'displaymode': True,
'skipassets': True,
'includeDetails': True,
'keyword': 'search term',
'dcName': 'SYD01'
},
headers={
'Authorization': 'Bearer YOUR_JWT_TOKEN'
}
)
data = response.json()
curl -X GET "https://api.rackcorp.net/api/rest/v2.9/json.php?cmd=device.getall&resStart=0&resWindow=50&displaymode=true&skipassets=true&includeDetails=true&keyword=search%20term&dcName=SYD01" \ -H "Authorization: Bearer YOUR_JWT_TOKEN"
GET https://api.rackcorp.net/api/rest/v2.9/json.php?cmd=device.getall&resStart=0&resWindow=50&displaymode=true&skipassets=true&includeDetails=true&keyword=search%20term&dcName=SYD01 Authorization: Bearer YOUR_JWT_TOKEN
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
cmd |
string | Yes | Must be "device.getall" |
resStart |
integer | No | Pagination start offset (default: 0) |
resWindow |
integer | No | Number of results per page (default: 20, minimum: 20) |
displaymode |
boolean | No | If true, returns data optimized for display (default: false) |
skipassets |
boolean | No | If true, skips asset information for faster responses (default: false) |
includeDetails |
boolean | No | If true, includes detailed device information (CPU, RAM, storage, etc.) |
keyword |
string | No | Search term to filter results (searches across multiple fields) |
stdName |
string | No | Filter by customer standard name |
customername |
string | No | Filter by customer name |
name |
string | No | Filter by device name |
ipAddress |
string | No | Filter by primary IP address |
hostDeviceName |
string | No | Filter by host device name |
vmhostName |
string | No | Filter by VM host name |
dcName |
string | No | Filter by data center name |
subject |
string | No | Additional search term |
ordering |
array | No | Array of sort objects. Each object has field and dir (ASC/DESC). Allowed fields: id, name, stdName, primaryIP, vmhostName, dcName |
Response
{
"code": "OK",
"count": 25,
"devices": [
{
"id": 123,
"name": "server-01",
"type": "VIRTUAL_VMW",
"primaryIP": "203.0.113.10",
"stdName": "Example Corp",
"customerid": 456,
"dcName": "SYD01",
"status": "ACTIVE",
"operationalStatus": "RUNNING",
"cpu": 4,
"ram": 8192,
"storage": 100
}
]
}
Device Object Fields
| Field | Type | Description |
|---|---|---|
id |
integer | Unique device identifier |
name |
string | Device name |
type |
string | Device type (e.g., "VIRTUAL_VMW", "DEDICATED", "CLOUD") |
primaryIP |
string | Primary IP address |
stdName |
string | Customer standard name |
customerid |
integer | Customer ID |
dcName |
string | Data center name |
hostDeviceName |
string | Host device name (for virtual machines) |
vmhostName |
string | VM host name |
status |
string | Device status (e.g., "ACTIVE", "INACTIVE") |
operationalStatus |
string | Operational status (e.g., "RUNNING", "STOPPED") |
cpu |
integer | Number of CPU cores |
ram |
integer | RAM in MB |
storage |
integer | Storage in GB |
dateCreated |
integer | Unix timestamp of creation date |
dateModified |
integer | Unix timestamp of last modification |
Error Responses
If an error occurs, the API will return a response with code: "FAULT":
{
"code": "FAULT",
"message": "Error message",
"error": {
"field1": "Error message 1",
"field2": "Error message 2"
}
}
Common error scenarios:
- Invalid device ID
- Permission denied
- Device not found