Getting Started
Learn how to authenticate and make your first request to the RackCorp API
Introduction
The RackCorp API provides programmatic access to manage your infrastructure, services, and resources. This guide walks you through authentication and your first API call.
Authentication
All API requests require authentication using a JWT (JSON Web Token). You can obtain a token either by logging into the RackCorp portal or by using an API key.
Authorization Header (Recommended)
Include your token in the HTTP Authorization header:
Authorization: Bearer YOUR_JWT_TOKEN
Cookie
Alternatively, you can send the token as a cookie:
Cookie: JWTSESSIONID=YOUR_JWT_TOKEN
Base URL
All API requests should be made to:
https://api.rackcorp.net/api/rest/v2.9/json.php
This is the direct REST endpoint. You will typically pass a cmd parameter or use
REST-style paths as documented on each component page.
Your First API Call
Below is a simple example that retrieves a load balancer using different languages.
cURL
curl -X GET "https://api.rackcorp.net/api/rest/v2.9/json.php?cmd=loadbalancer.get&id=123" \ -H "Authorization: Bearer YOUR_JWT_TOKEN"
PHP
<?php
$ch = curl_init('https://api.rackcorp.net/api/rest/v2.9/json.php?cmd=loadbalancer.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);
if ($data['code'] === 'OK') {
$lb = $data['loadbalancer'];
echo 'Load Balancer: ' . $lb['name'];
} else {
echo 'Error: ' . $data['message'];
}
?>
Python
import requests
response = requests.get(
"https://api.rackcorp.net/api/rest/v2.9/json.php",
params={"cmd": "loadbalancer.get", "id": 123},
headers={"Authorization": "Bearer YOUR_JWT_TOKEN"}
)
data = response.json()
if data["code"] == "OK":
lb = data["loadbalancer"]
print("Load Balancer:", lb["name"])
else:
print("Error:", data["message"])
Next Steps
- Read the JWT Tokens page for detailed authentication flows
- Explore component docs such as Load Balancer or Device
- Use the code examples on each page to integrate with your application