Add a project variable
curl --request POST \
--url {schemes}://api.upsun.com/projects/{projectId}/variables \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"value": "<string>",
"attributes": {},
"is_json": true,
"is_sensitive": true,
"visible_build": true,
"visible_runtime": true,
"application_scope": [
"<string>"
]
}
'import requests
url = "{schemes}://api.upsun.com/projects/{projectId}/variables"
payload = {
"name": "<string>",
"value": "<string>",
"attributes": {},
"is_json": True,
"is_sensitive": True,
"visible_build": True,
"visible_runtime": True,
"application_scope": ["<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({
name: '<string>',
value: '<string>',
attributes: {},
is_json: true,
is_sensitive: true,
visible_build: true,
visible_runtime: true,
application_scope: ['<string>']
})
};
fetch('{schemes}://api.upsun.com/projects/{projectId}/variables', 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 => "{schemes}://api.upsun.com/projects/{projectId}/variables",
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([
'name' => '<string>',
'value' => '<string>',
'attributes' => [
],
'is_json' => true,
'is_sensitive' => true,
'visible_build' => true,
'visible_runtime' => true,
'application_scope' => [
'<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 := "{schemes}://api.upsun.com/projects/{projectId}/variables"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"value\": \"<string>\",\n \"attributes\": {},\n \"is_json\": true,\n \"is_sensitive\": true,\n \"visible_build\": true,\n \"visible_runtime\": true,\n \"application_scope\": [\n \"<string>\"\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("{schemes}://api.upsun.com/projects/{projectId}/variables")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"value\": \"<string>\",\n \"attributes\": {},\n \"is_json\": true,\n \"is_sensitive\": true,\n \"visible_build\": true,\n \"visible_runtime\": true,\n \"application_scope\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("{schemes}://api.upsun.com/projects/{projectId}/variables")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"value\": \"<string>\",\n \"attributes\": {},\n \"is_json\": true,\n \"is_sensitive\": true,\n \"visible_build\": true,\n \"visible_runtime\": true,\n \"application_scope\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"status": "<string>",
"code": 123
}Project Variables
Add a project variable
Add a variable to a project. The value can be either a string or a JSON
object (default: string), as specified by the is_json boolean flag.
See the Variables
section in our documentation for more information.
POST
/
projects
/
{projectId}
/
variables
Add a project variable
curl --request POST \
--url {schemes}://api.upsun.com/projects/{projectId}/variables \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"value": "<string>",
"attributes": {},
"is_json": true,
"is_sensitive": true,
"visible_build": true,
"visible_runtime": true,
"application_scope": [
"<string>"
]
}
'import requests
url = "{schemes}://api.upsun.com/projects/{projectId}/variables"
payload = {
"name": "<string>",
"value": "<string>",
"attributes": {},
"is_json": True,
"is_sensitive": True,
"visible_build": True,
"visible_runtime": True,
"application_scope": ["<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({
name: '<string>',
value: '<string>',
attributes: {},
is_json: true,
is_sensitive: true,
visible_build: true,
visible_runtime: true,
application_scope: ['<string>']
})
};
fetch('{schemes}://api.upsun.com/projects/{projectId}/variables', 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 => "{schemes}://api.upsun.com/projects/{projectId}/variables",
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([
'name' => '<string>',
'value' => '<string>',
'attributes' => [
],
'is_json' => true,
'is_sensitive' => true,
'visible_build' => true,
'visible_runtime' => true,
'application_scope' => [
'<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 := "{schemes}://api.upsun.com/projects/{projectId}/variables"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"value\": \"<string>\",\n \"attributes\": {},\n \"is_json\": true,\n \"is_sensitive\": true,\n \"visible_build\": true,\n \"visible_runtime\": true,\n \"application_scope\": [\n \"<string>\"\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("{schemes}://api.upsun.com/projects/{projectId}/variables")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"value\": \"<string>\",\n \"attributes\": {},\n \"is_json\": true,\n \"is_sensitive\": true,\n \"visible_build\": true,\n \"visible_runtime\": true,\n \"application_scope\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("{schemes}://api.upsun.com/projects/{projectId}/variables")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"value\": \"<string>\",\n \"attributes\": {},\n \"is_json\": true,\n \"is_sensitive\": true,\n \"visible_build\": true,\n \"visible_runtime\": true,\n \"application_scope\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"status": "<string>",
"code": 123
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Body
application/json
Name of the variable
Value of the variable
Arbitrary attributes attached to this resource
Show child attributes
Show child attributes
The variable is a JSON string
The variable is sensitive
The variable is visible during build
The variable is visible at runtime
Applications that have access to this variable
Last modified on June 16, 2026
Was this page helpful?