Core Model
The public API uses token authentication. Read operations return data directly; heavier operations return tasks.
This page is not only an endpoint reference. It explains integration order, required headers, the task-based flow, and shows the same ideas in PHP, Node.js, and Python.
The public API uses token authentication. Read operations return data directly; heavier operations return tasks.
Use `Authorization: Bearer ...` for auth. Mutating requests also require `Idempotency-Key`.
After provision, format or snapshot calls, track progress from task endpoints.
If you do not want to copy code blocks manually, download the prepared client files and Postman collection directly.
Plain PHP + cURL starter client.
Fetch-based starter client.
Requests-based starter client.
Create an API client from the admin panel. The token is only shown in plain text once.
For this installation the base URL is currently `https://denemevm.yamanhosting.com`. Because the API prefix is `/api/v1`, the ping endpoint becomes `https://denemevm.yamanhosting.com/api/v1/ping`.
Use `GET /api/v1/ping` as the first live request. Solve auth, header and networking issues here first.
Use `GET /api/v1/servers` as the first real data-read flow. Then continue with `GET /api/v1/servers/{server}` and task endpoints as needed.
Send `Idempotency-Key` on provision, format, power and snapshot requests. This prevents the same operation from running twice during timeouts or retries.
Authorization: Bearer yvm_live_xxxxxxxxx
X-Request-Id: ext-req-1001
Useful for support and log tracing. It is also returned in the response.
Idempotency-Key: order-1001-format
Required only on mutating requests.
This section is written for developers who already know PHP but need guidance on integrating the API. You can start with raw `curl` and later move to a client such as Guzzle.
<?php
function yamanvmRequest(
string $method,
string $path,
string $token,
?array $payload = null,
?string $idempotencyKey = null
): array {
$baseUrl = 'https://yamanvm.yamanhosting.com';
$headers = [
'Authorization: Bearer ' . $token,
'Accept: application/json',
'X-Request-Id: php-' . uniqid(),
];
if ($idempotencyKey !== null) {
$headers[] = 'Idempotency-Key: ' . $idempotencyKey;
}
if ($payload !== null) {
$headers[] = 'Content-Type: application/json';
}
$ch = curl_init(rtrim($baseUrl, '/') . $path);
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => strtoupper($method),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_TIMEOUT => 30,
]);
if ($payload !== null) {
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload, JSON_UNESCAPED_SLASHES));
}
$raw = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($raw === false) {
throw new RuntimeException('Curl error: ' . curl_error($ch));
}
curl_close($ch);
return [
'status' => $status,
'body' => json_decode($raw, true),
'raw' => $raw,
];
}
<?php
$token = 'yvm_live_xxxxxxxxxxxxxxxxx';
$result = yamanvmRequest('GET', '/api/v1/ping', $token);
if ($result['status'] !== 200) {
print_r($result['body']);
exit('Ping failed');
}
print_r($result['body']);
<?php
$token = 'yvm_live_xxxxxxxxxxxxxxxxx';
$result = yamanvmRequest('GET', '/api/v1/servers?per_page=10', $token);
foreach (($result['body']['servers'] ?? []) as $server) {
echo $server['id'] . ' - ' . $server['name'] . PHP_EOL;
}
<?php
$token = 'yvm_live_xxxxxxxxxxxxxxxxx';
$serverId = 3;
$result = yamanvmRequest('GET', "/api/v1/servers/{$serverId}/tasks", $token);
foreach (($result['body']['tasks'] ?? []) as $task) {
echo sprintf(
"#%d %s %s %d%%\n",
$task['id'],
$task['type'],
$task['status'],
$task['progress_percent']
);
}
<?php
$token = 'yvm_live_xxxxxxxxxxxxxxxxx';
$serverId = 3;
$result = yamanvmRequest(
'POST',
"/api/v1/servers/{$serverId}/power",
$token,
['action' => 'restart'],
'srv-3-restart-1001'
);
print_r($result['body']);
<?php
$token = 'yvm_live_xxxxxxxxxxxxxxxxx';
$payload = [
'template_id' => 7,
'host_id' => 2,
'disk_id' => 4,
'cpu_count' => 2,
'ram_gb' => 4,
'disk_gb' => 80,
'ip_count' => 1,
'ip_pool_id' => 1,
'snapshot_limit' => 3,
];
$result = yamanvmRequest(
'POST',
'/api/v1/provisioning/requests',
$token,
$payload,
'order-1001-provision'
);
print_r($result['body']);
// Sonraki adım:
// response içindeki server.id veya task bilgisiyle takip akışına geçin.
const baseUrl = 'https://yamanvm.yamanhosting.com';
const token = 'yvm_live_xxxxxxxxxxxxxxxxx';
async function yamanvmRequest(method, path, payload = null, idempotencyKey = null) {
const headers = {
Authorization: `Bearer ${token}`,
Accept: 'application/json',
'X-Request-Id': `node-${Date.now()}`,
};
if (idempotencyKey) {
headers['Idempotency-Key'] = idempotencyKey;
}
if (payload) {
headers['Content-Type'] = 'application/json';
}
const response = await fetch(`${baseUrl}${path}`, {
method,
headers,
body: payload ? JSON.stringify(payload) : undefined,
});
return {
status: response.status,
body: await response.json(),
};
}
const ping = await yamanvmRequest('GET', '/api/v1/ping');
console.log(ping.status, ping.body);
const formatResponse = await yamanvmRequest(
'POST',
'/api/v1/servers/3/format',
{
template_id: 7,
admin_password: 'NewPass!123',
confirm_reset: true,
},
'srv-3-format-1001'
);
console.log(formatResponse.status, formatResponse.body);
import time
import requests
BASE_URL = "https://yamanvm.yamanhosting.com"
TOKEN = "yvm_live_xxxxxxxxxxxxxxxxx"
def yamanvm_request(method, path, payload=None, idempotency_key=None):
headers = {
"Authorization": f"Bearer {TOKEN}",
"Accept": "application/json",
"X-Request-Id": f"python-{int(time.time())}",
}
if idempotency_key:
headers["Idempotency-Key"] = idempotency_key
response = requests.request(
method,
f"{BASE_URL}{path}",
json=payload,
headers=headers,
timeout=30,
)
return response.status_code, response.json()
status, body = yamanvm_request("GET", "/api/v1/servers/3/tasks")
print(status)
print(body)
status, body = yamanvm_request(
"POST",
"/api/v1/servers/3/snapshots",
{
"name": "release-before-upgrade",
"description": "Checkpoint before upgrade",
},
"srv-3-snapshot-1001",
)
print(status)
print(body)
The token is missing or invalid. Fix authentication first.
The token is valid but the required scope is missing, or IP restriction is active.
The payload violates validation or business rules. Check the `errors` field.