Machines
Set Machine Memory Limit
Set the memory limit of a started Firecracker Machine by resizing its memory balloon. The limit lasts until the Machine stops or is updated.
- Fails with 409 while the Machine has a lease, even when the lease nonce is passed.
PUT
/
v1
/
apps
/
{app_name}
/
machines
/
{machine_id}
/
memory
Set Machine Memory Limit
curl --request PUT \
--url https://api.machines.dev/v1/apps/{app_name}/machines/{machine_id}/memory \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"limit_mb": 123
}
'import requests
url = "https://api.machines.dev/v1/apps/{app_name}/machines/{machine_id}/memory"
payload = { "limit_mb": 123 }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({limit_mb: 123})
};
fetch('https://api.machines.dev/v1/apps/{app_name}/machines/{machine_id}/memory', 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.machines.dev/v1/apps/{app_name}/machines/{machine_id}/memory",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'limit_mb' => 123
]),
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.machines.dev/v1/apps/{app_name}/machines/{machine_id}/memory"
payload := strings.NewReader("{\n \"limit_mb\": 123\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api.machines.dev/v1/apps/{app_name}/machines/{machine_id}/memory")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"limit_mb\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.machines.dev/v1/apps/{app_name}/machines/{machine_id}/memory")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"limit_mb\": 123\n}"
response = http.request(request)
puts response.read_body{
"available_mb": 123,
"limit_mb": 123
}{
"details": {},
"error": "<string>",
"status": "<unknown>"
}{
"details": {},
"error": "<string>",
"status": "<unknown>"
}{
"details": {},
"error": "<string>",
"status": "<unknown>"
}{
"details": {},
"error": "<string>",
"status": "<unknown>"
}{
"details": {},
"error": "<string>",
"status": "<unknown>"
}Authorizations
A Fly API token with access to the requested organization or resource. Send it as Authorization: Bearer <Fly API token>.
Body
application/json
Set memory limit request
New limit in MiB. Must be at least 128 and at most the Machine's configured memory
(guest.max_memory_mb if set, else guest.memory_mb).
⌘I
Set Machine Memory Limit
curl --request PUT \
--url https://api.machines.dev/v1/apps/{app_name}/machines/{machine_id}/memory \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"limit_mb": 123
}
'import requests
url = "https://api.machines.dev/v1/apps/{app_name}/machines/{machine_id}/memory"
payload = { "limit_mb": 123 }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({limit_mb: 123})
};
fetch('https://api.machines.dev/v1/apps/{app_name}/machines/{machine_id}/memory', 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.machines.dev/v1/apps/{app_name}/machines/{machine_id}/memory",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'limit_mb' => 123
]),
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.machines.dev/v1/apps/{app_name}/machines/{machine_id}/memory"
payload := strings.NewReader("{\n \"limit_mb\": 123\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api.machines.dev/v1/apps/{app_name}/machines/{machine_id}/memory")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"limit_mb\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.machines.dev/v1/apps/{app_name}/machines/{machine_id}/memory")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"limit_mb\": 123\n}"
response = http.request(request)
puts response.read_body{
"available_mb": 123,
"limit_mb": 123
}{
"details": {},
"error": "<string>",
"status": "<unknown>"
}{
"details": {},
"error": "<string>",
"status": "<unknown>"
}{
"details": {},
"error": "<string>",
"status": "<unknown>"
}{
"details": {},
"error": "<string>",
"status": "<unknown>"
}{
"details": {},
"error": "<string>",
"status": "<unknown>"
}