curl --request POST \
--url https://console.gmicloud.ai/api/v2/templates/{template_id}/builds \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"source": {
"type": "image",
"image": "<string>"
},
"commands": [
"<string>"
],
"envs": {},
"start_cmd": "<string>"
}
'import requests
url = "https://console.gmicloud.ai/api/v2/templates/{template_id}/builds"
payload = {
"source": {
"type": "image",
"image": "<string>"
},
"commands": ["<string>"],
"envs": {},
"start_cmd": "<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({
source: {type: 'image', image: '<string>'},
commands: ['<string>'],
envs: {},
start_cmd: '<string>'
})
};
fetch('https://console.gmicloud.ai/api/v2/templates/{template_id}/builds', 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://console.gmicloud.ai/api/v2/templates/{template_id}/builds",
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([
'source' => [
'type' => 'image',
'image' => '<string>'
],
'commands' => [
'<string>'
],
'envs' => [
],
'start_cmd' => '<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://console.gmicloud.ai/api/v2/templates/{template_id}/builds"
payload := strings.NewReader("{\n \"source\": {\n \"type\": \"image\",\n \"image\": \"<string>\"\n },\n \"commands\": [\n \"<string>\"\n ],\n \"envs\": {},\n \"start_cmd\": \"<string>\"\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://console.gmicloud.ai/api/v2/templates/{template_id}/builds")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"source\": {\n \"type\": \"image\",\n \"image\": \"<string>\"\n },\n \"commands\": [\n \"<string>\"\n ],\n \"envs\": {},\n \"start_cmd\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://console.gmicloud.ai/api/v2/templates/{template_id}/builds")
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 \"source\": {\n \"type\": \"image\",\n \"image\": \"<string>\"\n },\n \"commands\": [\n \"<string>\"\n ],\n \"envs\": {},\n \"start_cmd\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"request_id": "<string>",
"data": {
"id": "<string>",
"template_id": "<string>",
"status": "waiting"
}
}{
"code": "Parameter.Invalid",
"message": "Invalid request parameters",
"request_id": "req-xxxx"
}{
"code": "Auth.Unauthorized",
"message": "Authentication required",
"request_id": "req-xxxx"
}{
"code": "Resource.QuotaExceeded",
"message": "The resource quota is not enough.",
"request_id": "req-xxxx",
"details": {}
}{
"code": "Resource.NotFound",
"message": "The requested resource was not found",
"request_id": "req-xxxx"
}{
"code": "Resource.StateConflict",
"message": "Resource state conflict",
"request_id": "req-xxxx"
}{
"code": "Resource.QuotaExceeded",
"message": "The resource quota is not enough.",
"request_id": "req-xxxx",
"details": {}
}{
"code": "Resource.QuotaExceeded",
"message": "The resource quota is not enough.",
"request_id": "req-xxxx",
"details": {}
}{
"code": "Internal.ServerError",
"message": "An internal server error occurred",
"request_id": "req-xxxx"
}Create and start a rebuild
Creates a new Build from the given definition and starts it immediately. A rebuild inherits the most recent Build’s provider and resources, so a Template with no Build records left has nothing to inherit and returns 409. Not supported in every IDC; IDCs without rebuild support reject it with 422.
curl --request POST \
--url https://console.gmicloud.ai/api/v2/templates/{template_id}/builds \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"source": {
"type": "image",
"image": "<string>"
},
"commands": [
"<string>"
],
"envs": {},
"start_cmd": "<string>"
}
'import requests
url = "https://console.gmicloud.ai/api/v2/templates/{template_id}/builds"
payload = {
"source": {
"type": "image",
"image": "<string>"
},
"commands": ["<string>"],
"envs": {},
"start_cmd": "<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({
source: {type: 'image', image: '<string>'},
commands: ['<string>'],
envs: {},
start_cmd: '<string>'
})
};
fetch('https://console.gmicloud.ai/api/v2/templates/{template_id}/builds', 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://console.gmicloud.ai/api/v2/templates/{template_id}/builds",
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([
'source' => [
'type' => 'image',
'image' => '<string>'
],
'commands' => [
'<string>'
],
'envs' => [
],
'start_cmd' => '<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://console.gmicloud.ai/api/v2/templates/{template_id}/builds"
payload := strings.NewReader("{\n \"source\": {\n \"type\": \"image\",\n \"image\": \"<string>\"\n },\n \"commands\": [\n \"<string>\"\n ],\n \"envs\": {},\n \"start_cmd\": \"<string>\"\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://console.gmicloud.ai/api/v2/templates/{template_id}/builds")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"source\": {\n \"type\": \"image\",\n \"image\": \"<string>\"\n },\n \"commands\": [\n \"<string>\"\n ],\n \"envs\": {},\n \"start_cmd\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://console.gmicloud.ai/api/v2/templates/{template_id}/builds")
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 \"source\": {\n \"type\": \"image\",\n \"image\": \"<string>\"\n },\n \"commands\": [\n \"<string>\"\n ],\n \"envs\": {},\n \"start_cmd\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"request_id": "<string>",
"data": {
"id": "<string>",
"template_id": "<string>",
"status": "waiting"
}
}{
"code": "Parameter.Invalid",
"message": "Invalid request parameters",
"request_id": "req-xxxx"
}{
"code": "Auth.Unauthorized",
"message": "Authentication required",
"request_id": "req-xxxx"
}{
"code": "Resource.QuotaExceeded",
"message": "The resource quota is not enough.",
"request_id": "req-xxxx",
"details": {}
}{
"code": "Resource.NotFound",
"message": "The requested resource was not found",
"request_id": "req-xxxx"
}{
"code": "Resource.StateConflict",
"message": "Resource state conflict",
"request_id": "req-xxxx"
}{
"code": "Resource.QuotaExceeded",
"message": "The resource quota is not enough.",
"request_id": "req-xxxx",
"details": {}
}{
"code": "Resource.QuotaExceeded",
"message": "The resource quota is not enough.",
"request_id": "req-xxxx",
"details": {}
}{
"code": "Internal.ServerError",
"message": "An internal server error occurred",
"request_id": "req-xxxx"
}Authorizations
API Key or Access Token, always sent as Authorization: Bearer <token>. The gateway recognizes the token type automatically.
Path Parameters
Owning GMI Template identifier.
Query Parameters
Filter by data center name, e.g. us-denver-1
Body
Manual Build source. Sandbox sources use the snapshot endpoint.
- Option 1
- Option 2
Show child attributes
Show child attributes
Shell command strings executed sequentially during the Build.
1001 - 8192Environment variables available only during the Template Build.
They are visible to subsequent build commands/steps and are not persisted
into the resulting template artifact as sandbox runtime environment
variables. Pass runtime env when creating a Sandbox instead. Write-only:
values are never returned on Template or TemplateBuild responses.
Keys must be unique (JSON object); the server orders them
deterministically by key. Key names must match
[A-Za-z_][A-Za-z0-9_]*.
Show child attributes
Show child attributes
Launch command persisted with the Build and applied when Sandboxes created from this Template start.
1 - 8192