From d56bba0a7047f3860651f1e7a0de8ef4b0353930 Mon Sep 17 00:00:00 2001 From: AjdinDev Date: Wed, 13 Aug 2025 19:49:59 +0200 Subject: [PATCH] Add missing Client API endpoints --- docs/api/client/account.md | 674 ++++++++++++++++++++++++++++++++ docs/api/client/files.md | 772 +++++++++++++++++++++++++++++++++++++ docs/api/client/servers.md | 750 +++++++++++++++++++++++++++++++++++ 3 files changed, 2196 insertions(+) diff --git a/docs/api/client/account.md b/docs/api/client/account.md index b73113f..7f8551b 100644 --- a/docs/api/client/account.md +++ b/docs/api/client/account.md @@ -723,6 +723,680 @@ Returns empty response body with status code 204. +--- + +## Activity Logs + +### List Account Activity + +Retrieve a list of recent account activity and audit logs. + +**`GET /api/client/account/activity`** + +#### Example Request + +get('https://your-panel.com/api/client/account/activity', [ + 'headers' => [ + 'Authorization' => 'Bearer ptlc_YOUR_API_KEY', + 'Accept' => 'Application/vnd.pterodactyl.v1+json', + 'Content-Type' => 'application/json' + ] +]); + +$data = json_decode($response->getBody(), true); +print_r($data); +?>`, + go: `package main + +import ( + "encoding/json" + "fmt" + "net/http" +) + +func main() { + client := &http.Client{} + req, _ := http.NewRequest("GET", "https://your-panel.com/api/client/account/activity", nil) + req.Header.Add("Authorization", "Bearer ptlc_YOUR_API_KEY") + req.Header.Add("Accept", "Application/vnd.pterodactyl.v1+json") + req.Header.Add("Content-Type", "application/json") + + resp, _ := client.Do(req) + defer resp.Body.Close() + + var result map[string]interface{} + json.NewDecoder(resp.Body).Decode(&result) + fmt.Println("Activity logs:", result) +}`, + java: `import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.net.URI; + +HttpClient client = HttpClient.newHttpClient(); +HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create("https://your-panel.com/api/client/account/activity")) + .header("Authorization", "Bearer ptlc_YOUR_API_KEY") + .header("Accept", "Application/vnd.pterodactyl.v1+json") + .header("Content-Type", "application/json") + .GET() + .build(); + +HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); +System.out.println("Activity logs: " + response.body());`, + csharp: `using System.Net.Http; +using System.Threading.Tasks; + +var client = new HttpClient(); +client.DefaultRequestHeaders.Add("Authorization", "Bearer ptlc_YOUR_API_KEY"); +client.DefaultRequestHeaders.Add("Accept", "Application/vnd.pterodactyl.v1+json"); + +var response = await client.GetAsync("https://your-panel.com/api/client/account/activity"); +var content = await response.Content.ReadAsStringAsync(); +Console.WriteLine("Activity logs: " + content);`, + ruby: `require 'net/http' +require 'json' + +uri = URI('https://your-panel.com/api/client/account/activity') +http = Net::HTTP.new(uri.host, uri.port) +http.use_ssl = true + +request = Net::HTTP::Get.new(uri) +request['Authorization'] = 'Bearer ptlc_YOUR_API_KEY' +request['Accept'] = 'Application/vnd.pterodactyl.v1+json' +request['Content-Type'] = 'application/json' + +response = http.request(request) +puts "Activity logs: #{JSON.parse(response.body)}"` + }} +/> + +#### Example Response + +```json +{ + "object": "list", + "data": [ + { + "object": "activity_log", + "attributes": { + "id": "2c5608f7-9798-4db6-becd-f3c4b63e1a7f", + "batch": null, + "event": "user:account.email-changed", + "is_api": false, + "ip": "192.168.1.100", + "description": "Updated account email from user@old.com to user@new.com", + "properties": { + "old_email": "user@old.com", + "new_email": "user@new.com" + }, + "has_additional_metadata": true, + "timestamp": "2024-01-15T10:30:00.000000Z" + } + }, + { + "object": "activity_log", + "attributes": { + "id": "1a2b3c4d-5e6f-7g8h-9i0j-k1l2m3n4o5p6", + "batch": null, + "event": "user:account.password-changed", + "is_api": false, + "ip": "192.168.1.100", + "description": "Account password was changed", + "properties": {}, + "has_additional_metadata": false, + "timestamp": "2024-01-14T15:45:00.000000Z" + } + } + ], + "meta": { + "pagination": { + "total": 45, + "count": 2, + "per_page": 50, + "current_page": 1, + "total_pages": 1, + "links": {} + } + } +} +``` + +--- + +## SSH Keys + +### List SSH Keys + +Retrieve a list of SSH public keys associated with your account. + +**`GET /api/client/account/ssh-keys`** + +#### Example Request + +get('https://your-panel.com/api/client/account/ssh-keys', [ + 'headers' => [ + 'Authorization' => 'Bearer ptlc_YOUR_API_KEY', + 'Accept' => 'Application/vnd.pterodactyl.v1+json', + 'Content-Type' => 'application/json' + ] +]); + +$data = json_decode($response->getBody(), true); +print_r($data); +?>`, + go: `package main + +import ( + "encoding/json" + "fmt" + "net/http" +) + +func main() { + client := &http.Client{} + req, _ := http.NewRequest("GET", "https://your-panel.com/api/client/account/ssh-keys", nil) + req.Header.Add("Authorization", "Bearer ptlc_YOUR_API_KEY") + req.Header.Add("Accept", "Application/vnd.pterodactyl.v1+json") + req.Header.Add("Content-Type", "application/json") + + resp, _ := client.Do(req) + defer resp.Body.Close() + + var result map[string]interface{} + json.NewDecoder(resp.Body).Decode(&result) + fmt.Println("SSH keys:", result) +}`, + java: `import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.net.URI; + +HttpClient client = HttpClient.newHttpClient(); +HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create("https://your-panel.com/api/client/account/ssh-keys")) + .header("Authorization", "Bearer ptlc_YOUR_API_KEY") + .header("Accept", "Application/vnd.pterodactyl.v1+json") + .header("Content-Type", "application/json") + .GET() + .build(); + +HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); +System.out.println("SSH keys: " + response.body());`, + csharp: `using System.Net.Http; +using System.Threading.Tasks; + +var client = new HttpClient(); +client.DefaultRequestHeaders.Add("Authorization", "Bearer ptlc_YOUR_API_KEY"); +client.DefaultRequestHeaders.Add("Accept", "Application/vnd.pterodactyl.v1+json"); + +var response = await client.GetAsync("https://your-panel.com/api/client/account/ssh-keys"); +var content = await response.Content.ReadAsStringAsync(); +Console.WriteLine("SSH keys: " + content);`, + ruby: `require 'net/http' +require 'json' + +uri = URI('https://your-panel.com/api/client/account/ssh-keys') +http = Net::HTTP.new(uri.host, uri.port) +http.use_ssl = true + +request = Net::HTTP::Get.new(uri) +request['Authorization'] = 'Bearer ptlc_YOUR_API_KEY' +request['Accept'] = 'Application/vnd.pterodactyl.v1+json' +request['Content-Type'] = 'application/json' + +response = http.request(request) +puts "SSH keys: #{JSON.parse(response.body)}"` + }} +/> + +#### Example Response + +```json +{ + "object": "list", + "data": [ + { + "object": "ssh_key", + "attributes": { + "name": "My Laptop", + "fingerprint": "SHA256:abcd1234efgh5678ijkl9012mnop3456qrst7890uvwx", + "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC...", + "created_at": "2024-01-10T12:00:00.000000Z" + } + }, + { + "object": "ssh_key", + "attributes": { + "name": "Work Desktop", + "fingerprint": "SHA256:zyxw9876vuts5432rqpo1098nmlk7654jihg3210fedc", + "public_key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ...", + "created_at": "2024-01-05T09:30:00.000000Z" + } + } + ] +} +``` + +### Add SSH Key + +Add a new SSH public key to your account. + +**`POST /api/client/account/ssh-keys`** + +#### Request Body + +| Field | Type | Required | Description | +|-------|------|----------|-------------| +| `name` | string | Yes | Descriptive name for the SSH key | +| `public_key` | string | Yes | SSH public key content | + +#### Example Request + + 'My New Key', + 'public_key' => 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC...' +]; + +$response = $client->post('https://your-panel.com/api/client/account/ssh-keys', [ + 'headers' => [ + 'Authorization' => 'Bearer ptlc_YOUR_API_KEY', + 'Accept' => 'Application/vnd.pterodactyl.v1+json', + 'Content-Type' => 'application/json' + ], + 'json' => $sshKeyData +]); + +$data = json_decode($response->getBody(), true); +print_r($data); +?>`, + go: `package main + +import ( + "bytes" + "encoding/json" + "fmt" + "net/http" +) + +func main() { + sshKeyData := map[string]interface{}{ + "name": "My New Key", + "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC...", + } + + jsonData, _ := json.Marshal(sshKeyData) + + client := &http.Client{} + req, _ := http.NewRequest("POST", "https://your-panel.com/api/client/account/ssh-keys", bytes.NewBuffer(jsonData)) + req.Header.Add("Authorization", "Bearer ptlc_YOUR_API_KEY") + req.Header.Add("Accept", "Application/vnd.pterodactyl.v1+json") + req.Header.Add("Content-Type", "application/json") + + resp, _ := client.Do(req) + defer resp.Body.Close() + + var result map[string]interface{} + json.NewDecoder(resp.Body).Decode(&result) + fmt.Println("SSH key added:", result) +}`, + java: `import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.net.URI; + +String jsonData = """ +{ + "name": "My New Key", + "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC..." +} +"""; + +HttpClient client = HttpClient.newHttpClient(); +HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create("https://your-panel.com/api/client/account/ssh-keys")) + .header("Authorization", "Bearer ptlc_YOUR_API_KEY") + .header("Accept", "Application/vnd.pterodactyl.v1+json") + .header("Content-Type", "application/json") + .POST(HttpRequest.BodyPublishers.ofString(jsonData)) + .build(); + +HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); +System.out.println("SSH key added: " + response.body());`, + csharp: `using System.Net.Http; +using System.Text; +using System.Text.Json; +using System.Threading.Tasks; + +var client = new HttpClient(); +client.DefaultRequestHeaders.Add("Authorization", "Bearer ptlc_YOUR_API_KEY"); +client.DefaultRequestHeaders.Add("Accept", "Application/vnd.pterodactyl.v1+json"); + +var sshKeyData = new { + name = "My New Key", + public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC..." +}; + +var json = JsonSerializer.Serialize(sshKeyData); +var content = new StringContent(json, Encoding.UTF8, "application/json"); + +var response = await client.PostAsync("https://your-panel.com/api/client/account/ssh-keys", content); +var responseContent = await response.Content.ReadAsStringAsync(); +Console.WriteLine("SSH key added: " + responseContent);`, + ruby: `require 'net/http' +require 'json' + +ssh_key_data = { + name: 'My New Key', + public_key: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC...' +} + +uri = URI('https://your-panel.com/api/client/account/ssh-keys') +http = Net::HTTP.new(uri.host, uri.port) +http.use_ssl = true + +request = Net::HTTP::Post.new(uri) +request['Authorization'] = 'Bearer ptlc_YOUR_API_KEY' +request['Accept'] = 'Application/vnd.pterodactyl.v1+json' +request['Content-Type'] = 'application/json' +request.body = ssh_key_data.to_json + +response = http.request(request) +puts "SSH key added: #{JSON.parse(response.body)}"` + }} +/> + +#### Example Response + +```json +{ + "object": "ssh_key", + "attributes": { + "name": "My New Key", + "fingerprint": "SHA256:newkey1234fingerprint5678hash9012", + "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC...", + "created_at": "2024-01-20T14:30:00.000000Z" + } +} +``` + +### Remove SSH Key + +Remove an SSH public key from your account. + +**`POST /api/client/account/ssh-keys/remove`** + +#### Request Body + +| Field | Type | Required | Description | +|-------|------|----------|-------------| +| `fingerprint` | string | Yes | SSH key fingerprint to remove | + +#### Example Request + + 'SHA256:abcd1234efgh5678ijkl9012mnop3456qrst7890uvwx' +]; + +$response = $client->post('https://your-panel.com/api/client/account/ssh-keys/remove', [ + 'headers' => [ + 'Authorization' => 'Bearer ptlc_YOUR_API_KEY', + 'Accept' => 'Application/vnd.pterodactyl.v1+json', + 'Content-Type' => 'application/json' + ], + 'json' => $removeData +]); + +echo "SSH key removed"; +?>`, + go: `package main + +import ( + "bytes" + "encoding/json" + "fmt" + "net/http" +) + +func main() { + removeData := map[string]interface{}{ + "fingerprint": "SHA256:abcd1234efgh5678ijkl9012mnop3456qrst7890uvwx", + } + + jsonData, _ := json.Marshal(removeData) + + client := &http.Client{} + req, _ := http.NewRequest("POST", "https://your-panel.com/api/client/account/ssh-keys/remove", bytes.NewBuffer(jsonData)) + req.Header.Add("Authorization", "Bearer ptlc_YOUR_API_KEY") + req.Header.Add("Accept", "Application/vnd.pterodactyl.v1+json") + req.Header.Add("Content-Type", "application/json") + + resp, _ := client.Do(req) + defer resp.Body.Close() + + fmt.Println("SSH key removed") +}`, + java: `import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.net.URI; + +String jsonData = """ +{ + "fingerprint": "SHA256:abcd1234efgh5678ijkl9012mnop3456qrst7890uvwx" +} +"""; + +HttpClient client = HttpClient.newHttpClient(); +HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create("https://your-panel.com/api/client/account/ssh-keys/remove")) + .header("Authorization", "Bearer ptlc_YOUR_API_KEY") + .header("Accept", "Application/vnd.pterodactyl.v1+json") + .header("Content-Type", "application/json") + .POST(HttpRequest.BodyPublishers.ofString(jsonData)) + .build(); + +HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); +System.out.println("SSH key removed");`, + csharp: `using System.Net.Http; +using System.Text; +using System.Text.Json; +using System.Threading.Tasks; + +var client = new HttpClient(); +client.DefaultRequestHeaders.Add("Authorization", "Bearer ptlc_YOUR_API_KEY"); +client.DefaultRequestHeaders.Add("Accept", "Application/vnd.pterodactyl.v1+json"); + +var removeData = new { + fingerprint = "SHA256:abcd1234efgh5678ijkl9012mnop3456qrst7890uvwx" +}; + +var json = JsonSerializer.Serialize(removeData); +var content = new StringContent(json, Encoding.UTF8, "application/json"); + +var response = await client.PostAsync("https://your-panel.com/api/client/account/ssh-keys/remove", content); +Console.WriteLine("SSH key removed");`, + ruby: `require 'net/http' +require 'json' + +remove_data = { + fingerprint: 'SHA256:abcd1234efgh5678ijkl9012mnop3456qrst7890uvwx' +} + +uri = URI('https://your-panel.com/api/client/account/ssh-keys/remove') +http = Net::HTTP.new(uri.host, uri.port) +http.use_ssl = true + +request = Net::HTTP::Post.new(uri) +request['Authorization'] = 'Bearer ptlc_YOUR_API_KEY' +request['Accept'] = 'Application/vnd.pterodactyl.v1+json' +request['Content-Type'] = 'application/json' +request.body = remove_data.to_json + +response = http.request(request) +puts "SSH key removed"` + }} +/> + +#### Success Response (204) + +Returns empty response body with status code 204. + --- ## Common Error Codes diff --git a/docs/api/client/files.md b/docs/api/client/files.md index 189d797..29d35cf 100644 --- a/docs/api/client/files.md +++ b/docs/api/client/files.md @@ -1347,6 +1347,778 @@ Returns empty response body with status code 204. --- +## Rename File + +Rename a file or directory on the server. + +**`PUT /api/client/servers/{server}/files/rename`** + +### Request Body + +| Field | Type | Required | Description | +|-------|------|----------|-------------| +| `root` | string | Yes | Directory containing the file | +| `files` | array | Yes | Array containing old and new names | + +### Example Request + + '/', + 'files' => [ + [ + 'from' => 'old-name.txt', + 'to' => 'new-name.txt' + ] + ] +]; + +$response = $client->put("https://your-panel.com/api/client/servers/{$serverId}/files/rename", [ + 'headers' => [ + 'Authorization' => 'Bearer ptlc_YOUR_API_KEY', + 'Accept' => 'Application/vnd.pterodactyl.v1+json', + 'Content-Type' => 'application/json' + ], + 'json' => $renameData +]); + +echo "File renamed successfully"; +?>`, + go: `package main + +import ( + "bytes" + "encoding/json" + "fmt" + "net/http" +) + +func main() { + serverId := "d3aac109" + renameData := map[string]interface{}{ + "root": "/", + "files": []map[string]string{ + { + "from": "old-name.txt", + "to": "new-name.txt", + }, + }, + } + + jsonData, _ := json.Marshal(renameData) + + client := &http.Client{} + req, _ := http.NewRequest("PUT", fmt.Sprintf("https://your-panel.com/api/client/servers/%s/files/rename", serverId), bytes.NewBuffer(jsonData)) + req.Header.Add("Authorization", "Bearer ptlc_YOUR_API_KEY") + req.Header.Add("Accept", "Application/vnd.pterodactyl.v1+json") + req.Header.Add("Content-Type", "application/json") + + resp, _ := client.Do(req) + defer resp.Body.Close() + + fmt.Println("File renamed successfully") +}`, + java: `import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.net.URI; + +String serverId = "d3aac109"; +String jsonData = """ +{ + "root": "/", + "files": [ + { + "from": "old-name.txt", + "to": "new-name.txt" + } + ] +} +"""; + +HttpClient client = HttpClient.newHttpClient(); +HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create("https://your-panel.com/api/client/servers/" + serverId + "/files/rename")) + .header("Authorization", "Bearer ptlc_YOUR_API_KEY") + .header("Accept", "Application/vnd.pterodactyl.v1+json") + .header("Content-Type", "application/json") + .PUT(HttpRequest.BodyPublishers.ofString(jsonData)) + .build(); + +HttpResponse response = client.send(request, + HttpResponse.BodyHandlers.ofString()); +System.out.println("File renamed successfully");`, + csharp: `using System.Net.Http; +using System.Text; +using System.Text.Json; +using System.Threading.Tasks; + +var serverId = "d3aac109"; +var client = new HttpClient(); +client.DefaultRequestHeaders.Add("Authorization", "Bearer ptlc_YOUR_API_KEY"); +client.DefaultRequestHeaders.Add("Accept", "Application/vnd.pterodactyl.v1+json"); + +var renameData = new { + root = "/", + files = new[] { + new { from = "old-name.txt", to = "new-name.txt" } + } +}; + +var json = JsonSerializer.Serialize(renameData); +var content = new StringContent(json, Encoding.UTF8, "application/json"); + +var response = await client.PutAsync($"https://your-panel.com/api/client/servers/{serverId}/files/rename", content); +Console.WriteLine("File renamed successfully");`, + ruby: `require 'net/http' +require 'json' + +server_id = 'd3aac109' +rename_data = { + root: '/', + files: [ + { + from: 'old-name.txt', + to: 'new-name.txt' + } + ] +} + +uri = URI("https://your-panel.com/api/client/servers/#{server_id}/files/rename") +http = Net::HTTP.new(uri.host, uri.port) +http.use_ssl = true + +request = Net::HTTP::Put.new(uri) +request['Authorization'] = 'Bearer ptlc_YOUR_API_KEY' +request['Accept'] = 'Application/vnd.pterodactyl.v1+json' +request['Content-Type'] = 'application/json' +request.body = rename_data.to_json + +response = http.request(request) +puts "File renamed successfully"` + }} +/> + +### Success Response (204) + +Returns empty response body with status code 204. + +--- + +## Copy File + +Copy files to another location on the server. + +**`POST /api/client/servers/{server}/files/copy`** + +### Request Body + +| Field | Type | Required | Description | +|-------|------|----------|-------------| +| `location` | string | Yes | Source file path | + +### Example Request + + '/config.yml' +]; + +$response = $client->post("https://your-panel.com/api/client/servers/{$serverId}/files/copy", [ + 'headers' => [ + 'Authorization' => 'Bearer ptlc_YOUR_API_KEY', + 'Accept' => 'Application/vnd.pterodactyl.v1+json', + 'Content-Type' => 'application/json' + ], + 'json' => $copyData +]); + +echo "File copied successfully"; +?>`, + go: `package main + +import ( + "bytes" + "encoding/json" + "fmt" + "net/http" +) + +func main() { + serverId := "d3aac109" + copyData := map[string]interface{}{ + "location": "/config.yml", + } + + jsonData, _ := json.Marshal(copyData) + + client := &http.Client{} + req, _ := http.NewRequest("POST", fmt.Sprintf("https://your-panel.com/api/client/servers/%s/files/copy", serverId), bytes.NewBuffer(jsonData)) + req.Header.Add("Authorization", "Bearer ptlc_YOUR_API_KEY") + req.Header.Add("Accept", "Application/vnd.pterodactyl.v1+json") + req.Header.Add("Content-Type", "application/json") + + resp, _ := client.Do(req) + defer resp.Body.Close() + + fmt.Println("File copied successfully") +}`, + java: `import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.net.URI; + +String serverId = "d3aac109"; +String jsonData = """ +{ + "location": "/config.yml" +} +"""; + +HttpClient client = HttpClient.newHttpClient(); +HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create("https://your-panel.com/api/client/servers/" + serverId + "/files/copy")) + .header("Authorization", "Bearer ptlc_YOUR_API_KEY") + .header("Accept", "Application/vnd.pterodactyl.v1+json") + .header("Content-Type", "application/json") + .POST(HttpRequest.BodyPublishers.ofString(jsonData)) + .build(); + +HttpResponse response = client.send(request, + HttpResponse.BodyHandlers.ofString()); +System.out.println("File copied successfully");`, + csharp: `using System.Net.Http; +using System.Text; +using System.Text.Json; +using System.Threading.Tasks; + +var serverId = "d3aac109"; +var client = new HttpClient(); +client.DefaultRequestHeaders.Add("Authorization", "Bearer ptlc_YOUR_API_KEY"); +client.DefaultRequestHeaders.Add("Accept", "Application/vnd.pterodactyl.v1+json"); + +var copyData = new { + location = "/config.yml" +}; + +var json = JsonSerializer.Serialize(copyData); +var content = new StringContent(json, Encoding.UTF8, "application/json"); + +var response = await client.PostAsync($"https://your-panel.com/api/client/servers/{serverId}/files/copy", content); +Console.WriteLine("File copied successfully");`, + ruby: `require 'net/http' +require 'json' + +server_id = 'd3aac109' +copy_data = { + location: '/config.yml' +} + +uri = URI("https://your-panel.com/api/client/servers/#{server_id}/files/copy") +http = Net::HTTP.new(uri.host, uri.port) +http.use_ssl = true + +request = Net::HTTP::Post.new(uri) +request['Authorization'] = 'Bearer ptlc_YOUR_API_KEY' +request['Accept'] = 'Application/vnd.pterodactyl.v1+json' +request['Content-Type'] = 'application/json' +request.body = copy_data.to_json + +response = http.request(request) +puts "File copied successfully"` + }} +/> + +### Success Response (204) + +Returns empty response body with status code 204. The file will be copied with "_copy" appended to the filename. + +--- + +## Delete Files + +Delete one or more files or directories. + +**`POST /api/client/servers/{server}/files/delete`** + +### Request Body + +| Field | Type | Required | Description | +|-------|------|----------|-------------| +| `root` | string | Yes | Base directory path | +| `files` | array | Yes | Array of files/directories to delete | + +### Example Request + + '/', + 'files' => ['old-file.txt', 'temp-folder'] +]; + +$response = $client->post("https://your-panel.com/api/client/servers/{$serverId}/files/delete", [ + 'headers' => [ + 'Authorization' => 'Bearer ptlc_YOUR_API_KEY', + 'Accept' => 'Application/vnd.pterodactyl.v1+json', + 'Content-Type' => 'application/json' + ], + 'json' => $deleteData +]); + +echo "Files deleted successfully"; +?>`, + go: `package main + +import ( + "bytes" + "encoding/json" + "fmt" + "net/http" +) + +func main() { + serverId := "d3aac109" + deleteData := map[string]interface{}{ + "root": "/", + "files": []string{"old-file.txt", "temp-folder"}, + } + + jsonData, _ := json.Marshal(deleteData) + + client := &http.Client{} + req, _ := http.NewRequest("POST", fmt.Sprintf("https://your-panel.com/api/client/servers/%s/files/delete", serverId), bytes.NewBuffer(jsonData)) + req.Header.Add("Authorization", "Bearer ptlc_YOUR_API_KEY") + req.Header.Add("Accept", "Application/vnd.pterodactyl.v1+json") + req.Header.Add("Content-Type", "application/json") + + resp, _ := client.Do(req) + defer resp.Body.Close() + + fmt.Println("Files deleted successfully") +}`, + java: `import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.net.URI; + +String serverId = "d3aac109"; +String jsonData = """ +{ + "root": "/", + "files": ["old-file.txt", "temp-folder"] +} +"""; + +HttpClient client = HttpClient.newHttpClient(); +HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create("https://your-panel.com/api/client/servers/" + serverId + "/files/delete")) + .header("Authorization", "Bearer ptlc_YOUR_API_KEY") + .header("Accept", "Application/vnd.pterodactyl.v1+json") + .header("Content-Type", "application/json") + .POST(HttpRequest.BodyPublishers.ofString(jsonData)) + .build(); + +HttpResponse response = client.send(request, + HttpResponse.BodyHandlers.ofString()); +System.out.println("Files deleted successfully");`, + csharp: `using System.Net.Http; +using System.Text; +using System.Text.Json; +using System.Threading.Tasks; + +var serverId = "d3aac109"; +var client = new HttpClient(); +client.DefaultRequestHeaders.Add("Authorization", "Bearer ptlc_YOUR_API_KEY"); +client.DefaultRequestHeaders.Add("Accept", "Application/vnd.pterodactyl.v1+json"); + +var deleteData = new { + root = "/", + files = new[] { "old-file.txt", "temp-folder" } +}; + +var json = JsonSerializer.Serialize(deleteData); +var content = new StringContent(json, Encoding.UTF8, "application/json"); + +var response = await client.PostAsync($"https://your-panel.com/api/client/servers/{serverId}/files/delete", content); +Console.WriteLine("Files deleted successfully");`, + ruby: `require 'net/http' +require 'json' + +server_id = 'd3aac109' +delete_data = { + root: '/', + files: ['old-file.txt', 'temp-folder'] +} + +uri = URI("https://your-panel.com/api/client/servers/#{server_id}/files/delete") +http = Net::HTTP.new(uri.host, uri.port) +http.use_ssl = true + +request = Net::HTTP::Post.new(uri) +request['Authorization'] = 'Bearer ptlc_YOUR_API_KEY' +request['Accept'] = 'Application/vnd.pterodactyl.v1+json' +request['Content-Type'] = 'application/json' +request.body = delete_data.to_json + +response = http.request(request) +puts "Files deleted successfully"` + }} +/> + +### Success Response (204) + +Returns empty response body with status code 204. + +:::warning Important +Deleted files cannot be recovered. Always create backups before deleting important files. +::: + +--- + +## Create Folder + +Create a new directory on the server. + +**`POST /api/client/servers/{server}/files/create-folder`** + +### Request Body + +| Field | Type | Required | Description | +|-------|------|----------|-------------| +| `root` | string | Yes | Parent directory path | +| `name` | string | Yes | Name of the new folder | + +### Example Request + + '/', + 'name' => 'new-folder' +]; + +$response = $client->post("https://your-panel.com/api/client/servers/{$serverId}/files/create-folder", [ + 'headers' => [ + 'Authorization' => 'Bearer ptlc_YOUR_API_KEY', + 'Accept' => 'Application/vnd.pterodactyl.v1+json', + 'Content-Type' => 'application/json' + ], + 'json' => $folderData +]); + +echo "Folder created successfully"; +?>`, + go: `package main + +import ( + "bytes" + "encoding/json" + "fmt" + "net/http" +) + +func main() { + serverId := "d3aac109" + folderData := map[string]interface{}{ + "root": "/", + "name": "new-folder", + } + + jsonData, _ := json.Marshal(folderData) + + client := &http.Client{} + req, _ := http.NewRequest("POST", fmt.Sprintf("https://your-panel.com/api/client/servers/%s/files/create-folder", serverId), bytes.NewBuffer(jsonData)) + req.Header.Add("Authorization", "Bearer ptlc_YOUR_API_KEY") + req.Header.Add("Accept", "Application/vnd.pterodactyl.v1+json") + req.Header.Add("Content-Type", "application/json") + + resp, _ := client.Do(req) + defer resp.Body.Close() + + fmt.Println("Folder created successfully") +}`, + java: `import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.net.URI; + +String serverId = "d3aac109"; +String jsonData = """ +{ + "root": "/", + "name": "new-folder" +} +"""; + +HttpClient client = HttpClient.newHttpClient(); +HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create("https://your-panel.com/api/client/servers/" + serverId + "/files/create-folder")) + .header("Authorization", "Bearer ptlc_YOUR_API_KEY") + .header("Accept", "Application/vnd.pterodactyl.v1+json") + .header("Content-Type", "application/json") + .POST(HttpRequest.BodyPublishers.ofString(jsonData)) + .build(); + +HttpResponse response = client.send(request, + HttpResponse.BodyHandlers.ofString()); +System.out.println("Folder created successfully");`, + csharp: `using System.Net.Http; +using System.Text; +using System.Text.Json; +using System.Threading.Tasks; + +var serverId = "d3aac109"; +var client = new HttpClient(); +client.DefaultRequestHeaders.Add("Authorization", "Bearer ptlc_YOUR_API_KEY"); +client.DefaultRequestHeaders.Add("Accept", "Application/vnd.pterodactyl.v1+json"); + +var folderData = new { + root = "/", + name = "new-folder" +}; + +var json = JsonSerializer.Serialize(folderData); +var content = new StringContent(json, Encoding.UTF8, "application/json"); + +var response = await client.PostAsync($"https://your-panel.com/api/client/servers/{serverId}/files/create-folder", content); +Console.WriteLine("Folder created successfully");`, + ruby: `require 'net/http' +require 'json' + +server_id = 'd3aac109' +folder_data = { + root: '/', + name: 'new-folder' +} + +uri = URI("https://your-panel.com/api/client/servers/#{server_id}/files/create-folder") +http = Net::HTTP.new(uri.host, uri.port) +http.use_ssl = true + +request = Net::HTTP::Post.new(uri) +request['Authorization'] = 'Bearer ptlc_YOUR_API_KEY' +request['Accept'] = 'Application/vnd.pterodactyl.v1+json' +request['Content-Type'] = 'application/json' +request.body = folder_data.to_json + +response = http.request(request) +puts "Folder created successfully"` + }} +/> + +### Success Response (204) + +Returns empty response body with status code 204. + +--- + ## Required Permissions | Permission | Description | diff --git a/docs/api/client/servers.md b/docs/api/client/servers.md index 607a2b8..4459fcf 100644 --- a/docs/api/client/servers.md +++ b/docs/api/client/servers.md @@ -253,6 +253,236 @@ puts data` --- +## Get Permissions + +Get a list of all available permissions that can be assigned to users. + +**`GET /api/client/permissions`** + +### Example Request + +`, + go: `package main + +import ( + "fmt" + "io" + "net/http" +) + +func main() { + client := &http.Client{} + req, _ := http.NewRequest("GET", "https://your-panel.com/api/client/permissions", nil) + + req.Header.Add("Authorization", "Bearer ptlc_YOUR_API_KEY") + req.Header.Add("Accept", "Application/vnd.pterodactyl.v1+json") + req.Header.Add("Content-Type", "application/json") + + resp, _ := client.Do(req) + defer resp.Body.Close() + + body, _ := io.ReadAll(resp.Body) + fmt.Println(string(body)) +}`, + java: `import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.net.URI; + +HttpClient client = HttpClient.newHttpClient(); +HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create("https://your-panel.com/api/client/permissions")) + .header("Authorization", "Bearer ptlc_YOUR_API_KEY") + .header("Accept", "Application/vnd.pterodactyl.v1+json") + .header("Content-Type", "application/json") + .GET() + .build(); + +HttpResponse response = client.send(request, + HttpResponse.BodyHandlers.ofString()); +System.out.println(response.body());`, + csharp: `using System; +using System.Net.Http; +using System.Threading.Tasks; + +var client = new HttpClient(); +client.DefaultRequestHeaders.Add("Authorization", "Bearer ptlc_YOUR_API_KEY"); +client.DefaultRequestHeaders.Add("Accept", "Application/vnd.pterodactyl.v1+json"); + +var response = await client.GetAsync("https://your-panel.com/api/client/permissions"); +var content = await response.Content.ReadAsStringAsync(); +Console.WriteLine(content);`, + ruby: `require 'net/http' +require 'json' + +uri = URI('https://your-panel.com/api/client/permissions') +http = Net::HTTP.new(uri.host, uri.port) +http.use_ssl = true + +request = Net::HTTP::Get.new(uri) +request['Authorization'] = 'Bearer ptlc_YOUR_API_KEY' +request['Accept'] = 'Application/vnd.pterodactyl.v1+json' +request['Content-Type'] = 'application/json' + +response = http.request(request) +data = JSON.parse(response.body) +puts data` + }} +/> + +### Example Response + +```json +{ + "object": "system_permissions", + "attributes": { + "permissions": { + "websocket": { + "description": "Allows the user to connect to the server websocket, allowing them to view console output and statistics in real-time.", + "keys": { + "connect": "Allows a user to connect to the websocket instance for a server to stream the console." + } + }, + "control": { + "description": "Permissions that control a user's ability to control the power state of a server, or send commands.", + "keys": { + "console": "Allows a user to send commands to the server instance via the console.", + "start": "Allows a user to start the server if it is stopped.", + "stop": "Allows a user to stop a server if it is running.", + "restart": "Allows a user to perform a server restart. This allows them to start the server if it is offline, or stop and restart the server if it is running." + } + }, + "user": { + "description": "Permissions that allow a user to manage subusers for a server. They will never be able to edit their own account, or assign permissions they do not have themselves.", + "keys": { + "create": "Allows a user to create new subusers for the server.", + "read": "Allows the user to view subusers and their permissions for the server.", + "update": "Allows a user to modify other subusers.", + "delete": "Allows a user to delete a subuser from the server." + } + }, + "file": { + "description": "Permissions that control a user's ability to modify the filesystem for a server.", + "keys": { + "create": "Allows a user to create additional files and folders via the Panel or direct upload.", + "read": "Allows a user to view the contents of a directory and read the contents of a file. Users with this permission can also download files.", + "update": "Allows a user to update the contents of an existing file or directory.", + "delete": "Allows a user to delete files or directories.", + "archive": "Allows a user to archive the contents of a directory as well as decompress existing archives on the system.", + "sftp": "Allows a user to connect to SFTP and manage server files using the other assigned file permissions." + } + }, + "backup": { + "description": "Permissions that control a user's ability to generate and manage server backups.", + "keys": { + "create": "Allows a user to create new backups for the server.", + "read": "Allows a user to view all backups that exist for the server.", + "delete": "Allows a user to remove backups from the system.", + "download": "Allows a user to download backups.", + "restore": "Allows a user to restore a backup for the server." + } + }, + "allocation": { + "description": "Permissions that control a user's ability to modify the port allocations for a server.", + "keys": { + "read": "Allows a user to view all allocations currently assigned to a server. Users with any level of access to this server can always view the primary allocation.", + "create": "Allows a user to assign additional allocations to the server.", + "update": "Allows a user to change the primary server allocation and attach notes to each allocation.", + "delete": "Allows a user to delete an allocation from the server." + } + }, + "startup": { + "description": "Permissions that control a user's ability to view and modify the startup parameters for a server.", + "keys": { + "read": "Allows a user to view the startup variables for a server.", + "update": "Allows a user to modify the startup variables for the server.", + "docker-image": "Allows a user to modify the Docker image used when running the server." + } + }, + "database": { + "description": "Permissions that control a user's ability to manage databases for a server.", + "keys": { + "create": "Allows a user to create a new database for the server.", + "read": "Allows a user to view the database associated with the server.", + "update": "Allows a user to rotate the password on a database instance. If the user does not have the view_password permission they will not see the updated password.", + "delete": "Allows a user to remove a database instance from the server.", + "view_password": "Allows a user to view the password associated with a database instance for the server." + } + }, + "schedule": { + "description": "Permissions that control a user's ability to manage schedules for a server.", + "keys": { + "create": "Allows a user to create new schedules for the server.", + "read": "Allows a user to view schedules for the server.", + "update": "Allows a user to update schedules and schedule tasks for the server.", + "delete": "Allows a user to delete schedules for the server." + } + }, + "settings": { + "description": "Permissions that control a user's ability to view and modify server settings.", + "keys": { + "rename": "Allows a user to rename the server.", + "reinstall": "Allows a user to trigger a reinstall of the server." + } + }, + "activity": { + "description": "Permissions that control a user's ability to view activity logs for a server.", + "keys": { + "read": "Allows a user to view the activity logs for the server." + } + } + } + } +} +``` + +--- + ## Get Server Details Retrieve detailed information about a specific server. @@ -1377,6 +1607,526 @@ print_r($data); --- +## Server Activity + +### Get Server Activity Logs + +Retrieve server activity logs including recent events and actions. + +**`GET /api/client/servers/{server}/activity`** + +### URL Parameters + +| Parameter | Type | Description | +|-----------|------|-------------| +| `server` | string | Server identifier (UUID or short ID) | + +### Example Request + +`, + go: `package main + +import ( + "fmt" + "io" + "net/http" +) + +func main() { + serverId := "d3aac109" + client := &http.Client{} + req, _ := http.NewRequest("GET", fmt.Sprintf("https://your-panel.com/api/client/servers/%s/activity", serverId), nil) + + req.Header.Add("Authorization", "Bearer ptlc_YOUR_API_KEY") + req.Header.Add("Accept", "Application/vnd.pterodactyl.v1+json") + req.Header.Add("Content-Type", "application/json") + + resp, _ := client.Do(req) + defer resp.Body.Close() + + body, _ := io.ReadAll(resp.Body) + fmt.Println(string(body)) +}`, + java: `import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.net.URI; + +String serverId = "d3aac109"; +HttpClient client = HttpClient.newHttpClient(); +HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create("https://your-panel.com/api/client/servers/" + serverId + "/activity")) + .header("Authorization", "Bearer ptlc_YOUR_API_KEY") + .header("Accept", "Application/vnd.pterodactyl.v1+json") + .header("Content-Type", "application/json") + .GET() + .build(); + +HttpResponse response = client.send(request, + HttpResponse.BodyHandlers.ofString()); +System.out.println(response.body());`, + csharp: `using System; +using System.Net.Http; +using System.Threading.Tasks; + +var serverId = "d3aac109"; +var client = new HttpClient(); +client.DefaultRequestHeaders.Add("Authorization", "Bearer ptlc_YOUR_API_KEY"); +client.DefaultRequestHeaders.Add("Accept", "Application/vnd.pterodactyl.v1+json"); + +var response = await client.GetAsync($"https://your-panel.com/api/client/servers/{serverId}/activity"); +var content = await response.Content.ReadAsStringAsync(); +Console.WriteLine(content);`, + ruby: `require 'net/http' +require 'json' + +server_id = 'd3aac109' +uri = URI("https://your-panel.com/api/client/servers/#{server_id}/activity") +http = Net::HTTP.new(uri.host, uri.port) +http.use_ssl = true + +request = Net::HTTP::Get.new(uri) +request['Authorization'] = 'Bearer ptlc_YOUR_API_KEY' +request['Accept'] = 'Application/vnd.pterodactyl.v1+json' +request['Content-Type'] = 'application/json' + +response = http.request(request) +data = JSON.parse(response.body) +puts data` + }} +/> + +### Example Response + +```json +{ + "object": "list", + "data": [ + { + "object": "activity_log", + "attributes": { + "id": "3c5608f7-9798-4db6-becd-f3c4b63e1a7f", + "batch": null, + "event": "server:power.start", + "is_api": false, + "ip": "192.168.1.100", + "description": "Server was started", + "properties": { + "action": "start", + "username": "admin" + }, + "has_additional_metadata": true, + "timestamp": "2024-01-15T10:30:00.000000Z" + } + }, + { + "object": "activity_log", + "attributes": { + "id": "2a2b3c4d-5e6f-7g8h-9i0j-k1l2m3n4o5p6", + "batch": null, + "event": "server:backup.complete", + "is_api": true, + "ip": "192.168.1.100", + "description": "Backup completed successfully", + "properties": { + "backup_uuid": "550e8400-e29b-41d4-a716-446655440000", + "name": "Daily Backup" + }, + "has_additional_metadata": false, + "timestamp": "2024-01-15T09:00:00.000000Z" + } + } + ], + "meta": { + "pagination": { + "total": 125, + "count": 2, + "per_page": 50, + "current_page": 1, + "total_pages": 3, + "links": {} + } + } +} +``` + +--- + +## Server Settings + +### Rename Server + +Change the display name of a server. + +**`POST /api/client/servers/{server}/settings/rename`** + +### URL Parameters + +| Parameter | Type | Description | +|-----------|------|-------------| +| `server` | string | Server identifier (UUID or short ID) | + +### Request Body + +| Field | Type | Required | Description | +|-------|------|----------|-------------| +| `name` | string | Yes | New server name (1-255 characters) | +| `description` | string | No | Server description | + +### Example Request + + 'Production Server', + 'description' => 'Main production Minecraft server' +]; + +$response = $client->post("https://your-panel.com/api/client/servers/{$serverId}/settings/rename", [ + 'headers' => [ + 'Authorization' => 'Bearer ptlc_YOUR_API_KEY', + 'Accept' => 'Application/vnd.pterodactyl.v1+json', + 'Content-Type' => 'application/json' + ], + 'json' => $renameData +]); + +echo "Server renamed successfully"; +?>`, + go: `package main + +import ( + "bytes" + "encoding/json" + "fmt" + "net/http" +) + +func main() { + serverId := "d3aac109" + renameData := map[string]interface{}{ + "name": "Production Server", + "description": "Main production Minecraft server", + } + + jsonData, _ := json.Marshal(renameData) + + client := &http.Client{} + req, _ := http.NewRequest("POST", fmt.Sprintf("https://your-panel.com/api/client/servers/%s/settings/rename", serverId), bytes.NewBuffer(jsonData)) + req.Header.Add("Authorization", "Bearer ptlc_YOUR_API_KEY") + req.Header.Add("Accept", "Application/vnd.pterodactyl.v1+json") + req.Header.Add("Content-Type", "application/json") + + resp, _ := client.Do(req) + defer resp.Body.Close() + + fmt.Println("Server renamed successfully") +}`, + java: `import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.net.URI; + +String serverId = "d3aac109"; +String jsonData = """ +{ + "name": "Production Server", + "description": "Main production Minecraft server" +} +"""; + +HttpClient client = HttpClient.newHttpClient(); +HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create("https://your-panel.com/api/client/servers/" + serverId + "/settings/rename")) + .header("Authorization", "Bearer ptlc_YOUR_API_KEY") + .header("Accept", "Application/vnd.pterodactyl.v1+json") + .header("Content-Type", "application/json") + .POST(HttpRequest.BodyPublishers.ofString(jsonData)) + .build(); + +HttpResponse response = client.send(request, + HttpResponse.BodyHandlers.ofString()); +System.out.println("Server renamed successfully");`, + csharp: `using System.Net.Http; +using System.Text; +using System.Text.Json; +using System.Threading.Tasks; + +var serverId = "d3aac109"; +var client = new HttpClient(); +client.DefaultRequestHeaders.Add("Authorization", "Bearer ptlc_YOUR_API_KEY"); +client.DefaultRequestHeaders.Add("Accept", "Application/vnd.pterodactyl.v1+json"); + +var renameData = new { + name = "Production Server", + description = "Main production Minecraft server" +}; + +var json = JsonSerializer.Serialize(renameData); +var content = new StringContent(json, Encoding.UTF8, "application/json"); + +var response = await client.PostAsync($"https://your-panel.com/api/client/servers/{serverId}/settings/rename", content); +Console.WriteLine("Server renamed successfully");`, + ruby: `require 'net/http' +require 'json' + +server_id = 'd3aac109' +rename_data = { + name: 'Production Server', + description: 'Main production Minecraft server' +} + +uri = URI("https://your-panel.com/api/client/servers/#{server_id}/settings/rename") +http = Net::HTTP.new(uri.host, uri.port) +http.use_ssl = true + +request = Net::HTTP::Post.new(uri) +request['Authorization'] = 'Bearer ptlc_YOUR_API_KEY' +request['Accept'] = 'Application/vnd.pterodactyl.v1+json' +request['Content-Type'] = 'application/json' +request.body = rename_data.to_json + +response = http.request(request) +puts "Server renamed successfully"` + }} +/> + +### Success Response (204) + +Returns empty response body with status code 204. + +### Reinstall Server + +Trigger a reinstallation of the server. This will stop the server and re-run the installation script. + +**`POST /api/client/servers/{server}/settings/reinstall`** + +:::warning Important +This action will delete all server files and reinstall the server from scratch. Make sure to backup important data before proceeding. +::: + +### URL Parameters + +| Parameter | Type | Description | +|-----------|------|-------------| +| `server` | string | Server identifier (UUID or short ID) | + +### Example Request + +post("https://your-panel.com/api/client/servers/{$serverId}/settings/reinstall", [ + 'headers' => [ + 'Authorization' => 'Bearer ptlc_YOUR_API_KEY', + 'Accept' => 'Application/vnd.pterodactyl.v1+json', + 'Content-Type' => 'application/json' + ] +]); + +echo "Server reinstall initiated"; +?>`, + go: `package main + +import ( + "fmt" + "net/http" +) + +func main() { + serverId := "d3aac109" + client := &http.Client{} + req, _ := http.NewRequest("POST", fmt.Sprintf("https://your-panel.com/api/client/servers/%s/settings/reinstall", serverId), nil) + req.Header.Add("Authorization", "Bearer ptlc_YOUR_API_KEY") + req.Header.Add("Accept", "Application/vnd.pterodactyl.v1+json") + req.Header.Add("Content-Type", "application/json") + + resp, _ := client.Do(req) + defer resp.Body.Close() + + fmt.Println("Server reinstall initiated") +}`, + java: `import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.net.URI; + +String serverId = "d3aac109"; +HttpClient client = HttpClient.newHttpClient(); +HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create("https://your-panel.com/api/client/servers/" + serverId + "/settings/reinstall")) + .header("Authorization", "Bearer ptlc_YOUR_API_KEY") + .header("Accept", "Application/vnd.pterodactyl.v1+json") + .header("Content-Type", "application/json") + .POST(HttpRequest.BodyPublishers.noBody()) + .build(); + +HttpResponse response = client.send(request, + HttpResponse.BodyHandlers.ofString()); +System.out.println("Server reinstall initiated");`, + csharp: `using System.Net.Http; +using System.Threading.Tasks; + +var serverId = "d3aac109"; +var client = new HttpClient(); +client.DefaultRequestHeaders.Add("Authorization", "Bearer ptlc_YOUR_API_KEY"); +client.DefaultRequestHeaders.Add("Accept", "Application/vnd.pterodactyl.v1+json"); + +var response = await client.PostAsync($"https://your-panel.com/api/client/servers/{serverId}/settings/reinstall", null); +Console.WriteLine("Server reinstall initiated");`, + ruby: `require 'net/http' +require 'json' + +server_id = 'd3aac109' +uri = URI("https://your-panel.com/api/client/servers/#{server_id}/settings/reinstall") +http = Net::HTTP.new(uri.host, uri.port) +http.use_ssl = true + +request = Net::HTTP::Post.new(uri) +request['Authorization'] = 'Bearer ptlc_YOUR_API_KEY' +request['Accept'] = 'Application/vnd.pterodactyl.v1+json' +request['Content-Type'] = 'application/json' + +response = http.request(request) +puts "Server reinstall initiated"` + }} +/> + +### Success Response (202) + +Returns empty response body with status code 202 (Accepted). + +--- + ## Next Steps - Explore [File Management](./files) for server file operations