Code Samples #
Copy
curl --request POST \
--url 'https://app.xcloud.host/api/v1/servers/{uuid}/sudo-users' \
--header 'Authorization: Bearer YOUR_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"username": "deploy",
"password": "S3cur3P@ss!",
"ssh_public_keys": [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIExample deploy@workstation"
],
"is_temporary": false
}'
const response = await fetch('https://app.xcloud.host/api/v1/servers/{uuid}/sudo-users', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"username": "deploy",
"password": "S3cur3P@ss!",
"ssh_public_keys": [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIExample deploy@workstation"
],
"is_temporary": false
})
});
const data = await response.json();
console.log(data);
import requests
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
}
payload = {
"username": "deploy",
"password": "S3cur3P@ss!",
"ssh_public_keys": [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIExample deploy@workstation"
],
"is_temporary": false
}
response = requests.post("https://app.xcloud.host/api/v1/servers/{uuid}/sudo-users", headers=headers, json=payload)
print(response.json())
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://app.xcloud.host/api/v1/servers/{uuid}/sudo-users',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_TOKEN',
'Content-Type: application/json'
],
CURLOPT_POSTFIELDS => '{
"username": "deploy",
"password": "S3cur3P@ss!",
"ssh_public_keys": [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIExample deploy@workstation"
],
"is_temporary": false
}',
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
using System.Net.Http;
using System.Text;
var client = new HttpClient();
var request = new HttpRequestMessage(new HttpMethod("POST"), "https://app.xcloud.host/api/v1/servers/{uuid}/sudo-users");
request.Headers.Add("Authorization", "Bearer YOUR_TOKEN");
request.Content = new StringContent(@"{
""username"": ""deploy"",
""password"": ""S3cur3P@ss!"",
""ssh_public_keys"": [
""ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIExample deploy@workstation""
],
""is_temporary"": false
}", Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
import java.net.URI;
import java.net.http.*;
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://app.xcloud.host/api/v1/servers/{uuid}/sudo-users"))
.header("Authorization", "Bearer YOUR_TOKEN")
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("""
{
"username": "deploy",
"password": "S3cur3P@ss!",
"ssh_public_keys": [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIExample deploy@workstation"
],
"is_temporary": false
}
"""))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Response #
Copy
{
"success": true,
"message": "Sudo user created successfully.",
"data": {
"uuid": "c3d4e5f6-a7b8-9012-cdef-234567890123",
"username": "deploy",
"status": "updating",
"is_temporary": false,
"expires_at": null,
"created_at": "2025-06-01T12:00:00Z"
}
}
{
"success": false,
"message": "Unauthenticated.",
"data": null
}
{
"success": false,
"message": "This action is unauthorized. Your token is missing the required scope.",
"data": null
}
{
"success": false,
"message": "Not found.",
"data": null
}
{
"success": false,
"message": "The given data was invalid.",
"data": null,
"errors": {
"domain": [
"The domain field is required when mode is live."
]
}
}
Creates a New sudo user on the specified Server, or updates an existing one if a user with the same username already exists (idempotent). This is an asynchronous operation — the user will be in updating status until ready. Requires the write:servers scope.
Path Parameters #
| Name | Type | Required | Description |
|---|---|---|---|
uuid | string (uuid) | Required | UUID of the Server |
Request Body #
Content type: application/json — required
| Field | Type | Required | Description |
|---|---|---|---|
username | string | Required | Username for the sudo user. Cannot be "xcloud". |
password | string | Optional | Password for the sudo user. Required for non-root users. |
ssh_public_keys | array of string | Required | One or more SSH public keys to authorize for this user. |
is_temporary | boolean | Optional | Whether the sudo user is temporary. Temporary users may be automatically removed after expiry. |
Example request
Copy
{
"username": "deploy",
"password": "S3cur3P@ss!",
"ssh_public_keys": [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIExample deploy@workstation"
],
"is_temporary": false
}
Responses #
201 — Sudo user created or updated #
| Field | Type | Required | Description |
|---|---|---|---|
success | boolean | Optional | |
message | string | Optional | |
data | object | Optional | |
data | object | Optional | |
data.uuid | string (uuid) | Optional | |
data.username | string | Optional | |
data.status | string | Optional | Allowed: active, updating, deleting |
data.is_temporary | boolean | Optional | |
data.expires_at | string (date-time) | Optional | |
data.created_at | string (date-time) | Optional |
Example 201 response
Copy
{
"success": true,
"message": "Sudo user created successfully.",
"data": {
"uuid": "c3d4e5f6-a7b8-9012-cdef-234567890123",
"username": "deploy",
"status": "updating",
"is_temporary": false,
"expires_at": null,
"created_at": "2025-06-01T12:00:00Z"
}
}
401 — Missing or invalid authentication token #
| Field | Type | Required | Description |
|---|---|---|---|
success | boolean | Optional | |
message | string | Optional | |
data | object | Optional |
Example 401 response
Copy
{
"success": false,
"message": "Unauthenticated.",
"data": null
}
403 — Token lacks the required scope #
| Field | Type | Required | Description |
|---|---|---|---|
success | boolean | Optional | |
message | string | Optional | |
data | object | Optional |
Example 403 response
Copy
{
"success": false,
"message": "This action is unauthorized. Your token is missing the required scope.",
"data": null
}
404 — Resource not found or not accessible to your Team #
| Field | Type | Required | Description |
|---|---|---|---|
success | boolean | Optional | |
message | string | Optional | |
data | object | Optional |
Example 404 response
Copy
{
"success": false,
"message": "Not found.",
"data": null
}
422 — Request validation failed #
| Field | Type | Required | Description |
|---|---|---|---|
success | boolean | Optional | |
message | string | Optional | |
data | object | Optional | |
errors | object | Optional |
Example 422 response
Copy
{
"success": false,
"message": "The given data was invalid.",
"data": null,
"errors": {
"domain": [
"The domain field is required when mode is live."
]
}
}
