Replace the .env file for an app
const url = 'https://your-server.example/api/apps/example/env';const options = { method: 'PUT', headers: {cookie: 'session=<session>', 'Content-Type': 'application/json'}, body: '[{"key":"example","value":"example"}]'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PUT \ --url https://your-server.example/api/apps/example/env \ --header 'Content-Type: application/json' \ --cookie session=<session> \ --data '[ { "key": "example", "value": "example" } ]'Replaces the whole file. Not available to viewers. Never send masked entries back: their empty value would overwrite the secret.
The compose file is checked with the new values like a compose edit: 400 when the values make it fail the security checks or stop it loading; 409 when it already fails the checks with the current .env (fix and redeploy it first) or a value moves an endpoint onto a domain another app or the dashboard uses.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”App slug (lowercase, dash-separated).
Request Bodyrequired
Section titled “Request Bodyrequired”object
Example generated
[ { "key": "example", "value": "example" }]Responses
Section titled “Responses”Env saved (does not redeploy).
object
Example
{ "status": "ok"}Invalid request, or the compose file fails security checks (JSON body with every reason).
object
Example
{ "error": "compose file contains disallowed directives", "violations": [ "service \"web\": privileged mode not allowed" ]}The change cannot be applied: a domain belongs to another app or the dashboard (text body), or the app’s current compose file fails security checks (JSON body with every reason; fix and redeploy it first).
object
Example
{ "error": "compose file contains disallowed directives", "violations": [ "service \"web\": privileged mode not allowed" ]}