Snapshot a sandbox
Captures the sandbox into a saved snapshot of its memory and disk,
kept until deleted. A new sandbox is created from it with
from_snapshot on POST /sandboxes, resuming with its processes
intact. The sandbox must be active or paused. A running sandbox is
paused for the capture: under a second for the first memory snapshot
of a sandbox, longer when all of memory has to be written. The call
returns once the snapshot is ready; if the host’s answer is lost on
the way, it returns the snapshot still creating and the platform
settles it with the host shortly. Snapshots outlive the sandbox they
came from.
Pass idempotency_key to make a retry return the snapshot the first
request made instead of taking another, whatever became of it since.
curl --request POST \
--url https://api.superserve.ai/sandboxes/{sandbox_id}/snapshot \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"kind": "mem+fs",
"name": "<string>",
"idempotency_key": "<string>"
}
'import requests
url = "https://api.superserve.ai/sandboxes/{sandbox_id}/snapshot"
payload = {
"kind": "mem+fs",
"name": "<string>",
"idempotency_key": "<string>"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({kind: 'mem+fs', name: '<string>', idempotency_key: '<string>'})
};
fetch('https://api.superserve.ai/sandboxes/{sandbox_id}/snapshot', 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://api.superserve.ai/sandboxes/{sandbox_id}/snapshot",
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([
'kind' => 'mem+fs',
'name' => '<string>',
'idempotency_key' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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://api.superserve.ai/sandboxes/{sandbox_id}/snapshot"
payload := strings.NewReader("{\n \"kind\": \"mem+fs\",\n \"name\": \"<string>\",\n \"idempotency_key\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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://api.superserve.ai/sandboxes/{sandbox_id}/snapshot")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"kind\": \"mem+fs\",\n \"name\": \"<string>\",\n \"idempotency_key\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.superserve.ai/sandboxes/{sandbox_id}/snapshot")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"kind\": \"mem+fs\",\n \"name\": \"<string>\",\n \"idempotency_key\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"sandbox_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"kind": "mem+fs",
"status": "creating",
"size_bytes": 123,
"resources": {
"vcpu_count": 123,
"memory_mib": 123,
"disk_mib": 123
},
"created_at": "2023-11-07T05:31:56Z",
"template_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"ready_at": "2023-11-07T05:31:56Z"
}{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"sandbox_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"kind": "mem+fs",
"status": "creating",
"size_bytes": 123,
"resources": {
"vcpu_count": 123,
"memory_mib": 123,
"disk_mib": 123
},
"created_at": "2023-11-07T05:31:56Z",
"template_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"ready_at": "2023-11-07T05:31:56Z"
}{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"sandbox_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"kind": "mem+fs",
"status": "creating",
"size_bytes": 123,
"resources": {
"vcpu_count": 123,
"memory_mib": 123,
"disk_mib": 123
},
"created_at": "2023-11-07T05:31:56Z",
"template_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"ready_at": "2023-11-07T05:31:56Z"
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}Authorizations
Path Parameters
The unique identifier of the sandbox.
Public sandbox ID: a bare UUID, or the region-tagged form sb-<region>-<uuid> (e.g. sb-use-1b4e28ba-…). Treat as an opaque string; the tagged form routes the request to the sandbox's home region. Endpoints accept both forms interchangeably.
^(sb-[a-z0-9]+-)?[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$Body
mem+fs captures memory and disk. A disk-only kind is not offered yet.
mem+fs Optional label. Can be changed later with PATCH.
1 - 64Caller-chosen key, unique per sandbox. A retry carrying the same key returns the snapshot the first request made.
1 - 255Response
A snapshot an earlier request with the same idempotency_key made
The sandbox the snapshot was taken from. It may since have been deleted.
mem+fs creating, ready, failed, deleting Bytes the snapshot holds on disk; 0 until ready.
Show child attributes
Show child attributes
The template the captured sandbox was created from.
curl --request POST \
--url https://api.superserve.ai/sandboxes/{sandbox_id}/snapshot \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"kind": "mem+fs",
"name": "<string>",
"idempotency_key": "<string>"
}
'import requests
url = "https://api.superserve.ai/sandboxes/{sandbox_id}/snapshot"
payload = {
"kind": "mem+fs",
"name": "<string>",
"idempotency_key": "<string>"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({kind: 'mem+fs', name: '<string>', idempotency_key: '<string>'})
};
fetch('https://api.superserve.ai/sandboxes/{sandbox_id}/snapshot', 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://api.superserve.ai/sandboxes/{sandbox_id}/snapshot",
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([
'kind' => 'mem+fs',
'name' => '<string>',
'idempotency_key' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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://api.superserve.ai/sandboxes/{sandbox_id}/snapshot"
payload := strings.NewReader("{\n \"kind\": \"mem+fs\",\n \"name\": \"<string>\",\n \"idempotency_key\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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://api.superserve.ai/sandboxes/{sandbox_id}/snapshot")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"kind\": \"mem+fs\",\n \"name\": \"<string>\",\n \"idempotency_key\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.superserve.ai/sandboxes/{sandbox_id}/snapshot")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"kind\": \"mem+fs\",\n \"name\": \"<string>\",\n \"idempotency_key\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"sandbox_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"kind": "mem+fs",
"status": "creating",
"size_bytes": 123,
"resources": {
"vcpu_count": 123,
"memory_mib": 123,
"disk_mib": 123
},
"created_at": "2023-11-07T05:31:56Z",
"template_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"ready_at": "2023-11-07T05:31:56Z"
}{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"sandbox_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"kind": "mem+fs",
"status": "creating",
"size_bytes": 123,
"resources": {
"vcpu_count": 123,
"memory_mib": 123,
"disk_mib": 123
},
"created_at": "2023-11-07T05:31:56Z",
"template_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"ready_at": "2023-11-07T05:31:56Z"
}{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"sandbox_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"kind": "mem+fs",
"status": "creating",
"size_bytes": 123,
"resources": {
"vcpu_count": 123,
"memory_mib": 123,
"disk_mib": 123
},
"created_at": "2023-11-07T05:31:56Z",
"template_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"ready_at": "2023-11-07T05:31:56Z"
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}