curl --request POST \
--url https://api.outerlayer.ai/v1/work-items/{workItemId}/claim/sandbox \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Outerlayer-App-Id: <api-key>' \
--data '
{
"apis": [
"<string>"
],
"fromState": "<string>",
"idleMinutes": 123,
"metadata": {},
"preview": true,
"resume": "<string>",
"timeLimitMinutes": 123,
"waits": true
}
'import requests
url = "https://api.outerlayer.ai/v1/work-items/{workItemId}/claim/sandbox"
payload = {
"apis": ["<string>"],
"fromState": "<string>",
"idleMinutes": 123,
"metadata": {},
"preview": True,
"resume": "<string>",
"timeLimitMinutes": 123,
"waits": True
}
headers = {
"X-Outerlayer-App-Id": "<api-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Outerlayer-App-Id': '<api-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
apis: ['<string>'],
fromState: '<string>',
idleMinutes: 123,
metadata: {},
preview: true,
resume: '<string>',
timeLimitMinutes: 123,
waits: true
})
};
fetch('https://api.outerlayer.ai/v1/work-items/{workItemId}/claim/sandbox', 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.outerlayer.ai/v1/work-items/{workItemId}/claim/sandbox",
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([
'apis' => [
'<string>'
],
'fromState' => '<string>',
'idleMinutes' => 123,
'metadata' => [
],
'preview' => true,
'resume' => '<string>',
'timeLimitMinutes' => 123,
'waits' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Outerlayer-App-Id: <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.outerlayer.ai/v1/work-items/{workItemId}/claim/sandbox"
payload := strings.NewReader("{\n \"apis\": [\n \"<string>\"\n ],\n \"fromState\": \"<string>\",\n \"idleMinutes\": 123,\n \"metadata\": {},\n \"preview\": true,\n \"resume\": \"<string>\",\n \"timeLimitMinutes\": 123,\n \"waits\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Outerlayer-App-Id", "<api-key>")
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.outerlayer.ai/v1/work-items/{workItemId}/claim/sandbox")
.header("X-Outerlayer-App-Id", "<api-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"apis\": [\n \"<string>\"\n ],\n \"fromState\": \"<string>\",\n \"idleMinutes\": 123,\n \"metadata\": {},\n \"preview\": true,\n \"resume\": \"<string>\",\n \"timeLimitMinutes\": 123,\n \"waits\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.outerlayer.ai/v1/work-items/{workItemId}/claim/sandbox")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Outerlayer-App-Id"] = '<api-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"apis\": [\n \"<string>\"\n ],\n \"fromState\": \"<string>\",\n \"idleMinutes\": 123,\n \"metadata\": {},\n \"preview\": true,\n \"resume\": \"<string>\",\n \"timeLimitMinutes\": 123,\n \"waits\": true\n}"
response = http.request(request)
puts response.read_body{
"data": {
"api": "header",
"dataPlaneUrl": "<string>",
"fromState": "<string>",
"id": "<string>",
"machine": "small",
"metadata": {},
"name": "<string>",
"providerNote": "<string>",
"secret": "<string>",
"snapshot": "<string>",
"state": "<string>",
"tokenHeader": "<string>",
"urlToken": "<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>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}Create the managed sandbox of a claim a self-hosted runner or a fleet machine holds
Creates a sandbox on OuterLayer’s account at the sandbox provider for the claim the caller holds, and answers with the sandbox’s address and secret. The gateway chooses the snapshot: the base snapshot, or with fromState a saved state of the caller’s factory. The sandbox gets the processors and memory of the machine size in the factory’s build settings, a disk no smaller than the snapshot’s, and no direct network access. The sandbox of a preview lease is the one exception: it reaches GitHub and the hosts a managed build of the factory reaches (defaultAllowHosts and the factory’s allowHosts), because a preview runs its checkout and its setup in the sandbox. A sandbox made from a state with the same size as the state starts with the processes the state saved. A claim has one sandbox at a time: a claim that has a sandbox gets that sandbox again. The claim counts as a managed build from this call on, and its time is billed as managed build-hours from the moment its sandbox has started, not from this call. The provider can take minutes to start a sandbox. With waits: true, the gateway keeps a sandbox that is slow to start and answers with it in the state starting, with an empty secret and urlToken. The gateway ends the sandbox when the claim is released or its lease expires, unless the runner keeps it (keep-managed-sandbox). A claim whose sandbox is kept gets a new sandbox, and the kept one ends. With resume, the claim resumes its work item’s kept sandbox instead: the gateway wakes it, starts its time limit again, and answers it in the state running with its secret. A sandbox that cannot be resumed gets sandbox_not_resumable (409, with reason: not_found, ended, not_kept, other_item, machine_differs, expired, claim_open or claim_has_sandbox), and nothing is bound. A resume whose provider calls fail with a fault that can clear tries them again, and then keeps the sandbox again and answers sandbox_provider_busy. A resume that the provider refuses for good ends the kept sandbox. A state named in fromState that cannot be used gets sandbox_state_unusable (409, with reason): not_found (no saved state of the factory has this id, or it is removed), expired (seven days old), replaced (a newer saved state of the same key exists), base_changed (saved under another base snapshot), machine_differs (saved from a sandbox of another size than the claim’s) or snapshot_gone (the provider no longer has its snapshot, and the gateway removes the state). The checks of fromState come after the holds of managed_build_held. A fleet machine’s claim has the machine size of the factory’s Build settings, and a request that names another size gets machine_differs (409). Refusals: claim_expired (410), claim_not_held (403), managed_sandboxes_unavailable (403), managed_build_held (409, with reason: trial_hours_used, spending_cap_reached, at_limit or unavailable), machine_differs (409), sandbox_provider_busy (503) and sandbox_provider_refused (502). A refused call binds no sandbox to the claim. The gateway makes a new sandbox at the first provider in its order that the runner can use (apis). When that provider refuses with a fault that can clear, it tries the next one, from that provider’s base snapshot. providerNote holds the refusals before it, and api says how the sandbox is called. A resume that the kept sandbox’s provider cannot serve now gets sandbox_not_resumable with reason provider_busy when another provider could make a new sandbox, so the runner asks again without resume. The response is sent with Cache-Control: no-store.
curl --request POST \
--url https://api.outerlayer.ai/v1/work-items/{workItemId}/claim/sandbox \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Outerlayer-App-Id: <api-key>' \
--data '
{
"apis": [
"<string>"
],
"fromState": "<string>",
"idleMinutes": 123,
"metadata": {},
"preview": true,
"resume": "<string>",
"timeLimitMinutes": 123,
"waits": true
}
'import requests
url = "https://api.outerlayer.ai/v1/work-items/{workItemId}/claim/sandbox"
payload = {
"apis": ["<string>"],
"fromState": "<string>",
"idleMinutes": 123,
"metadata": {},
"preview": True,
"resume": "<string>",
"timeLimitMinutes": 123,
"waits": True
}
headers = {
"X-Outerlayer-App-Id": "<api-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Outerlayer-App-Id': '<api-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
apis: ['<string>'],
fromState: '<string>',
idleMinutes: 123,
metadata: {},
preview: true,
resume: '<string>',
timeLimitMinutes: 123,
waits: true
})
};
fetch('https://api.outerlayer.ai/v1/work-items/{workItemId}/claim/sandbox', 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.outerlayer.ai/v1/work-items/{workItemId}/claim/sandbox",
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([
'apis' => [
'<string>'
],
'fromState' => '<string>',
'idleMinutes' => 123,
'metadata' => [
],
'preview' => true,
'resume' => '<string>',
'timeLimitMinutes' => 123,
'waits' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Outerlayer-App-Id: <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.outerlayer.ai/v1/work-items/{workItemId}/claim/sandbox"
payload := strings.NewReader("{\n \"apis\": [\n \"<string>\"\n ],\n \"fromState\": \"<string>\",\n \"idleMinutes\": 123,\n \"metadata\": {},\n \"preview\": true,\n \"resume\": \"<string>\",\n \"timeLimitMinutes\": 123,\n \"waits\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Outerlayer-App-Id", "<api-key>")
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.outerlayer.ai/v1/work-items/{workItemId}/claim/sandbox")
.header("X-Outerlayer-App-Id", "<api-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"apis\": [\n \"<string>\"\n ],\n \"fromState\": \"<string>\",\n \"idleMinutes\": 123,\n \"metadata\": {},\n \"preview\": true,\n \"resume\": \"<string>\",\n \"timeLimitMinutes\": 123,\n \"waits\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.outerlayer.ai/v1/work-items/{workItemId}/claim/sandbox")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Outerlayer-App-Id"] = '<api-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"apis\": [\n \"<string>\"\n ],\n \"fromState\": \"<string>\",\n \"idleMinutes\": 123,\n \"metadata\": {},\n \"preview\": true,\n \"resume\": \"<string>\",\n \"timeLimitMinutes\": 123,\n \"waits\": true\n}"
response = http.request(request)
puts response.read_body{
"data": {
"api": "header",
"dataPlaneUrl": "<string>",
"fromState": "<string>",
"id": "<string>",
"machine": "small",
"metadata": {},
"name": "<string>",
"providerNote": "<string>",
"secret": "<string>",
"snapshot": "<string>",
"state": "<string>",
"tokenHeader": "<string>",
"urlToken": "<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>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}Authorizations
Headers
Body
The forms the runner can call a sandbox in besides header, such as helper. The gateway makes a new sandbox at the first provider in its order whose sandboxes the runner can call, and at the next one when that provider refuses with a fault that can clear. Absent, the runner gets only sandboxes of the form header.
832The id of a saved state of the caller's factory (save-managed-sandbox-state) to make the sandbox from, instead of the base snapshot. The state is read only for a new sandbox: a claim that has a sandbox gets that sandbox, whatever this names. A state that cannot be used gets sandbox_state_unusable (409, with reason), and nothing is bound. It does not apply to a resume.
The sandbox gets the machine size in the factory's build settings, and a runner key's request may not change it: the gateway ignores this field from a runner key. A fleet machine's claim recorded the factory's size when it started; a fleet machine that names another size gets machine_differs. A claim that had a sandbox before keeps the size of its first one. The answer's machine names the size.
small, large Set true to make the sandbox of the preview lease the caller holds. A preview lease runs beside the item's own lease, so a runner that holds both names the one it means. Absent, the sandbox is the item's own lease's, or the preview's when the item has no live lease of its own. A preview sandbox is always the small size, ends after four hours, and ignores resume.
The id of the work item's kept sandbox, which the claim resumes instead of a new sandbox. The claim is billed from the resume at the kept sandbox's size, which must be the machine size in the factory's build settings. idleMinutes and metadata do not apply to a resume, and timeLimitMinutes starts the sandbox's time limit again. A sandbox that cannot be resumed gets sandbox_not_resumable (409), and the runner then asks again without resume.
Set true when the runner can wait for a sandbox that is still starting. The gateway then answers 200 with the sandbox in the state starting, and the runner reads it until it has started. Absent, the gateway answers only with a sandbox that has started, and a sandbox that is still starting gets sandbox_provider_refused (502). It does not apply to a resume.