Skip to main content
POST
/
v1
/
apps
/
{id}
/
envs
Create or Edit Application Environment Variables
curl --request POST \
  --url https://api.vertracloud.app/v1/apps/{id}/envs \
  --header 'Content-Type: application/json' \
  --data '
{
  "environments": [
    {}
  ]
}
'
import requests

url = "https://api.vertracloud.app/v1/apps/{id}/envs"

payload = { "environments": [{}] }
headers = {"Content-Type": "application/json"}

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

print(response.text)
const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({environments: [{}]})
};

fetch('https://api.vertracloud.app/v1/apps/{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.vertracloud.app/v1/apps/{id}/envs",
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([
'environments' => [
[

]
]
]),
CURLOPT_HTTPHEADER => [
"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.vertracloud.app/v1/apps/{id}/envs"

payload := strings.NewReader("{\n \"environments\": [\n {}\n ]\n}")

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

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.vertracloud.app/v1/apps/{id}/envs")
.header("Content-Type", "application/json")
.body("{\n \"environments\": [\n {}\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.vertracloud.app/v1/apps/{id}/envs")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"environments\": [\n {}\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "response": [
    {
      "id": "env123",
      "key": "API_KEY",
      "value": "secret123",
      "note": "API key for external service",
      "created_at": "2026-03-14T19:58:00Z"
    },
    {
      "id": "env456",
      "key": "DATABASE_URL",
      "value": "mysql://user:pass@localhost/db",
      "note": null,
      "created_at": "2026-03-14T19:58:00Z"
    }
  ]
}
id
string
required
The ID of the application to create or update environment variables for. If the application belongs to a workspace, include the workspace_id in the format appId-workspace_id.
environments
array
required
An array of environment variable objects.

Response

response
array
An array of environment variable objects after creation or update.
{
  "response": [
    {
      "id": "env123",
      "key": "API_KEY",
      "value": "secret123",
      "note": "API key for external service",
      "created_at": "2026-03-14T19:58:00Z"
    },
    {
      "id": "env456",
      "key": "DATABASE_URL",
      "value": "mysql://user:pass@localhost/db",
      "note": null,
      "created_at": "2026-03-14T19:58:00Z"
    }
  ]
}

Error Responses

code
string
The error code indicating the reason for failure. Possible values:
  • UNAUTHORIZED: The user is not authenticated or lacks sufficient permissions.
  • FORBIDDEN: The user does not have permission to access the application.
  • APP_NOT_FOUND: The specified application does not exist.
  • INVALID_BODY: The request body is not a valid array or is empty.
  • INVALID_ENVIRONMENT: One or more environment variables are invalid or use forbidden keys.
  • ENV_VARIABLE_TOO_LONG: An environment variable key or value exceeds length limits.
  • ENV_LIMIT_EXCEEDED: The total number of environment variables exceeds the limit of 25.
message
string
A descriptive message providing additional details about the error.
{
  "code": "UNAUTHORIZED"
}
{
  "code": "APP_NOT_FOUND"
}
{
  "code": "INVALID_BODY"
}