curl --request POST \
--url https://api.cwsandbox.com/v1/sandboxes:createFromFile \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contents": "<string>",
"primaryService": "<string>",
"imageOverrides": {},
"buildContexts": {},
"defaultResources": {
"requests": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
},
"limits": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
}
},
"maxLifetimeSeconds": 123,
"tags": [
"<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
},
"networkIds": [
"<string>"
],
"objectStorageAccess": {
"buckets": [
"<string>"
],
"objectPrefix": "<string>"
},
"annotations": {},
"runnerIds": [
"<string>"
],
"requestId": "<string>",
"displayName": "<string>",
"buildContextObjects": {},
"builderSizes": {},
"imagePullCredentials": [
{
"registry": "<string>",
"credentials": {
"storeName": "<string>",
"path": "<string>",
"field": "<string>"
}
}
]
}
'import requests
url = "https://api.cwsandbox.com/v1/sandboxes:createFromFile"
payload = {
"contents": "<string>",
"primaryService": "<string>",
"imageOverrides": {},
"buildContexts": {},
"defaultResources": {
"requests": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
},
"limits": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
}
},
"maxLifetimeSeconds": 123,
"tags": ["<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
},
"networkIds": ["<string>"],
"objectStorageAccess": {
"buckets": ["<string>"],
"objectPrefix": "<string>"
},
"annotations": {},
"runnerIds": ["<string>"],
"requestId": "<string>",
"displayName": "<string>",
"buildContextObjects": {},
"builderSizes": {},
"imagePullCredentials": [
{
"registry": "<string>",
"credentials": {
"storeName": "<string>",
"path": "<string>",
"field": "<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({
contents: '<string>',
primaryService: '<string>',
imageOverrides: {},
buildContexts: {},
defaultResources: {
requests: {
cpu: '<string>',
memory: '<string>',
gpu: {count: '<string>', type: '<string>', memoryGb: '<string>'}
},
limits: {
cpu: '<string>',
memory: '<string>',
gpu: {count: '<string>', type: '<string>', memoryGb: '<string>'}
}
},
maxLifetimeSeconds: 123,
tags: ['<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
},
networkIds: ['<string>'],
objectStorageAccess: {buckets: ['<string>'], objectPrefix: '<string>'},
annotations: {},
runnerIds: ['<string>'],
requestId: '<string>',
displayName: '<string>',
buildContextObjects: {},
builderSizes: {},
imagePullCredentials: [
{
registry: '<string>',
credentials: {storeName: '<string>', path: '<string>', field: '<string>'}
}
]
})
};
fetch('https://api.cwsandbox.com/v1/sandboxes:createFromFile', 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:createFromFile",
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([
'contents' => '<string>',
'primaryService' => '<string>',
'imageOverrides' => [
],
'buildContexts' => [
],
'defaultResources' => [
'requests' => [
'cpu' => '<string>',
'memory' => '<string>',
'gpu' => [
'count' => '<string>',
'type' => '<string>',
'memoryGb' => '<string>'
]
],
'limits' => [
'cpu' => '<string>',
'memory' => '<string>',
'gpu' => [
'count' => '<string>',
'type' => '<string>',
'memoryGb' => '<string>'
]
]
],
'maxLifetimeSeconds' => 123,
'tags' => [
'<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
],
'networkIds' => [
'<string>'
],
'objectStorageAccess' => [
'buckets' => [
'<string>'
],
'objectPrefix' => '<string>'
],
'annotations' => [
],
'runnerIds' => [
'<string>'
],
'requestId' => '<string>',
'displayName' => '<string>',
'buildContextObjects' => [
],
'builderSizes' => [
],
'imagePullCredentials' => [
[
'registry' => '<string>',
'credentials' => [
'storeName' => '<string>',
'path' => '<string>',
'field' => '<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:createFromFile"
payload := strings.NewReader("{\n \"contents\": \"<string>\",\n \"primaryService\": \"<string>\",\n \"imageOverrides\": {},\n \"buildContexts\": {},\n \"defaultResources\": {\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 \"maxLifetimeSeconds\": 123,\n \"tags\": [\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 \"networkIds\": [\n \"<string>\"\n ],\n \"objectStorageAccess\": {\n \"buckets\": [\n \"<string>\"\n ],\n \"objectPrefix\": \"<string>\"\n },\n \"annotations\": {},\n \"runnerIds\": [\n \"<string>\"\n ],\n \"requestId\": \"<string>\",\n \"displayName\": \"<string>\",\n \"buildContextObjects\": {},\n \"builderSizes\": {},\n \"imagePullCredentials\": [\n {\n \"registry\": \"<string>\",\n \"credentials\": {\n \"storeName\": \"<string>\",\n \"path\": \"<string>\",\n \"field\": \"<string>\"\n }\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://api.cwsandbox.com/v1/sandboxes:createFromFile")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"contents\": \"<string>\",\n \"primaryService\": \"<string>\",\n \"imageOverrides\": {},\n \"buildContexts\": {},\n \"defaultResources\": {\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 \"maxLifetimeSeconds\": 123,\n \"tags\": [\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 \"networkIds\": [\n \"<string>\"\n ],\n \"objectStorageAccess\": {\n \"buckets\": [\n \"<string>\"\n ],\n \"objectPrefix\": \"<string>\"\n },\n \"annotations\": {},\n \"runnerIds\": [\n \"<string>\"\n ],\n \"requestId\": \"<string>\",\n \"displayName\": \"<string>\",\n \"buildContextObjects\": {},\n \"builderSizes\": {},\n \"imagePullCredentials\": [\n {\n \"registry\": \"<string>\",\n \"credentials\": {\n \"storeName\": \"<string>\",\n \"path\": \"<string>\",\n \"field\": \"<string>\"\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cwsandbox.com/v1/sandboxes:createFromFile")
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 \"contents\": \"<string>\",\n \"primaryService\": \"<string>\",\n \"imageOverrides\": {},\n \"buildContexts\": {},\n \"defaultResources\": {\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 \"maxLifetimeSeconds\": 123,\n \"tags\": [\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 \"networkIds\": [\n \"<string>\"\n ],\n \"objectStorageAccess\": {\n \"buckets\": [\n \"<string>\"\n ],\n \"objectPrefix\": \"<string>\"\n },\n \"annotations\": {},\n \"runnerIds\": [\n \"<string>\"\n ],\n \"requestId\": \"<string>\",\n \"displayName\": \"<string>\",\n \"buildContextObjects\": {},\n \"builderSizes\": {},\n \"imagePullCredentials\": [\n {\n \"registry\": \"<string>\",\n \"credentials\": {\n \"storeName\": \"<string>\",\n \"path\": \"<string>\",\n \"field\": \"<string>\"\n }\n }\n ]\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 from file
Launch a sandbox from a Compose file, using pullable images or building services when enabled.
curl --request POST \
--url https://api.cwsandbox.com/v1/sandboxes:createFromFile \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contents": "<string>",
"primaryService": "<string>",
"imageOverrides": {},
"buildContexts": {},
"defaultResources": {
"requests": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
},
"limits": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
}
},
"maxLifetimeSeconds": 123,
"tags": [
"<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
},
"networkIds": [
"<string>"
],
"objectStorageAccess": {
"buckets": [
"<string>"
],
"objectPrefix": "<string>"
},
"annotations": {},
"runnerIds": [
"<string>"
],
"requestId": "<string>",
"displayName": "<string>",
"buildContextObjects": {},
"builderSizes": {},
"imagePullCredentials": [
{
"registry": "<string>",
"credentials": {
"storeName": "<string>",
"path": "<string>",
"field": "<string>"
}
}
]
}
'import requests
url = "https://api.cwsandbox.com/v1/sandboxes:createFromFile"
payload = {
"contents": "<string>",
"primaryService": "<string>",
"imageOverrides": {},
"buildContexts": {},
"defaultResources": {
"requests": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
},
"limits": {
"cpu": "<string>",
"memory": "<string>",
"gpu": {
"count": "<string>",
"type": "<string>",
"memoryGb": "<string>"
}
}
},
"maxLifetimeSeconds": 123,
"tags": ["<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
},
"networkIds": ["<string>"],
"objectStorageAccess": {
"buckets": ["<string>"],
"objectPrefix": "<string>"
},
"annotations": {},
"runnerIds": ["<string>"],
"requestId": "<string>",
"displayName": "<string>",
"buildContextObjects": {},
"builderSizes": {},
"imagePullCredentials": [
{
"registry": "<string>",
"credentials": {
"storeName": "<string>",
"path": "<string>",
"field": "<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({
contents: '<string>',
primaryService: '<string>',
imageOverrides: {},
buildContexts: {},
defaultResources: {
requests: {
cpu: '<string>',
memory: '<string>',
gpu: {count: '<string>', type: '<string>', memoryGb: '<string>'}
},
limits: {
cpu: '<string>',
memory: '<string>',
gpu: {count: '<string>', type: '<string>', memoryGb: '<string>'}
}
},
maxLifetimeSeconds: 123,
tags: ['<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
},
networkIds: ['<string>'],
objectStorageAccess: {buckets: ['<string>'], objectPrefix: '<string>'},
annotations: {},
runnerIds: ['<string>'],
requestId: '<string>',
displayName: '<string>',
buildContextObjects: {},
builderSizes: {},
imagePullCredentials: [
{
registry: '<string>',
credentials: {storeName: '<string>', path: '<string>', field: '<string>'}
}
]
})
};
fetch('https://api.cwsandbox.com/v1/sandboxes:createFromFile', 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:createFromFile",
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([
'contents' => '<string>',
'primaryService' => '<string>',
'imageOverrides' => [
],
'buildContexts' => [
],
'defaultResources' => [
'requests' => [
'cpu' => '<string>',
'memory' => '<string>',
'gpu' => [
'count' => '<string>',
'type' => '<string>',
'memoryGb' => '<string>'
]
],
'limits' => [
'cpu' => '<string>',
'memory' => '<string>',
'gpu' => [
'count' => '<string>',
'type' => '<string>',
'memoryGb' => '<string>'
]
]
],
'maxLifetimeSeconds' => 123,
'tags' => [
'<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
],
'networkIds' => [
'<string>'
],
'objectStorageAccess' => [
'buckets' => [
'<string>'
],
'objectPrefix' => '<string>'
],
'annotations' => [
],
'runnerIds' => [
'<string>'
],
'requestId' => '<string>',
'displayName' => '<string>',
'buildContextObjects' => [
],
'builderSizes' => [
],
'imagePullCredentials' => [
[
'registry' => '<string>',
'credentials' => [
'storeName' => '<string>',
'path' => '<string>',
'field' => '<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:createFromFile"
payload := strings.NewReader("{\n \"contents\": \"<string>\",\n \"primaryService\": \"<string>\",\n \"imageOverrides\": {},\n \"buildContexts\": {},\n \"defaultResources\": {\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 \"maxLifetimeSeconds\": 123,\n \"tags\": [\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 \"networkIds\": [\n \"<string>\"\n ],\n \"objectStorageAccess\": {\n \"buckets\": [\n \"<string>\"\n ],\n \"objectPrefix\": \"<string>\"\n },\n \"annotations\": {},\n \"runnerIds\": [\n \"<string>\"\n ],\n \"requestId\": \"<string>\",\n \"displayName\": \"<string>\",\n \"buildContextObjects\": {},\n \"builderSizes\": {},\n \"imagePullCredentials\": [\n {\n \"registry\": \"<string>\",\n \"credentials\": {\n \"storeName\": \"<string>\",\n \"path\": \"<string>\",\n \"field\": \"<string>\"\n }\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://api.cwsandbox.com/v1/sandboxes:createFromFile")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"contents\": \"<string>\",\n \"primaryService\": \"<string>\",\n \"imageOverrides\": {},\n \"buildContexts\": {},\n \"defaultResources\": {\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 \"maxLifetimeSeconds\": 123,\n \"tags\": [\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 \"networkIds\": [\n \"<string>\"\n ],\n \"objectStorageAccess\": {\n \"buckets\": [\n \"<string>\"\n ],\n \"objectPrefix\": \"<string>\"\n },\n \"annotations\": {},\n \"runnerIds\": [\n \"<string>\"\n ],\n \"requestId\": \"<string>\",\n \"displayName\": \"<string>\",\n \"buildContextObjects\": {},\n \"builderSizes\": {},\n \"imagePullCredentials\": [\n {\n \"registry\": \"<string>\",\n \"credentials\": {\n \"storeName\": \"<string>\",\n \"path\": \"<string>\",\n \"field\": \"<string>\"\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cwsandbox.com/v1/sandboxes:createFromFile")
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 \"contents\": \"<string>\",\n \"primaryService\": \"<string>\",\n \"imageOverrides\": {},\n \"buildContexts\": {},\n \"defaultResources\": {\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 \"maxLifetimeSeconds\": 123,\n \"tags\": [\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 \"networkIds\": [\n \"<string>\"\n ],\n \"objectStorageAccess\": {\n \"buckets\": [\n \"<string>\"\n ],\n \"objectPrefix\": \"<string>\"\n },\n \"annotations\": {},\n \"runnerIds\": [\n \"<string>\"\n ],\n \"requestId\": \"<string>\",\n \"displayName\": \"<string>\",\n \"buildContextObjects\": {},\n \"builderSizes\": {},\n \"imagePullCredentials\": [\n {\n \"registry\": \"<string>\",\n \"credentials\": {\n \"storeName\": \"<string>\",\n \"path\": \"<string>\",\n \"field\": \"<string>\"\n }\n }\n ]\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.
Body
CreateSandboxFromFileRequest is the AIP-136 body for CreateSandboxFromFile. This list is closed: volumes, instance_type, runtime_class, runtime_class_selection, and published services are not fields here; those callers use CreateSandbox. There is no PartialSandboxSpec overlay. CONTROL_CONTAINER_ENGINE needs no runtime class field: the Runner's engine class is used (see Control).
Document type. Unspecified is INVALID_ARGUMENT. Compose is accepted for pull-only documents. Other declared types are UNIMPLEMENTED.
SANDBOX_FILE_TYPE_UNSPECIFIED, SANDBOX_FILE_TYPE_COMPOSE UTF-8 file bytes. Compose: max 256 KiB. The platform keeps the file, or the spec derived from it, for the life of the sandbox record, so put secrets in a secret store rather than inline.
Compose service that is the sandbox primary. Required when type is Compose and control is CONTROL_PLATFORM; must name a service in contents. Set with CONTROL_CONTAINER_ENGINE, it is INVALID_ARGUMENT (CWSANDBOX_INVALID_REQUEST).
Per-service image refs. Keys must be services. Use this to supply a pullable image for a service that would otherwise need a build. Valid only when type is Compose.
Show child attributes
Show child attributes
Per-service gzip build-context tarballs for services that still need a build. Keys must be services. Total 32 MiB. A service that still needs a build must not have an entry here when its build.context is a remote URL. Entries for services with an image are ignored. Valid only when type is Compose.
Show child attributes
Show child attributes
CPU/memory copied onto each service that omitted deploy.resources. Per container, not a project budget. GPU in this message is INVALID_ARGUMENT. Valid only when type is Compose.
Show child attributes
Show child attributes
Placement mode. Omit this field to use serverless placement. SANDBOX_MODE_UNSPECIFIED also selects SANDBOX_MODE_SERVERLESS. Set SANDBOX_MODE_CKS to use your own-cluster runners.
SANDBOX_MODE_UNSPECIFIED, SANDBOX_MODE_SERVERLESS, SANDBOX_MODE_CKS NetworkOptions declares the sandbox's network intent beyond port exposure.
Show child attributes
Show child attributes
Network membership is not supported. v1 sandbox creation and stored template validation reject a non-empty networkIds list. Use network to configure network rules; this field does not join sandbox networks.
ObjectStorageAccess grants the sandbox temporary access to object-storage buckets. The minted credential is injected into every user container.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Optional idempotency token; repeated identical requests with the same token return the original result.
Optional name for the created sandbox. Uses Sandbox.display_name rules.
Per-service build context stored in CoreWeave AI Object Storage, for contexts larger than build_contexts allows. Keys must be services that still need a build. A service with an entry here must not also have a build_contexts entry or a remote build.context. At most 64 entries. Valid only when type is Compose.
Show child attributes
Show child attributes
Per-service builder size name, at most 64 bytes. Omitted services use the default size. A size the build service does not offer is INVALID_ARGUMENT on builder_sizes.. Keys must be services that still need a build. At most 64 entries. Valid only when type is Compose.
Show child attributes
Show child attributes
Who controls the sandbox's containers (see Control). Unspecified means CONTROL_PLATFORM. CONTROL_CONTAINER_ENGINE is valid only when type is Compose. A server that doesn't support it returns UNIMPLEMENTED (CWSANDBOX_NOT_IMPLEMENTED). When no runner can run a container engine, the create is FAILED_PRECONDITION (CWSANDBOX_NO_SUITABLE_RUNNER) with metadata unsupported_feature=container_engine. A value the server doesn't recognize is UNIMPLEMENTED (CWSANDBOX_NOT_IMPLEMENTED).
CONTROL_UNSPECIFIED, CONTROL_PLATFORM, CONTROL_CONTAINER_ENGINE Registry credentials for pulling images, at most one per registry and at most 16 entries. A repeated registry or a 17th entry is INVALID_ARGUMENT (CWSANDBOX_INVALID_REQUEST). Credentials are resolved at create, as for Container.image_pull_credentials. With CONTROL_PLATFORM, each container uses the credential whose registry matches its image. With CONTROL_CONTAINER_ENGINE, the engine's Docker client holds every credential, and a credential here replaces the platform's own for the same registry. Valid only when type is Compose. A deployment without support returns UNIMPLEMENTED (CWSANDBOX_NOT_IMPLEMENTED).
Show child attributes
Show child attributes
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?