Skip to main content
PUT
/
v2
/
apps
/
{app_id}
/
envs
Overwrite Variables
curl --request PUT \
  --url https://api.squarecloud.app/v2/apps/{app_id}/envs \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '{
  "envs": {}
}'
import requests

url = "https://api.squarecloud.app/v2/apps/{app_id}/envs"

payload = { "envs": {} }
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'PUT',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({envs: {}})
};

fetch('https://api.squarecloud.app/v2/apps/{app_id}/envs', 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.squarecloud.app/v2/apps/{app_id}/envs",
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([
'envs' => [

]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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.squarecloud.app/v2/apps/{app_id}/envs"

payload := strings.NewReader("{\n \"envs\": {}\n}")

req, _ := http.NewRequest("PUT", url, payload)

req.Header.Add("Authorization", "<authorization>")
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.squarecloud.app/v2/apps/{app_id}/envs")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"envs\": {}\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.squarecloud.app/v2/apps/{app_id}/envs")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"envs\": {}\n}"

response = http.request(request)
puts response.read_body
{
  "status": "success",
  "response": {
    "TEST": "overwriteTest"
  }
}
Authorization
string
required
The API key for your account. You can find this in your account settings.
Overwrite replaces the application’s entire environment with exactly the variables you send: anything already set that isn’t included in the request body is deleted. Sending an empty envs object wipes every variable, which makes this the endpoint to use for a full reset rather than an incremental change. The same limits as other environment variable endpoints apply: up to 256 variables per application, 1024 characters per key, 4096 per value. Static applications aren’t supported and return an error, and on workspace-shared applications the caller needs the Administrator role or ownership. If you only need to change a few variables without touching the rest, use Add/Edit Variables instead, or Remove Variables to delete specific keys.

Parameters

app_id
string
required
The application ID.
envs
object
The key and value variables you want on the environment.

Response

status
string
Indicates whether the call was successful.. success if successful, error if not.
response
object
The key and value of all environment variables you defined.
{
  "status": "success",
  "response": {
    "TEST": "overwriteTest"
  }
}

Common errors

CodeHTTPMeaning
STATIC_APP_ENV_NOT_SUPPORTED400The application is static; static apps don’t support environment variables.
INVALID_ENV_CONTENT400envs is missing, not an object, or an array.
TOO_MANY_ENV_VARS400The new set would exceed 256 environment variables.
ENV_NAME_TOO_LONG400A variable key exceeds 1024 characters.
ENV_CONTENT_TOO_LONG400A variable value exceeds 4096 characters.