unikraft api
The API command allows you to make direct HTTP requests to the Unikraft Cloud API without using a higher-level CLI subcommand. This is useful for endpoints that do not yet have a dedicated command, or for scripting advanced workflows.
REQUEST BODY SYNTAX
The request body can be specified as positional arguments. Each argument is one of:
@file Read the body from a file on disk. @- Read the body from standard input (stdin). {...} Inline JSON object (merges with other arguments). [...] Inline JSON array (replaces the entire body). key=value Set a key to a literal string value. key:=raw Set a key to a raw JSON value (number, boolean, null, object, or array constructed from raw JSON).
NESTED JSON SYNTAX
key=value / key:=raw forms can be used to build complex nested structures:
key[sub]=value Sets a nested key inside an object. Multiple bracket segments create deeply nested objects. Example: user[name]=Alice user[age]:=30 Produces: {"user":{"name":"Alice","age":30}}
key[]=value Appends a value to an array. Multiple [] arguments add more elements. Example: apps[]=Terminal apps[]=Desktop Produces: {"apps":["Terminal","Desktop"]}
key[][sub]=value Creates a new object, assigns the sub-key inside it, and appends the whole object to the array. Further [sub] segments nest deeper. Example: arr[][key]=value arr[][count]:=42 Produces: {"arr":[{"key":"value"},{"count":42}]}
key[N]=value Assigns at a specific numeric index in an array. Gaps are padded with null. The maximum index is 10000. Example: arr[0]=first arr[2]=third Produces: {"arr":["first",null,"third"]}
TOP-LEVEL ARRAY SYNTAX
When the first argument starts with a bracket (e.g. [0][key]=value or []=value), the root of the request body becomes a JSON array instead of an object.
[N][key]=value Creates an array of objects and assigns at index N. Example: [0][type]=platform [0][name]=desktop [1][type]=platform [1][name]=web Produces: [{"type":"platform","name":"desktop"},{"type":"platform","name":"web"}]
[]=value Appends raw values to the root array. Example: []=a []=b []=c Produces: ["a","b","c"]
[]:=raw Appends a raw JSON value (number, boolean, null) to the root array. Example: []:=1 []:=2 []:=3 Produces: [1,2,3]
RAW JSON VALUES
Use the := operator (instead of =) to pass a raw JSON value:
count:=42 Number, not a string. active:=true Boolean. data:=null Null value. nested:={"a":1} Nested JSON object. arr:=["x","y"] Nested JSON array.
ESCAPING
Special characters in key names can be escaped with a backslash:
key[sub]=value Literal bracket in key name. key=value=test Literal equals sign in key name. key[\]=value Literal backslash in key name. key[\1]=value Force a numeric segment to be treated as a string map key instead of an array index.
MULTIPLE ARGUMENTS
Multiple body arguments can be passed on a single line or across multiple lines. Arguments are processed in order; later values overwrite earlier ones at the same path.
WHITESPACE IN VALUES
If a value contains spaces, quote the entire argument: unikraft api /v1/volumes "name=my test volume" stars:=54000
EXAMPLES
The examples below demonstrate many of the syntax forms described above.
Code
Examples
List instances in the default metro:
Code
Get the current user's quotas:
Code
Inspect a specific instance by UUID:
Code
Create a new 256MB volume with raw JSON values:
Code
Set nested object keys using bracket notation:
Code
Append values to an array with key[]= syntax:
Code
Append objects to an array using key[][sub]= syntax:
Code
Create a top-level JSON array with [N][key]=value syntax:
Code
Build a root array of raw values with []:= syntax:
Code
Assign at a specific array index with padding:
Code
Merge an inline JSON object with key=value arguments:
Code
Pass a full JSON literal as the request body:
Code
Create resources from a JSON file:
Code
Pipe a request body in from stdin:
Code
Pass a value containing spaces (quote the argument):
Code
Force a numeric segment as a string map key with backslash escaping:
Code
Escape special characters in key names with backslash:
Code
Send custom headers and skip TLS verification:
Code
Delete an instance by UUID:
Code
Check the health of the API:
Code
Options
Code
Options inherited from parent commands
Code
See Also
unikraft: The Unikraft Command-Line Interface.