curl --request POST \
--url https://console.gmicloud.ai/api/v2/snapshots \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"sandbox_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"metadata": {}
}
'import requests
url = "https://console.gmicloud.ai/api/v2/snapshots"
payload = {
"sandbox_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"metadata": {}
}
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({
sandbox_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
name: '<string>',
metadata: {}
})
};
fetch('https://console.gmicloud.ai/api/v2/snapshots', 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/snapshots",
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([
'sandbox_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'name' => '<string>',
'metadata' => [
]
]),
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/snapshots"
payload := strings.NewReader("{\n \"sandbox_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\",\n \"metadata\": {}\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/snapshots")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"sandbox_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://console.gmicloud.ai/api/v2/snapshots")
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 \"sandbox_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"request_id": "<string>",
"data": {
"snapshot_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"idc_name": "<string>",
"name": "<string>",
"status": "creating",
"source_sandbox_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"source_template_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"source_build_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"vcpu": 123,
"ram_mb": 123,
"disk_size_mb": 123,
"architecture": "<string>",
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"product": "<string>",
"product_name": "<string>",
"failure_code": "<string>",
"status_reason": "<string>",
"ready_at": "2023-11-07T05:31:56Z"
}
}{
"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": "System.Internal",
"message": "An internal server error occurred",
"request_id": "req-xxxx"
}Create a durable snapshot
Creates a durable snapshot from a running sandbox in the current tenant.
The snapshot can be queried immediately, while creation completes asynchronously.
Poll GET /snapshots/ until status becomes ready or error.
A ready snapshot can be supplied as snapshot_id to POST /sandboxes.
A snapshot captures the sandbox filesystem only: running processes and
in-memory state are not preserved, and a sandbox created from it boots fresh
from the saved disk. The source sandbox keeps running.
If snapshot creation is unsupported for the source sandbox, the request
returns 422 Snapshot.UnsupportedOnProvider.
Idempotency-Key is optional. Within the 24-hour deduplication window,
repeating a key with identical parameters returns the same snapshot with its
current status and Idempotency-Replayed: true, including while creating
and after it becomes ready. Different parameters return 400
Sandbox.IdempotentParameterMismatch. Without the header, no deduplication
is performed.
The source sandbox must be running, otherwise 409 Snapshot.SourceNotRunning.
While another snapshot of the same sandbox is being created, a new request
may return 409 Snapshot.CreateInProgress, including temporarily after a
previous snapshot was cancelled with DELETE. Wait before retrying and ensure
the source sandbox is running.
A definitive snapshot creation failure returns 201 with a queryable snapshot in
error and failure_code: Snapshot.ProviderCreateFailed. Replaying that
key returns the same error snapshot without creating another.
Some failed creation attempts consume the idempotency key; replay returns
409 Sandbox.IdempotentKeyConsumed. Error details include failure_code
and snapshot_id; the failed snapshot remains readable through GET.
Retry with a new Idempotency-Key. A deleted snapshot also consumes its
original key.
Non-empty names are case-sensitive and unique within the organization across
all IDCs. A name held by another snapshot returns 409 Resource.AlreadyExists.
Empty names may be shared. Creation failure clears the name atomically;
the failed record remains readable by snapshot_id. Use a new Idempotency-Key
to retry with the same name once the source sandbox is running again.
Name release does not change whether a key can be replayed. A definitive
Snapshot.ProviderCreateFailed result remains replayable and returns the
current record, whose name is cleared on failure. Failures detected while
the create request is being handled, such as a source lease or workflow
handoff failure, consume the key; replay returns 409
Sandbox.IdempotentKeyConsumed without a snapshot record. Failures settled
later in the background, such as a failed creation workflow or an expired
creation deadline, leave the key replayable; replay returns the current
error record with its cleared name.
Use snapshot_id to query a failed attempt; use a new key to create another.
curl --request POST \
--url https://console.gmicloud.ai/api/v2/snapshots \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"sandbox_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"metadata": {}
}
'import requests
url = "https://console.gmicloud.ai/api/v2/snapshots"
payload = {
"sandbox_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"metadata": {}
}
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({
sandbox_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
name: '<string>',
metadata: {}
})
};
fetch('https://console.gmicloud.ai/api/v2/snapshots', 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/snapshots",
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([
'sandbox_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'name' => '<string>',
'metadata' => [
]
]),
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/snapshots"
payload := strings.NewReader("{\n \"sandbox_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\",\n \"metadata\": {}\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/snapshots")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"sandbox_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://console.gmicloud.ai/api/v2/snapshots")
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 \"sandbox_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"request_id": "<string>",
"data": {
"snapshot_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"idc_name": "<string>",
"name": "<string>",
"status": "creating",
"source_sandbox_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"source_template_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"source_build_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"vcpu": 123,
"ram_mb": 123,
"disk_size_mb": 123,
"architecture": "<string>",
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"product": "<string>",
"product_name": "<string>",
"failure_code": "<string>",
"status_reason": "<string>",
"ready_at": "2023-11-07T05:31:56Z"
}
}{
"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": "System.Internal",
"message": "An internal server error occurred",
"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 - 64