Skip to main content
POST
/
environments
/
{environment}
/
variables
Add environment variables
curl --request POST \
  --url https://cloud.laravel.com/api/environments/{environment}/variables \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "variables": [
    {
      "key": "<string>",
      "value": "<string>"
    }
  ]
}
'
import requests

url = "https://cloud.laravel.com/api/environments/{environment}/variables"

payload = { "variables": [
{
"key": "<string>",
"value": "<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({variables: [{key: '<string>', value: '<string>'}]})
};

fetch('https://cloud.laravel.com/api/environments/{environment}/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 => "https://cloud.laravel.com/api/environments/{environment}/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([
'variables' => [
[
'key' => '<string>',
'value' => '<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 := "https://cloud.laravel.com/api/environments/{environment}/variables"

payload := strings.NewReader("{\n \"variables\": [\n {\n \"key\": \"<string>\",\n \"value\": \"<string>\"\n }\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("https://cloud.laravel.com/api/environments/{environment}/variables")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"variables\": [\n {\n \"key\": \"<string>\",\n \"value\": \"<string>\"\n }\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://cloud.laravel.com/api/environments/{environment}/variables")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"variables\": [\n {\n \"key\": \"<string>\",\n \"value\": \"<string>\"\n }\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "data": {
    "id": "<string>",
    "type": "environments",
    "links": {
      "self": {
        "href": "<string>",
        "rel": "<string>",
        "describedby": "<string>",
        "title": "<string>",
        "type": "<string>",
        "hreflang": "<string>",
        "meta": {}
      }
    },
    "attributes": {
      "name": "<string>",
      "slug": "<string>",
      "created_from_automation": true,
      "vanity_domain": "<string>",
      "build_command": "<string>",
      "deploy_command": "<string>",
      "uses_octane": true,
      "uses_hibernation": true,
      "hibernation_wake_up_interval": 123,
      "uses_push_to_deploy": true,
      "uses_deploy_hook": true,
      "environment_variables": [
        {
          "key": "<string>",
          "value": "<string>"
        }
      ],
      "network_settings": {
        "cache": {
          "strategy": "<string>"
        },
        "response_headers": {
          "frame": "<string>",
          "content_type": "<string>",
          "hsts": {
            "max_age": 123,
            "include_subdomains": true,
            "preload": true
          }
        },
        "firewall": {
          "bot_categories": [],
          "rate_limit": {
            "429": true,
            "4xx": true
          },
          "under_attack_mode_started_at": "<string>",
          "block_path": true
        },
        "content_converter": true
      },
      "created_at": "2023-11-07T05:31:56Z"
    },
    "relationships": {
      "application": {
        "data": {
          "type": "applications",
          "id": "<string>"
        }
      },
      "branch": {
        "data": {
          "type": "branches",
          "id": "<string>"
        }
      },
      "deployments": {
        "data": [
          {
            "type": "deployments",
            "id": "<string>"
          }
        ]
      },
      "currentDeployment": {
        "data": {
          "type": "deployments",
          "id": "<string>"
        }
      },
      "domains": {
        "data": [
          {
            "type": "domains",
            "id": "<string>"
          }
        ]
      },
      "primaryDomain": {
        "data": {
          "type": "domains",
          "id": "<string>"
        }
      },
      "instances": {
        "data": [
          {
            "type": "instances",
            "id": "<string>"
          }
        ]
      },
      "database": {
        "data": {
          "type": "databaseSchemas",
          "id": "<string>"
        }
      },
      "cache": {
        "data": {
          "type": "caches",
          "id": "<string>"
        }
      },
      "buckets": {
        "data": [
          {
            "type": "filesystems",
            "id": "<string>"
          }
        ]
      },
      "websocketApplication": {
        "data": {
          "type": "websocketApplications",
          "id": "<string>"
        }
      }
    }
  },
  "included": [
    {
      "id": "<string>",
      "type": "applications",
      "attributes": {
        "name": "<string>",
        "slug": "<string>",
        "slack_channel": "<string>",
        "avatar_url": "<string>",
        "created_at": "2023-11-07T05:31:56Z",
        "repository": {
          "full_name": "<string>",
          "default_branch": "<string>"
        }
      },
      "relationships": {
        "repository": {
          "data": {
            "type": "repositories",
            "id": "<string>"
          }
        },
        "organization": {
          "data": {
            "type": "organizations",
            "id": "<string>"
          }
        },
        "environments": {
          "data": [
            {
              "type": "environments",
              "id": "<string>"
            }
          ]
        },
        "deployments": {
          "data": [
            {
              "type": "deployments",
              "id": "<string>"
            }
          ]
        },
        "defaultEnvironment": {
          "data": {
            "type": "environments",
            "id": "<string>"
          }
        }
      }
    }
  ]
}
{
"message": "<string>"
}
{
"message": "<string>",
"errors": {}
}

Authorizations

Authorization
string
header
required

The Bearer Token generated on the Cloud UI.

Path Parameters

environment
string
required

The environment identifier

Body

application/json
method
enum<string>
required

When set to 'append', variables are added to the end without checking for duplicates. When set to 'set', variables with matching keys are updated; otherwise they are added.

Available options:
append,
set
variables
object[]
required
Required array length: 1 - 200 elements

Response

EnvironmentResource

data
EnvironmentResource · object
required
included
(ApplicationResource · object | BranchResource · object | DeploymentResource · object | DomainResource · object | InstanceResource · object | DatabaseSchemaResource · object | CacheResource · object | FilesystemResource · object | WebsocketApplicationResource · object)[]