curl --request POST \
--url https://console.gmicloud.ai/api/v2/sandboxes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"template_id": "<string>",
"snapshot_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"product": "gmi.sandbox.large",
"idc_name": "<string>",
"timeout": 2,
"env_vars": {},
"metadata": {},
"secure": false,
"auto_pause": false,
"egress_control": false,
"egress": {
"allowed_hostnames": [
"<string>"
],
"allowed_cidrs": [
"<string>"
]
}
}
'import requests
url = "https://console.gmicloud.ai/api/v2/sandboxes"
payload = {
"template_id": "<string>",
"snapshot_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"product": "gmi.sandbox.large",
"idc_name": "<string>",
"timeout": 2,
"env_vars": {},
"metadata": {},
"secure": False,
"auto_pause": False,
"egress_control": False,
"egress": {
"allowed_hostnames": ["<string>"],
"allowed_cidrs": ["<string>"]
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
template_id: '<string>',
snapshot_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
product: 'gmi.sandbox.large',
idc_name: '<string>',
timeout: 2,
env_vars: {},
metadata: {},
secure: false,
auto_pause: false,
egress_control: false,
egress: {allowed_hostnames: ['<string>'], allowed_cidrs: ['<string>']}
})
};
fetch('https://console.gmicloud.ai/api/v2/sandboxes', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://console.gmicloud.ai/api/v2/sandboxes",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'template_id' => '<string>',
'snapshot_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'product' => 'gmi.sandbox.large',
'idc_name' => '<string>',
'timeout' => 2,
'env_vars' => [
],
'metadata' => [
],
'secure' => false,
'auto_pause' => false,
'egress_control' => false,
'egress' => [
'allowed_hostnames' => [
'<string>'
],
'allowed_cidrs' => [
'<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://console.gmicloud.ai/api/v2/sandboxes"
payload := strings.NewReader("{\n \"template_id\": \"<string>\",\n \"snapshot_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"product\": \"gmi.sandbox.large\",\n \"idc_name\": \"<string>\",\n \"timeout\": 2,\n \"env_vars\": {},\n \"metadata\": {},\n \"secure\": false,\n \"auto_pause\": false,\n \"egress_control\": false,\n \"egress\": {\n \"allowed_hostnames\": [\n \"<string>\"\n ],\n \"allowed_cidrs\": [\n \"<string>\"\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://console.gmicloud.ai/api/v2/sandboxes")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"template_id\": \"<string>\",\n \"snapshot_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"product\": \"gmi.sandbox.large\",\n \"idc_name\": \"<string>\",\n \"timeout\": 2,\n \"env_vars\": {},\n \"metadata\": {},\n \"secure\": false,\n \"auto_pause\": false,\n \"egress_control\": false,\n \"egress\": {\n \"allowed_hostnames\": [\n \"<string>\"\n ],\n \"allowed_cidrs\": [\n \"<string>\"\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://console.gmicloud.ai/api/v2/sandboxes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"template_id\": \"<string>\",\n \"snapshot_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"product\": \"gmi.sandbox.large\",\n \"idc_name\": \"<string>\",\n \"timeout\": 2,\n \"env_vars\": {},\n \"metadata\": {},\n \"secure\": false,\n \"auto_pause\": false,\n \"egress_control\": false,\n \"egress\": {\n \"allowed_hostnames\": [\n \"<string>\"\n ],\n \"allowed_cidrs\": [\n \"<string>\"\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"request_id": "<string>",
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"sandbox_key": "<string>",
"template_id": "<string>",
"domain": "<string>",
"sandbox_access_token": "<string>",
"traffic_access_token": "<string>"
}
}{
"code": "Parameter.Invalid",
"message": "Invalid request parameters",
"request_id": "req-xxxx"
}{
"code": "Auth.Unauthorized",
"message": "Authentication required",
"request_id": "req-xxxx"
}{
"code": "Resource.QuotaExceeded",
"message": "The resource quota is not enough.",
"request_id": "req-xxxx",
"trace_id": "<string>",
"details": {}
}{
"code": "Resource.NotFound",
"message": "The requested resource was not found",
"request_id": "req-xxxx"
}{
"code": "Resource.QuotaExceeded",
"message": "The resource quota is not enough.",
"request_id": "req-xxxx",
"trace_id": "<string>",
"details": {}
}{
"code": "Template.ProviderNotSupported",
"message": "The selected IDC does not support this template operation",
"request_id": "req-xxxx"
}{
"code": "Resource.QuotaExceeded",
"message": "The resource quota is not enough.",
"request_id": "req-xxxx",
"trace_id": "<string>",
"details": {}
}{
"code": "Request.Canceled",
"message": "Request canceled",
"request_id": "req-xxxx"
}{
"code": "System.Internal",
"message": "An internal server error occurred",
"request_id": "req-xxxx"
}{
"code": "Request.Timeout",
"message": "Request timed out",
"request_id": "req-xxxx"
}Create a sandbox
Creates a sandbox from exactly one source: template_id or a ready snapshot_id.
Compute resources (CPU / memory / disk / architecture) are inherited from the snapshot of the selected Template Build or durable snapshot. They are fixed at capture time. A snapshot launch is a cold start with a new sandbox identifier; network and lifecycle settings come from this create request.
Snapshot launches return 409 Snapshot.NotReady if the snapshot is not ready or becomes unavailable for launch before creation is accepted. If snapshot launches are unsupported for the selected sandbox configuration, the request returns 422 Snapshot.UnsupportedOnProvider.
Idempotency: pass an explicit Idempotency-Key request header as the idempotency key (unrelated to the tracing header X-Request-ID, which is always generated server-side; a client-supplied value is ignored). Resubmitting the same key with identical parameters returns the sandbox created by the first request (with its current access data) plus an Idempotency-Replayed: true response header. The same key with different parameters returns 400 Sandbox.IdempotentParameterMismatch. If the creation under that key has deterministically failed, or the sandbox it created has been deleted, the request returns 409 Sandbox.IdempotentKeyConsumed (retryable failures are automatically re-attempted when the same key is retried). The deduplication window is 24 hours; after it expires the same key is treated as a new request. Without the header, no deduplication is performed.
Backends that create asynchronously return as soon as the request is accepted: the instance starts in provisioning and transitions to running once ready. The detail endpoint is queryable during this period (see GET /sandboxes/).
The sandbox_access_token stays valid for the entire lifetime of the sandbox.
curl --request POST \
--url https://console.gmicloud.ai/api/v2/sandboxes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"template_id": "<string>",
"snapshot_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"product": "gmi.sandbox.large",
"idc_name": "<string>",
"timeout": 2,
"env_vars": {},
"metadata": {},
"secure": false,
"auto_pause": false,
"egress_control": false,
"egress": {
"allowed_hostnames": [
"<string>"
],
"allowed_cidrs": [
"<string>"
]
}
}
'import requests
url = "https://console.gmicloud.ai/api/v2/sandboxes"
payload = {
"template_id": "<string>",
"snapshot_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"product": "gmi.sandbox.large",
"idc_name": "<string>",
"timeout": 2,
"env_vars": {},
"metadata": {},
"secure": False,
"auto_pause": False,
"egress_control": False,
"egress": {
"allowed_hostnames": ["<string>"],
"allowed_cidrs": ["<string>"]
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
template_id: '<string>',
snapshot_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
product: 'gmi.sandbox.large',
idc_name: '<string>',
timeout: 2,
env_vars: {},
metadata: {},
secure: false,
auto_pause: false,
egress_control: false,
egress: {allowed_hostnames: ['<string>'], allowed_cidrs: ['<string>']}
})
};
fetch('https://console.gmicloud.ai/api/v2/sandboxes', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://console.gmicloud.ai/api/v2/sandboxes",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'template_id' => '<string>',
'snapshot_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'product' => 'gmi.sandbox.large',
'idc_name' => '<string>',
'timeout' => 2,
'env_vars' => [
],
'metadata' => [
],
'secure' => false,
'auto_pause' => false,
'egress_control' => false,
'egress' => [
'allowed_hostnames' => [
'<string>'
],
'allowed_cidrs' => [
'<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://console.gmicloud.ai/api/v2/sandboxes"
payload := strings.NewReader("{\n \"template_id\": \"<string>\",\n \"snapshot_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"product\": \"gmi.sandbox.large\",\n \"idc_name\": \"<string>\",\n \"timeout\": 2,\n \"env_vars\": {},\n \"metadata\": {},\n \"secure\": false,\n \"auto_pause\": false,\n \"egress_control\": false,\n \"egress\": {\n \"allowed_hostnames\": [\n \"<string>\"\n ],\n \"allowed_cidrs\": [\n \"<string>\"\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://console.gmicloud.ai/api/v2/sandboxes")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"template_id\": \"<string>\",\n \"snapshot_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"product\": \"gmi.sandbox.large\",\n \"idc_name\": \"<string>\",\n \"timeout\": 2,\n \"env_vars\": {},\n \"metadata\": {},\n \"secure\": false,\n \"auto_pause\": false,\n \"egress_control\": false,\n \"egress\": {\n \"allowed_hostnames\": [\n \"<string>\"\n ],\n \"allowed_cidrs\": [\n \"<string>\"\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://console.gmicloud.ai/api/v2/sandboxes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"template_id\": \"<string>\",\n \"snapshot_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"product\": \"gmi.sandbox.large\",\n \"idc_name\": \"<string>\",\n \"timeout\": 2,\n \"env_vars\": {},\n \"metadata\": {},\n \"secure\": false,\n \"auto_pause\": false,\n \"egress_control\": false,\n \"egress\": {\n \"allowed_hostnames\": [\n \"<string>\"\n ],\n \"allowed_cidrs\": [\n \"<string>\"\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"request_id": "<string>",
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"sandbox_key": "<string>",
"template_id": "<string>",
"domain": "<string>",
"sandbox_access_token": "<string>",
"traffic_access_token": "<string>"
}
}{
"code": "Parameter.Invalid",
"message": "Invalid request parameters",
"request_id": "req-xxxx"
}{
"code": "Auth.Unauthorized",
"message": "Authentication required",
"request_id": "req-xxxx"
}{
"code": "Resource.QuotaExceeded",
"message": "The resource quota is not enough.",
"request_id": "req-xxxx",
"trace_id": "<string>",
"details": {}
}{
"code": "Resource.NotFound",
"message": "The requested resource was not found",
"request_id": "req-xxxx"
}{
"code": "Resource.QuotaExceeded",
"message": "The resource quota is not enough.",
"request_id": "req-xxxx",
"trace_id": "<string>",
"details": {}
}{
"code": "Template.ProviderNotSupported",
"message": "The selected IDC does not support this template operation",
"request_id": "req-xxxx"
}{
"code": "Resource.QuotaExceeded",
"message": "The resource quota is not enough.",
"request_id": "req-xxxx",
"trace_id": "<string>",
"details": {}
}{
"code": "Request.Canceled",
"message": "Request canceled",
"request_id": "req-xxxx"
}{
"code": "System.Internal",
"message": "An internal server error occurred",
"request_id": "req-xxxx"
}{
"code": "Request.Timeout",
"message": "Request timed out",
"request_id": "req-xxxx"
}Authorizations
Headers
Optional caller-generated idempotency key (a UUID is recommended). Matched byte-for-byte: 1-64 printable ASCII characters, no whitespace. Absent means no deduplication. The same key with a different request body returns 400 Sandbox.IdempotentParameterMismatch. Echoed on responses; replays add Idempotency-Replayed: true. Keys are remembered for 24 hours.
1 - 64Body
- Option 1
- Option 2
Target data center name, e.g. us-central1-c. Optional: when omitted, the organization's configured default data center is used (maintained by the platform administrator); if the organization has no default configured, the request returns 400. If the effective data center is under maintenance, the request returns 409 IDC.UnderMaintenance. Note that Templates are bound to a data center: the effective data center (whether explicit or default) must match the one that owns the Template or snapshot referenced by the request, otherwise a Template is reported as not found (400 Parameter.Invalid); a snapshot that exists but belongs to another data center also returns 400 Parameter.Invalid (404 Resource.NotFound is returned only when the snapshot does not exist).
Time-to-live in seconds. When omitted, 300 seconds is used. An explicit value must be at least 1; 0 or a negative value returns 400 Parameter.Invalid. At most 86400 (24 hours) in the selected IDC; a larger value returns 400 Parameter.Invalid. The limit can differ by IDC.
x >= 1