Compile Template
curl --request POST \
--url https://control-plane.kubiya.ai/api/v1/templates/compile \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"context": {
"env_vars": {
"PORT": "8080"
},
"secrets": {
"api_key": "secret-value"
},
"variables": {}
},
"environment_id": "env-123",
"template": "http://api.example.com:{{.env.PORT}}/auth?key={{.secret.api_key}}",
"validate_only": false
}
'import requests
url = "https://control-plane.kubiya.ai/api/v1/templates/compile"
payload = {
"context": {
"env_vars": { "PORT": "8080" },
"secrets": { "api_key": "secret-value" },
"variables": {}
},
"environment_id": "env-123",
"template": "http://api.example.com:{{.env.PORT}}/auth?key={{.secret.api_key}}",
"validate_only": False
}
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({
context: {env_vars: {PORT: '8080'}, secrets: {api_key: 'secret-value'}, variables: {}},
environment_id: 'env-123',
template: 'http://api.example.com:{{.env.PORT}}/auth?key={{.secret.api_key}}',
validate_only: false
})
};
fetch('https://control-plane.kubiya.ai/api/v1/templates/compile', 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://control-plane.kubiya.ai/api/v1/templates/compile",
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([
'context' => [
'env_vars' => [
'PORT' => '8080'
],
'secrets' => [
'api_key' => 'secret-value'
],
'variables' => [
]
],
'environment_id' => 'env-123',
'template' => 'http://api.example.com:{{.env.PORT}}/auth?key={{.secret.api_key}}',
'validate_only' => false
]),
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://control-plane.kubiya.ai/api/v1/templates/compile"
payload := strings.NewReader("{\n \"context\": {\n \"env_vars\": {\n \"PORT\": \"8080\"\n },\n \"secrets\": {\n \"api_key\": \"secret-value\"\n },\n \"variables\": {}\n },\n \"environment_id\": \"env-123\",\n \"template\": \"http://api.example.com:{{.env.PORT}}/auth?key={{.secret.api_key}}\",\n \"validate_only\": false\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://control-plane.kubiya.ai/api/v1/templates/compile")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"context\": {\n \"env_vars\": {\n \"PORT\": \"8080\"\n },\n \"secrets\": {\n \"api_key\": \"secret-value\"\n },\n \"variables\": {}\n },\n \"environment_id\": \"env-123\",\n \"template\": \"http://api.example.com:{{.env.PORT}}/auth?key={{.secret.api_key}}\",\n \"validate_only\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://control-plane.kubiya.ai/api/v1/templates/compile")
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 \"context\": {\n \"env_vars\": {\n \"PORT\": \"8080\"\n },\n \"secrets\": {\n \"api_key\": \"secret-value\"\n },\n \"variables\": {}\n },\n \"environment_id\": \"env-123\",\n \"template\": \"http://api.example.com:{{.env.PORT}}/auth?key={{.secret.api_key}}\",\n \"validate_only\": false\n}"
response = http.request(request)
puts response.read_body{
"compiled": "http://api.example.com:8080/auth?key=secret-value",
"errors": [],
"valid": true,
"variables": [
{
"display_name": "PORT",
"end": 38,
"name": "env.PORT",
"raw": "{{.env.PORT}}",
"start": 25,
"type": "env"
},
{
"display_name": "api_key",
"end": 68,
"name": "secret.api_key",
"raw": "{{.secret.api_key}}",
"start": 48,
"type": "secret"
}
],
"warnings": []
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}templates
Compile Template
Compile a template by substituting variables with values from context.
This endpoint:
- Parses the template to extract variables
- Validates syntax
- If context provided: validates against context and compiles
- If validate_only=True: only validates without compiling
Returns detailed information about variables, errors, and warnings.
POST
/
api
/
v1
/
templates
/
compile
Compile Template
curl --request POST \
--url https://control-plane.kubiya.ai/api/v1/templates/compile \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"context": {
"env_vars": {
"PORT": "8080"
},
"secrets": {
"api_key": "secret-value"
},
"variables": {}
},
"environment_id": "env-123",
"template": "http://api.example.com:{{.env.PORT}}/auth?key={{.secret.api_key}}",
"validate_only": false
}
'import requests
url = "https://control-plane.kubiya.ai/api/v1/templates/compile"
payload = {
"context": {
"env_vars": { "PORT": "8080" },
"secrets": { "api_key": "secret-value" },
"variables": {}
},
"environment_id": "env-123",
"template": "http://api.example.com:{{.env.PORT}}/auth?key={{.secret.api_key}}",
"validate_only": False
}
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({
context: {env_vars: {PORT: '8080'}, secrets: {api_key: 'secret-value'}, variables: {}},
environment_id: 'env-123',
template: 'http://api.example.com:{{.env.PORT}}/auth?key={{.secret.api_key}}',
validate_only: false
})
};
fetch('https://control-plane.kubiya.ai/api/v1/templates/compile', 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://control-plane.kubiya.ai/api/v1/templates/compile",
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([
'context' => [
'env_vars' => [
'PORT' => '8080'
],
'secrets' => [
'api_key' => 'secret-value'
],
'variables' => [
]
],
'environment_id' => 'env-123',
'template' => 'http://api.example.com:{{.env.PORT}}/auth?key={{.secret.api_key}}',
'validate_only' => false
]),
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://control-plane.kubiya.ai/api/v1/templates/compile"
payload := strings.NewReader("{\n \"context\": {\n \"env_vars\": {\n \"PORT\": \"8080\"\n },\n \"secrets\": {\n \"api_key\": \"secret-value\"\n },\n \"variables\": {}\n },\n \"environment_id\": \"env-123\",\n \"template\": \"http://api.example.com:{{.env.PORT}}/auth?key={{.secret.api_key}}\",\n \"validate_only\": false\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://control-plane.kubiya.ai/api/v1/templates/compile")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"context\": {\n \"env_vars\": {\n \"PORT\": \"8080\"\n },\n \"secrets\": {\n \"api_key\": \"secret-value\"\n },\n \"variables\": {}\n },\n \"environment_id\": \"env-123\",\n \"template\": \"http://api.example.com:{{.env.PORT}}/auth?key={{.secret.api_key}}\",\n \"validate_only\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://control-plane.kubiya.ai/api/v1/templates/compile")
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 \"context\": {\n \"env_vars\": {\n \"PORT\": \"8080\"\n },\n \"secrets\": {\n \"api_key\": \"secret-value\"\n },\n \"variables\": {}\n },\n \"environment_id\": \"env-123\",\n \"template\": \"http://api.example.com:{{.env.PORT}}/auth?key={{.secret.api_key}}\",\n \"validate_only\": false\n}"
response = http.request(request)
puts response.read_body{
"compiled": "http://api.example.com:8080/auth?key=secret-value",
"errors": [],
"valid": true,
"variables": [
{
"display_name": "PORT",
"end": 38,
"name": "env.PORT",
"raw": "{{.env.PORT}}",
"start": 25,
"type": "env"
},
{
"display_name": "api_key",
"end": 68,
"name": "secret.api_key",
"raw": "{{.secret.api_key}}",
"start": 48,
"type": "secret"
}
],
"warnings": []
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Authorizations
Enter your Kubiya API token (format: Bearer )
Body
application/json
Request schema for template compilation endpoint.
Template string with {{variable}} syntax
Minimum string length:
1Context for compilation (variables, secrets, env_vars)
Only validate syntax without compiling
Environment ID for secret validation
Response
Successful Response
Response schema for template compilation endpoint.
Whether the template is valid
Compiled template (if valid and context provided)
Variables found in template
Show child attributes
Show child attributes
Validation/compilation errors
Show child attributes
Show child attributes
Non-fatal warnings
Was this page helpful?
⌘I