curl --request POST \
--url https://api.cwsandbox.com/v1/sandboxes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"spec": {
"containers": [
{
"name": "<string>",
"image": "<string>",
"command": "<string>",
"args": [
"<string>"
],
"environmentVariables": {},
"resources": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
},
"files": [
{
"path": "<string>",
"content": "<string>"
}
],
"volumeMounts": [
{
"volume": "<string>",
"mountPath": "<string>",
"readOnly": true,
"subPath": "<string>"
}
],
"secretStores": [
{
"storeName": "<string>",
"secrets": [
{
"path": "<string>",
"envVar": "<string>",
"field": "<string>"
}
]
}
],
"workingDir": "<string>",
"resourceRequirements": {
"requests": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
},
"limits": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
}
},
"securityContext": {
"runAsUser": 123,
"runAsGroup": 123,
"privileged": true,
"allowPrivilegeEscalation": true,
"readOnlyRootFilesystem": true,
"capabilitiesAdd": [
"<string>"
],
"capabilitiesDrop": [
"<string>"
],
"seccompProfile": "<string>"
},
"primary": true,
"startupProbe": {
"exec": [
"<string>"
],
"periodSeconds": 123,
"timeoutSeconds": 123,
"failureThreshold": 123,
"initialDelaySeconds": 123
}
}
],
"volumes": [
{
"name": "<string>",
"scratch": {
"size": "<string>",
"restoreFromSnapshotId": "<string>"
},
"volumeId": "<string>"
}
],
"services": [
{
"port": 123,
"name": "<string>"
}
],
"maxLifetimeSeconds": 123,
"networkIds": [
"<string>"
],
"objectStorageAccess": {
"buckets": [
"<string>"
],
"objectPrefix": "<string>"
},
"tags": [
"<string>"
],
"runnerIds": [
"<string>"
],
"network": {
"ingress": [
{
"any": true,
"ports": [
{
"port": 123,
"protocol": "<string>",
"endPort": 123
}
]
}
],
"egress": [
{
"httpsHostname": "<string>",
"any": true,
"ports": [
{
"port": 123,
"protocol": "<string>",
"endPort": 123
}
],
"httpsHostnameExcept": [
"<string>"
]
}
],
"denyEgress": true,
"denyIngress": true
},
"annotations": {},
"instanceType": "<string>",
"runtimeClass": "<string>",
"networkConfigId": "<string>"
},
"displayName": "<string>"
}
'import requests
url = "https://api.cwsandbox.com/v1/sandboxes"
payload = {
"spec": {
"containers": [
{
"name": "<string>",
"image": "<string>",
"command": "<string>",
"args": ["<string>"],
"environmentVariables": {},
"resources": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
},
"files": [
{
"path": "<string>",
"content": "<string>"
}
],
"volumeMounts": [
{
"volume": "<string>",
"mountPath": "<string>",
"readOnly": True,
"subPath": "<string>"
}
],
"secretStores": [
{
"storeName": "<string>",
"secrets": [
{
"path": "<string>",
"envVar": "<string>",
"field": "<string>"
}
]
}
],
"workingDir": "<string>",
"resourceRequirements": {
"requests": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
},
"limits": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
}
},
"securityContext": {
"runAsUser": 123,
"runAsGroup": 123,
"privileged": True,
"allowPrivilegeEscalation": True,
"readOnlyRootFilesystem": True,
"capabilitiesAdd": ["<string>"],
"capabilitiesDrop": ["<string>"],
"seccompProfile": "<string>"
},
"primary": True,
"startupProbe": {
"exec": ["<string>"],
"periodSeconds": 123,
"timeoutSeconds": 123,
"failureThreshold": 123,
"initialDelaySeconds": 123
}
}
],
"volumes": [
{
"name": "<string>",
"scratch": {
"size": "<string>",
"restoreFromSnapshotId": "<string>"
},
"volumeId": "<string>"
}
],
"services": [
{
"port": 123,
"name": "<string>"
}
],
"maxLifetimeSeconds": 123,
"networkIds": ["<string>"],
"objectStorageAccess": {
"buckets": ["<string>"],
"objectPrefix": "<string>"
},
"tags": ["<string>"],
"runnerIds": ["<string>"],
"network": {
"ingress": [
{
"any": True,
"ports": [
{
"port": 123,
"protocol": "<string>",
"endPort": 123
}
]
}
],
"egress": [
{
"httpsHostname": "<string>",
"any": True,
"ports": [
{
"port": 123,
"protocol": "<string>",
"endPort": 123
}
],
"httpsHostnameExcept": ["<string>"]
}
],
"denyEgress": True,
"denyIngress": True
},
"annotations": {},
"instanceType": "<string>",
"runtimeClass": "<string>",
"networkConfigId": "<string>"
},
"displayName": "<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({
spec: {
containers: [
{
name: '<string>',
image: '<string>',
command: '<string>',
args: ['<string>'],
environmentVariables: {},
resources: {
cpu: '<string>',
memory: '<string>',
gpu: {count: '<string>', type: '<string>', memoryGb: '<string>'}
},
files: [{path: '<string>', content: '<string>'}],
volumeMounts: [
{volume: '<string>', mountPath: '<string>', readOnly: true, subPath: '<string>'}
],
secretStores: [
{
storeName: '<string>',
secrets: [{path: '<string>', envVar: '<string>', field: '<string>'}]
}
],
workingDir: '<string>',
resourceRequirements: {
requests: {
cpu: '<string>',
memory: '<string>',
gpu: {count: '<string>', type: '<string>', memoryGb: '<string>'}
},
limits: {
cpu: '<string>',
memory: '<string>',
gpu: {count: '<string>', type: '<string>', memoryGb: '<string>'}
}
},
securityContext: {
runAsUser: 123,
runAsGroup: 123,
privileged: true,
allowPrivilegeEscalation: true,
readOnlyRootFilesystem: true,
capabilitiesAdd: ['<string>'],
capabilitiesDrop: ['<string>'],
seccompProfile: '<string>'
},
primary: true,
startupProbe: {
exec: ['<string>'],
periodSeconds: 123,
timeoutSeconds: 123,
failureThreshold: 123,
initialDelaySeconds: 123
}
}
],
volumes: [
{
name: '<string>',
scratch: {size: '<string>', restoreFromSnapshotId: '<string>'},
volumeId: '<string>'
}
],
services: [{port: 123, name: '<string>'}],
maxLifetimeSeconds: 123,
networkIds: ['<string>'],
objectStorageAccess: {buckets: ['<string>'], objectPrefix: '<string>'},
tags: ['<string>'],
runnerIds: ['<string>'],
network: {
ingress: [{any: true, ports: [{port: 123, protocol: '<string>', endPort: 123}]}],
egress: [
{
httpsHostname: '<string>',
any: true,
ports: [{port: 123, protocol: '<string>', endPort: 123}],
httpsHostnameExcept: ['<string>']
}
],
denyEgress: true,
denyIngress: true
},
annotations: {},
instanceType: '<string>',
runtimeClass: '<string>',
networkConfigId: '<string>'
},
displayName: '<string>'
})
};
fetch('https://api.cwsandbox.com/v1/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://api.cwsandbox.com/v1/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([
'spec' => [
'containers' => [
[
'name' => '<string>',
'image' => '<string>',
'command' => '<string>',
'args' => [
'<string>'
],
'environmentVariables' => [
],
'resources' => [
'cpu' => '<string>',
'memory' => '<string>',
'gpu' => [
'count' => '<string>',
'type' => '<string>',
'memoryGb' => '<string>'
]
],
'files' => [
[
'path' => '<string>',
'content' => '<string>'
]
],
'volumeMounts' => [
[
'volume' => '<string>',
'mountPath' => '<string>',
'readOnly' => true,
'subPath' => '<string>'
]
],
'secretStores' => [
[
'storeName' => '<string>',
'secrets' => [
[
'path' => '<string>',
'envVar' => '<string>',
'field' => '<string>'
]
]
]
],
'workingDir' => '<string>',
'resourceRequirements' => [
'requests' => [
'cpu' => '<string>',
'memory' => '<string>',
'gpu' => [
'count' => '<string>',
'type' => '<string>',
'memoryGb' => '<string>'
]
],
'limits' => [
'cpu' => '<string>',
'memory' => '<string>',
'gpu' => [
'count' => '<string>',
'type' => '<string>',
'memoryGb' => '<string>'
]
]
],
'securityContext' => [
'runAsUser' => 123,
'runAsGroup' => 123,
'privileged' => true,
'allowPrivilegeEscalation' => true,
'readOnlyRootFilesystem' => true,
'capabilitiesAdd' => [
'<string>'
],
'capabilitiesDrop' => [
'<string>'
],
'seccompProfile' => '<string>'
],
'primary' => true,
'startupProbe' => [
'exec' => [
'<string>'
],
'periodSeconds' => 123,
'timeoutSeconds' => 123,
'failureThreshold' => 123,
'initialDelaySeconds' => 123
]
]
],
'volumes' => [
[
'name' => '<string>',
'scratch' => [
'size' => '<string>',
'restoreFromSnapshotId' => '<string>'
],
'volumeId' => '<string>'
]
],
'services' => [
[
'port' => 123,
'name' => '<string>'
]
],
'maxLifetimeSeconds' => 123,
'networkIds' => [
'<string>'
],
'objectStorageAccess' => [
'buckets' => [
'<string>'
],
'objectPrefix' => '<string>'
],
'tags' => [
'<string>'
],
'runnerIds' => [
'<string>'
],
'network' => [
'ingress' => [
[
'any' => true,
'ports' => [
[
'port' => 123,
'protocol' => '<string>',
'endPort' => 123
]
]
]
],
'egress' => [
[
'httpsHostname' => '<string>',
'any' => true,
'ports' => [
[
'port' => 123,
'protocol' => '<string>',
'endPort' => 123
]
],
'httpsHostnameExcept' => [
'<string>'
]
]
],
'denyEgress' => true,
'denyIngress' => true
],
'annotations' => [
],
'instanceType' => '<string>',
'runtimeClass' => '<string>',
'networkConfigId' => '<string>'
],
'displayName' => '<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://api.cwsandbox.com/v1/sandboxes"
payload := strings.NewReader("{\n \"spec\": {\n \"containers\": [\n {\n \"name\": \"<string>\",\n \"image\": \"<string>\",\n \"command\": \"<string>\",\n \"args\": [\n \"<string>\"\n ],\n \"environmentVariables\": {},\n \"resources\": {\n \"cpu\": \"<string>\",\n \"memory\": \"<string>\",\n \"gpu\": {\n \"count\": \"<string>\",\n \"type\": \"<string>\",\n \"memoryGb\": \"<string>\"\n }\n },\n \"files\": [\n {\n \"path\": \"<string>\",\n \"content\": \"<string>\"\n }\n ],\n \"volumeMounts\": [\n {\n \"volume\": \"<string>\",\n \"mountPath\": \"<string>\",\n \"readOnly\": true,\n \"subPath\": \"<string>\"\n }\n ],\n \"secretStores\": [\n {\n \"storeName\": \"<string>\",\n \"secrets\": [\n {\n \"path\": \"<string>\",\n \"envVar\": \"<string>\",\n \"field\": \"<string>\"\n }\n ]\n }\n ],\n \"workingDir\": \"<string>\",\n \"resourceRequirements\": {\n \"requests\": {\n \"cpu\": \"<string>\",\n \"memory\": \"<string>\",\n \"gpu\": {\n \"count\": \"<string>\",\n \"type\": \"<string>\",\n \"memoryGb\": \"<string>\"\n }\n },\n \"limits\": {\n \"cpu\": \"<string>\",\n \"memory\": \"<string>\",\n \"gpu\": {\n \"count\": \"<string>\",\n \"type\": \"<string>\",\n \"memoryGb\": \"<string>\"\n }\n }\n },\n \"securityContext\": {\n \"runAsUser\": 123,\n \"runAsGroup\": 123,\n \"privileged\": true,\n \"allowPrivilegeEscalation\": true,\n \"readOnlyRootFilesystem\": true,\n \"capabilitiesAdd\": [\n \"<string>\"\n ],\n \"capabilitiesDrop\": [\n \"<string>\"\n ],\n \"seccompProfile\": \"<string>\"\n },\n \"primary\": true,\n \"startupProbe\": {\n \"exec\": [\n \"<string>\"\n ],\n \"periodSeconds\": 123,\n \"timeoutSeconds\": 123,\n \"failureThreshold\": 123,\n \"initialDelaySeconds\": 123\n }\n }\n ],\n \"volumes\": [\n {\n \"name\": \"<string>\",\n \"scratch\": {\n \"size\": \"<string>\",\n \"restoreFromSnapshotId\": \"<string>\"\n },\n \"volumeId\": \"<string>\"\n }\n ],\n \"services\": [\n {\n \"port\": 123,\n \"name\": \"<string>\"\n }\n ],\n \"maxLifetimeSeconds\": 123,\n \"networkIds\": [\n \"<string>\"\n ],\n \"objectStorageAccess\": {\n \"buckets\": [\n \"<string>\"\n ],\n \"objectPrefix\": \"<string>\"\n },\n \"tags\": [\n \"<string>\"\n ],\n \"runnerIds\": [\n \"<string>\"\n ],\n \"network\": {\n \"ingress\": [\n {\n \"any\": true,\n \"ports\": [\n {\n \"port\": 123,\n \"protocol\": \"<string>\",\n \"endPort\": 123\n }\n ]\n }\n ],\n \"egress\": [\n {\n \"httpsHostname\": \"<string>\",\n \"any\": true,\n \"ports\": [\n {\n \"port\": 123,\n \"protocol\": \"<string>\",\n \"endPort\": 123\n }\n ],\n \"httpsHostnameExcept\": [\n \"<string>\"\n ]\n }\n ],\n \"denyEgress\": true,\n \"denyIngress\": true\n },\n \"annotations\": {},\n \"instanceType\": \"<string>\",\n \"runtimeClass\": \"<string>\",\n \"networkConfigId\": \"<string>\"\n },\n \"displayName\": \"<string>\"\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://api.cwsandbox.com/v1/sandboxes")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"spec\": {\n \"containers\": [\n {\n \"name\": \"<string>\",\n \"image\": \"<string>\",\n \"command\": \"<string>\",\n \"args\": [\n \"<string>\"\n ],\n \"environmentVariables\": {},\n \"resources\": {\n \"cpu\": \"<string>\",\n \"memory\": \"<string>\",\n \"gpu\": {\n \"count\": \"<string>\",\n \"type\": \"<string>\",\n \"memoryGb\": \"<string>\"\n }\n },\n \"files\": [\n {\n \"path\": \"<string>\",\n \"content\": \"<string>\"\n }\n ],\n \"volumeMounts\": [\n {\n \"volume\": \"<string>\",\n \"mountPath\": \"<string>\",\n \"readOnly\": true,\n \"subPath\": \"<string>\"\n }\n ],\n \"secretStores\": [\n {\n \"storeName\": \"<string>\",\n \"secrets\": [\n {\n \"path\": \"<string>\",\n \"envVar\": \"<string>\",\n \"field\": \"<string>\"\n }\n ]\n }\n ],\n \"workingDir\": \"<string>\",\n \"resourceRequirements\": {\n \"requests\": {\n \"cpu\": \"<string>\",\n \"memory\": \"<string>\",\n \"gpu\": {\n \"count\": \"<string>\",\n \"type\": \"<string>\",\n \"memoryGb\": \"<string>\"\n }\n },\n \"limits\": {\n \"cpu\": \"<string>\",\n \"memory\": \"<string>\",\n \"gpu\": {\n \"count\": \"<string>\",\n \"type\": \"<string>\",\n \"memoryGb\": \"<string>\"\n }\n }\n },\n \"securityContext\": {\n \"runAsUser\": 123,\n \"runAsGroup\": 123,\n \"privileged\": true,\n \"allowPrivilegeEscalation\": true,\n \"readOnlyRootFilesystem\": true,\n \"capabilitiesAdd\": [\n \"<string>\"\n ],\n \"capabilitiesDrop\": [\n \"<string>\"\n ],\n \"seccompProfile\": \"<string>\"\n },\n \"primary\": true,\n \"startupProbe\": {\n \"exec\": [\n \"<string>\"\n ],\n \"periodSeconds\": 123,\n \"timeoutSeconds\": 123,\n \"failureThreshold\": 123,\n \"initialDelaySeconds\": 123\n }\n }\n ],\n \"volumes\": [\n {\n \"name\": \"<string>\",\n \"scratch\": {\n \"size\": \"<string>\",\n \"restoreFromSnapshotId\": \"<string>\"\n },\n \"volumeId\": \"<string>\"\n }\n ],\n \"services\": [\n {\n \"port\": 123,\n \"name\": \"<string>\"\n }\n ],\n \"maxLifetimeSeconds\": 123,\n \"networkIds\": [\n \"<string>\"\n ],\n \"objectStorageAccess\": {\n \"buckets\": [\n \"<string>\"\n ],\n \"objectPrefix\": \"<string>\"\n },\n \"tags\": [\n \"<string>\"\n ],\n \"runnerIds\": [\n \"<string>\"\n ],\n \"network\": {\n \"ingress\": [\n {\n \"any\": true,\n \"ports\": [\n {\n \"port\": 123,\n \"protocol\": \"<string>\",\n \"endPort\": 123\n }\n ]\n }\n ],\n \"egress\": [\n {\n \"httpsHostname\": \"<string>\",\n \"any\": true,\n \"ports\": [\n {\n \"port\": 123,\n \"protocol\": \"<string>\",\n \"endPort\": 123\n }\n ],\n \"httpsHostnameExcept\": [\n \"<string>\"\n ]\n }\n ],\n \"denyEgress\": true,\n \"denyIngress\": true\n },\n \"annotations\": {},\n \"instanceType\": \"<string>\",\n \"runtimeClass\": \"<string>\",\n \"networkConfigId\": \"<string>\"\n },\n \"displayName\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cwsandbox.com/v1/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 \"spec\": {\n \"containers\": [\n {\n \"name\": \"<string>\",\n \"image\": \"<string>\",\n \"command\": \"<string>\",\n \"args\": [\n \"<string>\"\n ],\n \"environmentVariables\": {},\n \"resources\": {\n \"cpu\": \"<string>\",\n \"memory\": \"<string>\",\n \"gpu\": {\n \"count\": \"<string>\",\n \"type\": \"<string>\",\n \"memoryGb\": \"<string>\"\n }\n },\n \"files\": [\n {\n \"path\": \"<string>\",\n \"content\": \"<string>\"\n }\n ],\n \"volumeMounts\": [\n {\n \"volume\": \"<string>\",\n \"mountPath\": \"<string>\",\n \"readOnly\": true,\n \"subPath\": \"<string>\"\n }\n ],\n \"secretStores\": [\n {\n \"storeName\": \"<string>\",\n \"secrets\": [\n {\n \"path\": \"<string>\",\n \"envVar\": \"<string>\",\n \"field\": \"<string>\"\n }\n ]\n }\n ],\n \"workingDir\": \"<string>\",\n \"resourceRequirements\": {\n \"requests\": {\n \"cpu\": \"<string>\",\n \"memory\": \"<string>\",\n \"gpu\": {\n \"count\": \"<string>\",\n \"type\": \"<string>\",\n \"memoryGb\": \"<string>\"\n }\n },\n \"limits\": {\n \"cpu\": \"<string>\",\n \"memory\": \"<string>\",\n \"gpu\": {\n \"count\": \"<string>\",\n \"type\": \"<string>\",\n \"memoryGb\": \"<string>\"\n }\n }\n },\n \"securityContext\": {\n \"runAsUser\": 123,\n \"runAsGroup\": 123,\n \"privileged\": true,\n \"allowPrivilegeEscalation\": true,\n \"readOnlyRootFilesystem\": true,\n \"capabilitiesAdd\": [\n \"<string>\"\n ],\n \"capabilitiesDrop\": [\n \"<string>\"\n ],\n \"seccompProfile\": \"<string>\"\n },\n \"primary\": true,\n \"startupProbe\": {\n \"exec\": [\n \"<string>\"\n ],\n \"periodSeconds\": 123,\n \"timeoutSeconds\": 123,\n \"failureThreshold\": 123,\n \"initialDelaySeconds\": 123\n }\n }\n ],\n \"volumes\": [\n {\n \"name\": \"<string>\",\n \"scratch\": {\n \"size\": \"<string>\",\n \"restoreFromSnapshotId\": \"<string>\"\n },\n \"volumeId\": \"<string>\"\n }\n ],\n \"services\": [\n {\n \"port\": 123,\n \"name\": \"<string>\"\n }\n ],\n \"maxLifetimeSeconds\": 123,\n \"networkIds\": [\n \"<string>\"\n ],\n \"objectStorageAccess\": {\n \"buckets\": [\n \"<string>\"\n ],\n \"objectPrefix\": \"<string>\"\n },\n \"tags\": [\n \"<string>\"\n ],\n \"runnerIds\": [\n \"<string>\"\n ],\n \"network\": {\n \"ingress\": [\n {\n \"any\": true,\n \"ports\": [\n {\n \"port\": 123,\n \"protocol\": \"<string>\",\n \"endPort\": 123\n }\n ]\n }\n ],\n \"egress\": [\n {\n \"httpsHostname\": \"<string>\",\n \"any\": true,\n \"ports\": [\n {\n \"port\": 123,\n \"protocol\": \"<string>\",\n \"endPort\": 123\n }\n ],\n \"httpsHostnameExcept\": [\n \"<string>\"\n ]\n }\n ],\n \"denyEgress\": true,\n \"denyIngress\": true\n },\n \"annotations\": {},\n \"instanceType\": \"<string>\",\n \"runtimeClass\": \"<string>\",\n \"networkConfigId\": \"<string>\"\n },\n \"displayName\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"spec": {
"containers": [
{
"name": "<string>",
"image": "<string>",
"command": "<string>",
"args": [
"<string>"
],
"environmentVariables": {},
"resources": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
},
"files": [
{
"path": "<string>",
"content": "<string>"
}
],
"volumeMounts": [
{
"volume": "<string>",
"mountPath": "<string>",
"readOnly": true,
"subPath": "<string>"
}
],
"secretStores": [
{
"storeName": "<string>",
"secrets": [
{
"path": "<string>",
"envVar": "<string>",
"field": "<string>"
}
]
}
],
"workingDir": "<string>",
"resourceRequirements": {
"requests": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
},
"limits": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
}
},
"securityContext": {
"runAsUser": 123,
"runAsGroup": 123,
"privileged": true,
"allowPrivilegeEscalation": true,
"readOnlyRootFilesystem": true,
"capabilitiesAdd": [
"<string>"
],
"capabilitiesDrop": [
"<string>"
],
"seccompProfile": "<string>"
},
"imagePullCredentials": {
"registry": "<string>",
"credentials": {
"storeName": "<string>",
"path": "<string>",
"field": "<string>"
}
},
"primary": true,
"startupProbe": {
"exec": [
"<string>"
],
"periodSeconds": 123,
"timeoutSeconds": 123,
"failureThreshold": 123,
"initialDelaySeconds": 123
}
}
],
"volumes": [
{
"name": "<string>",
"scratch": {
"size": "<string>",
"medium": "STORAGE_MEDIUM_UNSPECIFIED",
"restoreFromSnapshotId": "<string>"
},
"volumeId": "<string>"
}
],
"services": [
{
"port": 123,
"name": "<string>",
"protocol": "SERVICE_PROTOCOL_UNSPECIFIED",
"visibility": "VISIBILITY_UNSPECIFIED",
"endpoint": {
"kind": "ENDPOINT_KIND_UNSPECIFIED",
"auth": "ENDPOINT_AUTH_UNSPECIFIED",
"requestTimeoutSeconds": 123
}
}
],
"maxLifetimeSeconds": 123,
"networkIds": [
"<string>"
],
"objectStorageAccess": {
"buckets": [
"<string>"
],
"permission": "OBJECT_STORAGE_PERMISSION_UNSPECIFIED",
"objectPrefix": "<string>"
},
"tags": [
"<string>"
],
"runnerIds": [
"<string>"
],
"annotations": {},
"instanceType": "<string>",
"mode": "SANDBOX_MODE_UNSPECIFIED",
"runtimeClass": "<string>",
"networkConfigId": "<string>",
"runtimeClassSelection": "RUNTIME_CLASS_UNSPECIFIED"
},
"sandboxId": "<string>",
"status": {
"state": "STATE_UNSPECIFIED",
"stateReason": "<string>",
"createTime": "2023-11-07T05:31:56Z",
"startTime": "2023-11-07T05:31:56Z",
"endTime": "2023-11-07T05:31:56Z",
"services": [
{
"port": 123,
"name": "<string>",
"protocol": "SERVICE_PROTOCOL_UNSPECIFIED",
"visibility": "VISIBILITY_UNSPECIFIED",
"endpoint": {
"kind": "ENDPOINT_KIND_UNSPECIFIED",
"auth": "ENDPOINT_AUTH_UNSPECIFIED",
"url": "<string>",
"requestTimeoutSeconds": 123,
"address": "<string>"
},
"url": "<string>"
}
],
"resourceUsage": {
"cpuMillicores": "<string>",
"memoryMb": "<string>",
"gpuCount": "<string>"
},
"exitCode": 123,
"effectiveResources": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
},
"effectiveMaxLifetimeSeconds": 123,
"containerStatuses": [
{
"name": "<string>",
"state": "STATE_UNSPECIFIED",
"exitCode": 123,
"restartCount": 123
}
],
"runnerId": "<string>",
"runnerGroupId": "<string>",
"effectiveIngress": [
{
"cidr": {
"cidr": "<string>",
"except": [
"<string>"
]
},
"tenant": "TENANT_SCOPE_UNSPECIFIED",
"any": true,
"ports": [
{
"port": 123,
"protocol": "<string>",
"endPort": 123
}
]
}
],
"effectiveEgress": [
{
"cidr": {
"cidr": "<string>",
"except": [
"<string>"
]
},
"httpsHostname": "<string>",
"tenant": "TENANT_SCOPE_UNSPECIFIED",
"any": true,
"selector": {
"podLabels": {},
"namespaceLabels": {}
},
"ports": [
{
"port": 123,
"protocol": "<string>",
"endPort": 123
}
],
"httpsHostnameExcept": [
"<string>"
]
}
],
"effectiveResourceRequirements": {
"requests": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
},
"limits": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
}
},
"attachedVolumeIds": [
"<string>"
],
"effectiveRuntimeClass": "<string>",
"effectiveDnsEgress": "DNS_EGRESS_MODE_UNSPECIFIED"
},
"sourceTemplateId": "<string>",
"sourceTemplateRevision": "<string>",
"displayName": "<string>",
"endpointShareToken": "<string>",
"control": "CONTROL_UNSPECIFIED"
}{
"code": 123,
"message": "<string>",
"details": [
{
"@type": "<string>"
}
]
}Create sandbox
Launch a sandbox from a complete sandbox spec, then poll Get sandbox until it is running.
curl --request POST \
--url https://api.cwsandbox.com/v1/sandboxes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"spec": {
"containers": [
{
"name": "<string>",
"image": "<string>",
"command": "<string>",
"args": [
"<string>"
],
"environmentVariables": {},
"resources": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
},
"files": [
{
"path": "<string>",
"content": "<string>"
}
],
"volumeMounts": [
{
"volume": "<string>",
"mountPath": "<string>",
"readOnly": true,
"subPath": "<string>"
}
],
"secretStores": [
{
"storeName": "<string>",
"secrets": [
{
"path": "<string>",
"envVar": "<string>",
"field": "<string>"
}
]
}
],
"workingDir": "<string>",
"resourceRequirements": {
"requests": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
},
"limits": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
}
},
"securityContext": {
"runAsUser": 123,
"runAsGroup": 123,
"privileged": true,
"allowPrivilegeEscalation": true,
"readOnlyRootFilesystem": true,
"capabilitiesAdd": [
"<string>"
],
"capabilitiesDrop": [
"<string>"
],
"seccompProfile": "<string>"
},
"primary": true,
"startupProbe": {
"exec": [
"<string>"
],
"periodSeconds": 123,
"timeoutSeconds": 123,
"failureThreshold": 123,
"initialDelaySeconds": 123
}
}
],
"volumes": [
{
"name": "<string>",
"scratch": {
"size": "<string>",
"restoreFromSnapshotId": "<string>"
},
"volumeId": "<string>"
}
],
"services": [
{
"port": 123,
"name": "<string>"
}
],
"maxLifetimeSeconds": 123,
"networkIds": [
"<string>"
],
"objectStorageAccess": {
"buckets": [
"<string>"
],
"objectPrefix": "<string>"
},
"tags": [
"<string>"
],
"runnerIds": [
"<string>"
],
"network": {
"ingress": [
{
"any": true,
"ports": [
{
"port": 123,
"protocol": "<string>",
"endPort": 123
}
]
}
],
"egress": [
{
"httpsHostname": "<string>",
"any": true,
"ports": [
{
"port": 123,
"protocol": "<string>",
"endPort": 123
}
],
"httpsHostnameExcept": [
"<string>"
]
}
],
"denyEgress": true,
"denyIngress": true
},
"annotations": {},
"instanceType": "<string>",
"runtimeClass": "<string>",
"networkConfigId": "<string>"
},
"displayName": "<string>"
}
'import requests
url = "https://api.cwsandbox.com/v1/sandboxes"
payload = {
"spec": {
"containers": [
{
"name": "<string>",
"image": "<string>",
"command": "<string>",
"args": ["<string>"],
"environmentVariables": {},
"resources": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
},
"files": [
{
"path": "<string>",
"content": "<string>"
}
],
"volumeMounts": [
{
"volume": "<string>",
"mountPath": "<string>",
"readOnly": True,
"subPath": "<string>"
}
],
"secretStores": [
{
"storeName": "<string>",
"secrets": [
{
"path": "<string>",
"envVar": "<string>",
"field": "<string>"
}
]
}
],
"workingDir": "<string>",
"resourceRequirements": {
"requests": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
},
"limits": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
}
},
"securityContext": {
"runAsUser": 123,
"runAsGroup": 123,
"privileged": True,
"allowPrivilegeEscalation": True,
"readOnlyRootFilesystem": True,
"capabilitiesAdd": ["<string>"],
"capabilitiesDrop": ["<string>"],
"seccompProfile": "<string>"
},
"primary": True,
"startupProbe": {
"exec": ["<string>"],
"periodSeconds": 123,
"timeoutSeconds": 123,
"failureThreshold": 123,
"initialDelaySeconds": 123
}
}
],
"volumes": [
{
"name": "<string>",
"scratch": {
"size": "<string>",
"restoreFromSnapshotId": "<string>"
},
"volumeId": "<string>"
}
],
"services": [
{
"port": 123,
"name": "<string>"
}
],
"maxLifetimeSeconds": 123,
"networkIds": ["<string>"],
"objectStorageAccess": {
"buckets": ["<string>"],
"objectPrefix": "<string>"
},
"tags": ["<string>"],
"runnerIds": ["<string>"],
"network": {
"ingress": [
{
"any": True,
"ports": [
{
"port": 123,
"protocol": "<string>",
"endPort": 123
}
]
}
],
"egress": [
{
"httpsHostname": "<string>",
"any": True,
"ports": [
{
"port": 123,
"protocol": "<string>",
"endPort": 123
}
],
"httpsHostnameExcept": ["<string>"]
}
],
"denyEgress": True,
"denyIngress": True
},
"annotations": {},
"instanceType": "<string>",
"runtimeClass": "<string>",
"networkConfigId": "<string>"
},
"displayName": "<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({
spec: {
containers: [
{
name: '<string>',
image: '<string>',
command: '<string>',
args: ['<string>'],
environmentVariables: {},
resources: {
cpu: '<string>',
memory: '<string>',
gpu: {count: '<string>', type: '<string>', memoryGb: '<string>'}
},
files: [{path: '<string>', content: '<string>'}],
volumeMounts: [
{volume: '<string>', mountPath: '<string>', readOnly: true, subPath: '<string>'}
],
secretStores: [
{
storeName: '<string>',
secrets: [{path: '<string>', envVar: '<string>', field: '<string>'}]
}
],
workingDir: '<string>',
resourceRequirements: {
requests: {
cpu: '<string>',
memory: '<string>',
gpu: {count: '<string>', type: '<string>', memoryGb: '<string>'}
},
limits: {
cpu: '<string>',
memory: '<string>',
gpu: {count: '<string>', type: '<string>', memoryGb: '<string>'}
}
},
securityContext: {
runAsUser: 123,
runAsGroup: 123,
privileged: true,
allowPrivilegeEscalation: true,
readOnlyRootFilesystem: true,
capabilitiesAdd: ['<string>'],
capabilitiesDrop: ['<string>'],
seccompProfile: '<string>'
},
primary: true,
startupProbe: {
exec: ['<string>'],
periodSeconds: 123,
timeoutSeconds: 123,
failureThreshold: 123,
initialDelaySeconds: 123
}
}
],
volumes: [
{
name: '<string>',
scratch: {size: '<string>', restoreFromSnapshotId: '<string>'},
volumeId: '<string>'
}
],
services: [{port: 123, name: '<string>'}],
maxLifetimeSeconds: 123,
networkIds: ['<string>'],
objectStorageAccess: {buckets: ['<string>'], objectPrefix: '<string>'},
tags: ['<string>'],
runnerIds: ['<string>'],
network: {
ingress: [{any: true, ports: [{port: 123, protocol: '<string>', endPort: 123}]}],
egress: [
{
httpsHostname: '<string>',
any: true,
ports: [{port: 123, protocol: '<string>', endPort: 123}],
httpsHostnameExcept: ['<string>']
}
],
denyEgress: true,
denyIngress: true
},
annotations: {},
instanceType: '<string>',
runtimeClass: '<string>',
networkConfigId: '<string>'
},
displayName: '<string>'
})
};
fetch('https://api.cwsandbox.com/v1/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://api.cwsandbox.com/v1/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([
'spec' => [
'containers' => [
[
'name' => '<string>',
'image' => '<string>',
'command' => '<string>',
'args' => [
'<string>'
],
'environmentVariables' => [
],
'resources' => [
'cpu' => '<string>',
'memory' => '<string>',
'gpu' => [
'count' => '<string>',
'type' => '<string>',
'memoryGb' => '<string>'
]
],
'files' => [
[
'path' => '<string>',
'content' => '<string>'
]
],
'volumeMounts' => [
[
'volume' => '<string>',
'mountPath' => '<string>',
'readOnly' => true,
'subPath' => '<string>'
]
],
'secretStores' => [
[
'storeName' => '<string>',
'secrets' => [
[
'path' => '<string>',
'envVar' => '<string>',
'field' => '<string>'
]
]
]
],
'workingDir' => '<string>',
'resourceRequirements' => [
'requests' => [
'cpu' => '<string>',
'memory' => '<string>',
'gpu' => [
'count' => '<string>',
'type' => '<string>',
'memoryGb' => '<string>'
]
],
'limits' => [
'cpu' => '<string>',
'memory' => '<string>',
'gpu' => [
'count' => '<string>',
'type' => '<string>',
'memoryGb' => '<string>'
]
]
],
'securityContext' => [
'runAsUser' => 123,
'runAsGroup' => 123,
'privileged' => true,
'allowPrivilegeEscalation' => true,
'readOnlyRootFilesystem' => true,
'capabilitiesAdd' => [
'<string>'
],
'capabilitiesDrop' => [
'<string>'
],
'seccompProfile' => '<string>'
],
'primary' => true,
'startupProbe' => [
'exec' => [
'<string>'
],
'periodSeconds' => 123,
'timeoutSeconds' => 123,
'failureThreshold' => 123,
'initialDelaySeconds' => 123
]
]
],
'volumes' => [
[
'name' => '<string>',
'scratch' => [
'size' => '<string>',
'restoreFromSnapshotId' => '<string>'
],
'volumeId' => '<string>'
]
],
'services' => [
[
'port' => 123,
'name' => '<string>'
]
],
'maxLifetimeSeconds' => 123,
'networkIds' => [
'<string>'
],
'objectStorageAccess' => [
'buckets' => [
'<string>'
],
'objectPrefix' => '<string>'
],
'tags' => [
'<string>'
],
'runnerIds' => [
'<string>'
],
'network' => [
'ingress' => [
[
'any' => true,
'ports' => [
[
'port' => 123,
'protocol' => '<string>',
'endPort' => 123
]
]
]
],
'egress' => [
[
'httpsHostname' => '<string>',
'any' => true,
'ports' => [
[
'port' => 123,
'protocol' => '<string>',
'endPort' => 123
]
],
'httpsHostnameExcept' => [
'<string>'
]
]
],
'denyEgress' => true,
'denyIngress' => true
],
'annotations' => [
],
'instanceType' => '<string>',
'runtimeClass' => '<string>',
'networkConfigId' => '<string>'
],
'displayName' => '<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://api.cwsandbox.com/v1/sandboxes"
payload := strings.NewReader("{\n \"spec\": {\n \"containers\": [\n {\n \"name\": \"<string>\",\n \"image\": \"<string>\",\n \"command\": \"<string>\",\n \"args\": [\n \"<string>\"\n ],\n \"environmentVariables\": {},\n \"resources\": {\n \"cpu\": \"<string>\",\n \"memory\": \"<string>\",\n \"gpu\": {\n \"count\": \"<string>\",\n \"type\": \"<string>\",\n \"memoryGb\": \"<string>\"\n }\n },\n \"files\": [\n {\n \"path\": \"<string>\",\n \"content\": \"<string>\"\n }\n ],\n \"volumeMounts\": [\n {\n \"volume\": \"<string>\",\n \"mountPath\": \"<string>\",\n \"readOnly\": true,\n \"subPath\": \"<string>\"\n }\n ],\n \"secretStores\": [\n {\n \"storeName\": \"<string>\",\n \"secrets\": [\n {\n \"path\": \"<string>\",\n \"envVar\": \"<string>\",\n \"field\": \"<string>\"\n }\n ]\n }\n ],\n \"workingDir\": \"<string>\",\n \"resourceRequirements\": {\n \"requests\": {\n \"cpu\": \"<string>\",\n \"memory\": \"<string>\",\n \"gpu\": {\n \"count\": \"<string>\",\n \"type\": \"<string>\",\n \"memoryGb\": \"<string>\"\n }\n },\n \"limits\": {\n \"cpu\": \"<string>\",\n \"memory\": \"<string>\",\n \"gpu\": {\n \"count\": \"<string>\",\n \"type\": \"<string>\",\n \"memoryGb\": \"<string>\"\n }\n }\n },\n \"securityContext\": {\n \"runAsUser\": 123,\n \"runAsGroup\": 123,\n \"privileged\": true,\n \"allowPrivilegeEscalation\": true,\n \"readOnlyRootFilesystem\": true,\n \"capabilitiesAdd\": [\n \"<string>\"\n ],\n \"capabilitiesDrop\": [\n \"<string>\"\n ],\n \"seccompProfile\": \"<string>\"\n },\n \"primary\": true,\n \"startupProbe\": {\n \"exec\": [\n \"<string>\"\n ],\n \"periodSeconds\": 123,\n \"timeoutSeconds\": 123,\n \"failureThreshold\": 123,\n \"initialDelaySeconds\": 123\n }\n }\n ],\n \"volumes\": [\n {\n \"name\": \"<string>\",\n \"scratch\": {\n \"size\": \"<string>\",\n \"restoreFromSnapshotId\": \"<string>\"\n },\n \"volumeId\": \"<string>\"\n }\n ],\n \"services\": [\n {\n \"port\": 123,\n \"name\": \"<string>\"\n }\n ],\n \"maxLifetimeSeconds\": 123,\n \"networkIds\": [\n \"<string>\"\n ],\n \"objectStorageAccess\": {\n \"buckets\": [\n \"<string>\"\n ],\n \"objectPrefix\": \"<string>\"\n },\n \"tags\": [\n \"<string>\"\n ],\n \"runnerIds\": [\n \"<string>\"\n ],\n \"network\": {\n \"ingress\": [\n {\n \"any\": true,\n \"ports\": [\n {\n \"port\": 123,\n \"protocol\": \"<string>\",\n \"endPort\": 123\n }\n ]\n }\n ],\n \"egress\": [\n {\n \"httpsHostname\": \"<string>\",\n \"any\": true,\n \"ports\": [\n {\n \"port\": 123,\n \"protocol\": \"<string>\",\n \"endPort\": 123\n }\n ],\n \"httpsHostnameExcept\": [\n \"<string>\"\n ]\n }\n ],\n \"denyEgress\": true,\n \"denyIngress\": true\n },\n \"annotations\": {},\n \"instanceType\": \"<string>\",\n \"runtimeClass\": \"<string>\",\n \"networkConfigId\": \"<string>\"\n },\n \"displayName\": \"<string>\"\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://api.cwsandbox.com/v1/sandboxes")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"spec\": {\n \"containers\": [\n {\n \"name\": \"<string>\",\n \"image\": \"<string>\",\n \"command\": \"<string>\",\n \"args\": [\n \"<string>\"\n ],\n \"environmentVariables\": {},\n \"resources\": {\n \"cpu\": \"<string>\",\n \"memory\": \"<string>\",\n \"gpu\": {\n \"count\": \"<string>\",\n \"type\": \"<string>\",\n \"memoryGb\": \"<string>\"\n }\n },\n \"files\": [\n {\n \"path\": \"<string>\",\n \"content\": \"<string>\"\n }\n ],\n \"volumeMounts\": [\n {\n \"volume\": \"<string>\",\n \"mountPath\": \"<string>\",\n \"readOnly\": true,\n \"subPath\": \"<string>\"\n }\n ],\n \"secretStores\": [\n {\n \"storeName\": \"<string>\",\n \"secrets\": [\n {\n \"path\": \"<string>\",\n \"envVar\": \"<string>\",\n \"field\": \"<string>\"\n }\n ]\n }\n ],\n \"workingDir\": \"<string>\",\n \"resourceRequirements\": {\n \"requests\": {\n \"cpu\": \"<string>\",\n \"memory\": \"<string>\",\n \"gpu\": {\n \"count\": \"<string>\",\n \"type\": \"<string>\",\n \"memoryGb\": \"<string>\"\n }\n },\n \"limits\": {\n \"cpu\": \"<string>\",\n \"memory\": \"<string>\",\n \"gpu\": {\n \"count\": \"<string>\",\n \"type\": \"<string>\",\n \"memoryGb\": \"<string>\"\n }\n }\n },\n \"securityContext\": {\n \"runAsUser\": 123,\n \"runAsGroup\": 123,\n \"privileged\": true,\n \"allowPrivilegeEscalation\": true,\n \"readOnlyRootFilesystem\": true,\n \"capabilitiesAdd\": [\n \"<string>\"\n ],\n \"capabilitiesDrop\": [\n \"<string>\"\n ],\n \"seccompProfile\": \"<string>\"\n },\n \"primary\": true,\n \"startupProbe\": {\n \"exec\": [\n \"<string>\"\n ],\n \"periodSeconds\": 123,\n \"timeoutSeconds\": 123,\n \"failureThreshold\": 123,\n \"initialDelaySeconds\": 123\n }\n }\n ],\n \"volumes\": [\n {\n \"name\": \"<string>\",\n \"scratch\": {\n \"size\": \"<string>\",\n \"restoreFromSnapshotId\": \"<string>\"\n },\n \"volumeId\": \"<string>\"\n }\n ],\n \"services\": [\n {\n \"port\": 123,\n \"name\": \"<string>\"\n }\n ],\n \"maxLifetimeSeconds\": 123,\n \"networkIds\": [\n \"<string>\"\n ],\n \"objectStorageAccess\": {\n \"buckets\": [\n \"<string>\"\n ],\n \"objectPrefix\": \"<string>\"\n },\n \"tags\": [\n \"<string>\"\n ],\n \"runnerIds\": [\n \"<string>\"\n ],\n \"network\": {\n \"ingress\": [\n {\n \"any\": true,\n \"ports\": [\n {\n \"port\": 123,\n \"protocol\": \"<string>\",\n \"endPort\": 123\n }\n ]\n }\n ],\n \"egress\": [\n {\n \"httpsHostname\": \"<string>\",\n \"any\": true,\n \"ports\": [\n {\n \"port\": 123,\n \"protocol\": \"<string>\",\n \"endPort\": 123\n }\n ],\n \"httpsHostnameExcept\": [\n \"<string>\"\n ]\n }\n ],\n \"denyEgress\": true,\n \"denyIngress\": true\n },\n \"annotations\": {},\n \"instanceType\": \"<string>\",\n \"runtimeClass\": \"<string>\",\n \"networkConfigId\": \"<string>\"\n },\n \"displayName\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cwsandbox.com/v1/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 \"spec\": {\n \"containers\": [\n {\n \"name\": \"<string>\",\n \"image\": \"<string>\",\n \"command\": \"<string>\",\n \"args\": [\n \"<string>\"\n ],\n \"environmentVariables\": {},\n \"resources\": {\n \"cpu\": \"<string>\",\n \"memory\": \"<string>\",\n \"gpu\": {\n \"count\": \"<string>\",\n \"type\": \"<string>\",\n \"memoryGb\": \"<string>\"\n }\n },\n \"files\": [\n {\n \"path\": \"<string>\",\n \"content\": \"<string>\"\n }\n ],\n \"volumeMounts\": [\n {\n \"volume\": \"<string>\",\n \"mountPath\": \"<string>\",\n \"readOnly\": true,\n \"subPath\": \"<string>\"\n }\n ],\n \"secretStores\": [\n {\n \"storeName\": \"<string>\",\n \"secrets\": [\n {\n \"path\": \"<string>\",\n \"envVar\": \"<string>\",\n \"field\": \"<string>\"\n }\n ]\n }\n ],\n \"workingDir\": \"<string>\",\n \"resourceRequirements\": {\n \"requests\": {\n \"cpu\": \"<string>\",\n \"memory\": \"<string>\",\n \"gpu\": {\n \"count\": \"<string>\",\n \"type\": \"<string>\",\n \"memoryGb\": \"<string>\"\n }\n },\n \"limits\": {\n \"cpu\": \"<string>\",\n \"memory\": \"<string>\",\n \"gpu\": {\n \"count\": \"<string>\",\n \"type\": \"<string>\",\n \"memoryGb\": \"<string>\"\n }\n }\n },\n \"securityContext\": {\n \"runAsUser\": 123,\n \"runAsGroup\": 123,\n \"privileged\": true,\n \"allowPrivilegeEscalation\": true,\n \"readOnlyRootFilesystem\": true,\n \"capabilitiesAdd\": [\n \"<string>\"\n ],\n \"capabilitiesDrop\": [\n \"<string>\"\n ],\n \"seccompProfile\": \"<string>\"\n },\n \"primary\": true,\n \"startupProbe\": {\n \"exec\": [\n \"<string>\"\n ],\n \"periodSeconds\": 123,\n \"timeoutSeconds\": 123,\n \"failureThreshold\": 123,\n \"initialDelaySeconds\": 123\n }\n }\n ],\n \"volumes\": [\n {\n \"name\": \"<string>\",\n \"scratch\": {\n \"size\": \"<string>\",\n \"restoreFromSnapshotId\": \"<string>\"\n },\n \"volumeId\": \"<string>\"\n }\n ],\n \"services\": [\n {\n \"port\": 123,\n \"name\": \"<string>\"\n }\n ],\n \"maxLifetimeSeconds\": 123,\n \"networkIds\": [\n \"<string>\"\n ],\n \"objectStorageAccess\": {\n \"buckets\": [\n \"<string>\"\n ],\n \"objectPrefix\": \"<string>\"\n },\n \"tags\": [\n \"<string>\"\n ],\n \"runnerIds\": [\n \"<string>\"\n ],\n \"network\": {\n \"ingress\": [\n {\n \"any\": true,\n \"ports\": [\n {\n \"port\": 123,\n \"protocol\": \"<string>\",\n \"endPort\": 123\n }\n ]\n }\n ],\n \"egress\": [\n {\n \"httpsHostname\": \"<string>\",\n \"any\": true,\n \"ports\": [\n {\n \"port\": 123,\n \"protocol\": \"<string>\",\n \"endPort\": 123\n }\n ],\n \"httpsHostnameExcept\": [\n \"<string>\"\n ]\n }\n ],\n \"denyEgress\": true,\n \"denyIngress\": true\n },\n \"annotations\": {},\n \"instanceType\": \"<string>\",\n \"runtimeClass\": \"<string>\",\n \"networkConfigId\": \"<string>\"\n },\n \"displayName\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"spec": {
"containers": [
{
"name": "<string>",
"image": "<string>",
"command": "<string>",
"args": [
"<string>"
],
"environmentVariables": {},
"resources": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
},
"files": [
{
"path": "<string>",
"content": "<string>"
}
],
"volumeMounts": [
{
"volume": "<string>",
"mountPath": "<string>",
"readOnly": true,
"subPath": "<string>"
}
],
"secretStores": [
{
"storeName": "<string>",
"secrets": [
{
"path": "<string>",
"envVar": "<string>",
"field": "<string>"
}
]
}
],
"workingDir": "<string>",
"resourceRequirements": {
"requests": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
},
"limits": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
}
},
"securityContext": {
"runAsUser": 123,
"runAsGroup": 123,
"privileged": true,
"allowPrivilegeEscalation": true,
"readOnlyRootFilesystem": true,
"capabilitiesAdd": [
"<string>"
],
"capabilitiesDrop": [
"<string>"
],
"seccompProfile": "<string>"
},
"imagePullCredentials": {
"registry": "<string>",
"credentials": {
"storeName": "<string>",
"path": "<string>",
"field": "<string>"
}
},
"primary": true,
"startupProbe": {
"exec": [
"<string>"
],
"periodSeconds": 123,
"timeoutSeconds": 123,
"failureThreshold": 123,
"initialDelaySeconds": 123
}
}
],
"volumes": [
{
"name": "<string>",
"scratch": {
"size": "<string>",
"medium": "STORAGE_MEDIUM_UNSPECIFIED",
"restoreFromSnapshotId": "<string>"
},
"volumeId": "<string>"
}
],
"services": [
{
"port": 123,
"name": "<string>",
"protocol": "SERVICE_PROTOCOL_UNSPECIFIED",
"visibility": "VISIBILITY_UNSPECIFIED",
"endpoint": {
"kind": "ENDPOINT_KIND_UNSPECIFIED",
"auth": "ENDPOINT_AUTH_UNSPECIFIED",
"requestTimeoutSeconds": 123
}
}
],
"maxLifetimeSeconds": 123,
"networkIds": [
"<string>"
],
"objectStorageAccess": {
"buckets": [
"<string>"
],
"permission": "OBJECT_STORAGE_PERMISSION_UNSPECIFIED",
"objectPrefix": "<string>"
},
"tags": [
"<string>"
],
"runnerIds": [
"<string>"
],
"annotations": {},
"instanceType": "<string>",
"mode": "SANDBOX_MODE_UNSPECIFIED",
"runtimeClass": "<string>",
"networkConfigId": "<string>",
"runtimeClassSelection": "RUNTIME_CLASS_UNSPECIFIED"
},
"sandboxId": "<string>",
"status": {
"state": "STATE_UNSPECIFIED",
"stateReason": "<string>",
"createTime": "2023-11-07T05:31:56Z",
"startTime": "2023-11-07T05:31:56Z",
"endTime": "2023-11-07T05:31:56Z",
"services": [
{
"port": 123,
"name": "<string>",
"protocol": "SERVICE_PROTOCOL_UNSPECIFIED",
"visibility": "VISIBILITY_UNSPECIFIED",
"endpoint": {
"kind": "ENDPOINT_KIND_UNSPECIFIED",
"auth": "ENDPOINT_AUTH_UNSPECIFIED",
"url": "<string>",
"requestTimeoutSeconds": 123,
"address": "<string>"
},
"url": "<string>"
}
],
"resourceUsage": {
"cpuMillicores": "<string>",
"memoryMb": "<string>",
"gpuCount": "<string>"
},
"exitCode": 123,
"effectiveResources": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
},
"effectiveMaxLifetimeSeconds": 123,
"containerStatuses": [
{
"name": "<string>",
"state": "STATE_UNSPECIFIED",
"exitCode": 123,
"restartCount": 123
}
],
"runnerId": "<string>",
"runnerGroupId": "<string>",
"effectiveIngress": [
{
"cidr": {
"cidr": "<string>",
"except": [
"<string>"
]
},
"tenant": "TENANT_SCOPE_UNSPECIFIED",
"any": true,
"ports": [
{
"port": 123,
"protocol": "<string>",
"endPort": 123
}
]
}
],
"effectiveEgress": [
{
"cidr": {
"cidr": "<string>",
"except": [
"<string>"
]
},
"httpsHostname": "<string>",
"tenant": "TENANT_SCOPE_UNSPECIFIED",
"any": true,
"selector": {
"podLabels": {},
"namespaceLabels": {}
},
"ports": [
{
"port": 123,
"protocol": "<string>",
"endPort": 123
}
],
"httpsHostnameExcept": [
"<string>"
]
}
],
"effectiveResourceRequirements": {
"requests": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
},
"limits": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
}
},
"attachedVolumeIds": [
"<string>"
],
"effectiveRuntimeClass": "<string>",
"effectiveDnsEgress": "DNS_EGRESS_MODE_UNSPECIFIED"
},
"sourceTemplateId": "<string>",
"sourceTemplateRevision": "<string>",
"displayName": "<string>",
"endpointShareToken": "<string>",
"control": "CONTROL_UNSPECIFIED"
}{
"code": 123,
"message": "<string>",
"details": [
{
"@type": "<string>"
}
]
}Authorizations
CoreWeave API access token sent as a bearer token.
Query Parameters
Optional idempotency token; repeated identical requests with the same token return the original result.
Body
Sandbox is a single running (or terminal) compute environment.
Desired workload. Required on create and immutable thereafter. It is absent when v1 projects a sandbox created through v1beta2, which has no v1 SandboxSpec. It is also absent in STATE_PREPARING, and after an image fill fails before the spec is stored. When create used a template, this is the resolved spec from that create — never re-read from the live template.
Show child attributes
Show child attributes
Optional, immutable lookup name, unique among active sandboxes in the tenant organization. Case-sensitive, at most 128 UTF-8 bytes; leading or trailing whitespace, slashes, colons, control characters, and UUIDs are invalid. The name becomes reusable once the sandbox reaches a terminal state.
Response
OK
Sandbox is a single running (or terminal) compute environment.
Desired workload. Required on create and immutable thereafter. It is absent when v1 projects a sandbox created through v1beta2, which has no v1 SandboxSpec. It is also absent in STATE_PREPARING, and after an image fill fails before the spec is stored. When create used a template, this is the resolved spec from that create — never re-read from the live template.
Show child attributes
Show child attributes
Server-assigned unique identifier.
Observed state.
Show child attributes
Show child attributes
Template selected at create time, if any. Historical provenance; retained even if the template is later deleted.
Revision of the template applied at create time.
Optional, immutable lookup name, unique among active sandboxes in the tenant organization. Case-sensitive, at most 128 UTF-8 bytes; leading or trailing whitespace, slashes, colons, control characters, and UUIDs are invalid. The name becomes reusable once the sandbox reaches a terminal state.
CreateSandbox, CreateSandboxFromTemplate, and an identical request_id replay of that call, after HTTPS URLs confirm. Omitted from Get, List, status, and from a successful create while those URLs are unconfirmed. Send as X-Sandbox-Share-Token or ?share_token=; both are stripped before forwarding.
Who controls the sandbox's containers: CONTROL_CONTAINER_ENGINE for a sandbox created with it, and CONTROL_PLATFORM for every other sandbox. CONTROL_UNSPECIFIED means no controller is specified; successful creates resolve the default to CONTROL_PLATFORM.
CONTROL_UNSPECIFIED, CONTROL_PLATFORM, CONTROL_CONTAINER_ENGINE Was this page helpful?