Skip to main content
POST
/
api
/
v1
/
templates
/
compile
Compile Template
curl --request POST \
  --url https://control-plane.kubiya.ai/api/v1/templates/compile \
  --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
}'
{
  "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": []
}

Body

application/json

Request schema for template compilation endpoint.

template
string
required

Template string with {{variable}} syntax

Minimum length: 1
context
object | null

Context for compilation (variables, secrets, env_vars)

validate_only
boolean
default:false

Only validate syntax without compiling

environment_id
string | null

Environment ID for secret validation

Response

Successful Response

Response schema for template compilation endpoint.

valid
boolean
required

Whether the template is valid

compiled
string | null

Compiled template (if valid and context provided)

variables
TemplateVariableSchema · object[]

Variables found in template

errors
ValidationErrorSchema · object[]

Validation/compilation errors

warnings
string[]

Non-fatal warnings