curl --request POST \
--url {schemes}://api.upsun.com/projects/{projectId}/environments/{environmentId}/initialize \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"profile": "<string>",
"repository": "<string>",
"config": "<string>",
"files": [
{
"path": "<string>",
"mode": 123,
"contents": "<string>"
}
],
"resources": {}
}
'import requests
url = "{schemes}://api.upsun.com/projects/{projectId}/environments/{environmentId}/initialize"
payload = {
"profile": "<string>",
"repository": "<string>",
"config": "<string>",
"files": [
{
"path": "<string>",
"mode": 123,
"contents": "<string>"
}
],
"resources": {}
}
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({
profile: '<string>',
repository: '<string>',
config: '<string>',
files: [{path: '<string>', mode: 123, contents: '<string>'}],
resources: {}
})
};
fetch('{schemes}://api.upsun.com/projects/{projectId}/environments/{environmentId}/initialize', 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}/environments/{environmentId}/initialize",
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([
'profile' => '<string>',
'repository' => '<string>',
'config' => '<string>',
'files' => [
[
'path' => '<string>',
'mode' => 123,
'contents' => '<string>'
]
],
'resources' => [
]
]),
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}/environments/{environmentId}/initialize"
payload := strings.NewReader("{\n \"profile\": \"<string>\",\n \"repository\": \"<string>\",\n \"config\": \"<string>\",\n \"files\": [\n {\n \"path\": \"<string>\",\n \"mode\": 123,\n \"contents\": \"<string>\"\n }\n ],\n \"resources\": {}\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}/environments/{environmentId}/initialize")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"profile\": \"<string>\",\n \"repository\": \"<string>\",\n \"config\": \"<string>\",\n \"files\": [\n {\n \"path\": \"<string>\",\n \"mode\": 123,\n \"contents\": \"<string>\"\n }\n ],\n \"resources\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("{schemes}://api.upsun.com/projects/{projectId}/environments/{environmentId}/initialize")
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 \"profile\": \"<string>\",\n \"repository\": \"<string>\",\n \"config\": \"<string>\",\n \"files\": [\n {\n \"path\": \"<string>\",\n \"mode\": 123,\n \"contents\": \"<string>\"\n }\n ],\n \"resources\": {}\n}"
response = http.request(request)
puts response.read_body{
"status": "<string>",
"code": 123
}Initialize a new environment
Initialize and configure a new environment with an existing repository. The payload is the url of a git repository with a profile name:
{
"repository": "git@github.com:platformsh/a-project-template.git@master",
"profile": "Example Project",
"files": [
{
"mode": 0600,
"path": "config.json",
"contents": "XXXXXXXX"
}
]
}
It can optionally carry additional files that will be committed to the repository, the POSIX file mode to set on each file, and the base64-encoded contents of each file.
This endpoint can also add a second repository
URL in the config parameter that will be added to the contents of the first.
This allows you to put your application in one repository and the Upsun
YAML configuration files in another.
curl --request POST \
--url {schemes}://api.upsun.com/projects/{projectId}/environments/{environmentId}/initialize \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"profile": "<string>",
"repository": "<string>",
"config": "<string>",
"files": [
{
"path": "<string>",
"mode": 123,
"contents": "<string>"
}
],
"resources": {}
}
'import requests
url = "{schemes}://api.upsun.com/projects/{projectId}/environments/{environmentId}/initialize"
payload = {
"profile": "<string>",
"repository": "<string>",
"config": "<string>",
"files": [
{
"path": "<string>",
"mode": 123,
"contents": "<string>"
}
],
"resources": {}
}
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({
profile: '<string>',
repository: '<string>',
config: '<string>',
files: [{path: '<string>', mode: 123, contents: '<string>'}],
resources: {}
})
};
fetch('{schemes}://api.upsun.com/projects/{projectId}/environments/{environmentId}/initialize', 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}/environments/{environmentId}/initialize",
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([
'profile' => '<string>',
'repository' => '<string>',
'config' => '<string>',
'files' => [
[
'path' => '<string>',
'mode' => 123,
'contents' => '<string>'
]
],
'resources' => [
]
]),
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}/environments/{environmentId}/initialize"
payload := strings.NewReader("{\n \"profile\": \"<string>\",\n \"repository\": \"<string>\",\n \"config\": \"<string>\",\n \"files\": [\n {\n \"path\": \"<string>\",\n \"mode\": 123,\n \"contents\": \"<string>\"\n }\n ],\n \"resources\": {}\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}/environments/{environmentId}/initialize")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"profile\": \"<string>\",\n \"repository\": \"<string>\",\n \"config\": \"<string>\",\n \"files\": [\n {\n \"path\": \"<string>\",\n \"mode\": 123,\n \"contents\": \"<string>\"\n }\n ],\n \"resources\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("{schemes}://api.upsun.com/projects/{projectId}/environments/{environmentId}/initialize")
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 \"profile\": \"<string>\",\n \"repository\": \"<string>\",\n \"config\": \"<string>\",\n \"files\": [\n {\n \"path\": \"<string>\",\n \"mode\": 123,\n \"contents\": \"<string>\"\n }\n ],\n \"resources\": {}\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.
Body
Name of the profile to show in the UI
Repository to clone from
Repository to clone the configuration files from
A list of files to add to the repository during initialization
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Was this page helpful?