Generate template code
curl --request POST \
--url http://localhost:4005/v1/templates/generate-code \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"blocks": [
{
"assignment": "<string>",
"blockId": "<string>",
"children": "<array>",
"collection": "<string>",
"condition": "<string>",
"content": "<string>",
"elifBranches": [
{
"children": "<array>",
"condition": "<string>"
}
],
"elseChildren": "<array>",
"expression": "<string>",
"field": "<string>",
"filters": [
{
"args": "<string>",
"name": "<string>"
}
],
"format": "<string>",
"function": "<string>",
"inline": true,
"iterator": "<string>",
"properties": {},
"tagArgs": "<string>",
"tagName": "<string>",
"trimWhitespace": true,
"type": "<string>",
"variable": "<string>"
}
],
"format": "<string>"
}
'import requests
url = "http://localhost:4005/v1/templates/generate-code"
payload = {
"blocks": [
{
"assignment": "<string>",
"blockId": "<string>",
"children": "<array>",
"collection": "<string>",
"condition": "<string>",
"content": "<string>",
"elifBranches": [
{
"children": "<array>",
"condition": "<string>"
}
],
"elseChildren": "<array>",
"expression": "<string>",
"field": "<string>",
"filters": [
{
"args": "<string>",
"name": "<string>"
}
],
"format": "<string>",
"function": "<string>",
"inline": True,
"iterator": "<string>",
"properties": {},
"tagArgs": "<string>",
"tagName": "<string>",
"trimWhitespace": True,
"type": "<string>",
"variable": "<string>"
}
],
"format": "<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({
blocks: [
{
assignment: '<string>',
blockId: '<string>',
children: '<array>',
collection: '<string>',
condition: '<string>',
content: '<string>',
elifBranches: [{children: '<array>', condition: '<string>'}],
elseChildren: '<array>',
expression: '<string>',
field: '<string>',
filters: [{args: '<string>', name: '<string>'}],
format: '<string>',
function: '<string>',
inline: true,
iterator: '<string>',
properties: {},
tagArgs: '<string>',
tagName: '<string>',
trimWhitespace: true,
type: '<string>',
variable: '<string>'
}
],
format: '<string>'
})
};
fetch('http://localhost:4005/v1/templates/generate-code', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "4005",
CURLOPT_URL => "http://localhost:4005/v1/templates/generate-code",
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([
'blocks' => [
[
'assignment' => '<string>',
'blockId' => '<string>',
'children' => '<array>',
'collection' => '<string>',
'condition' => '<string>',
'content' => '<string>',
'elifBranches' => [
[
'children' => '<array>',
'condition' => '<string>'
]
],
'elseChildren' => '<array>',
'expression' => '<string>',
'field' => '<string>',
'filters' => [
[
'args' => '<string>',
'name' => '<string>'
]
],
'format' => '<string>',
'function' => '<string>',
'inline' => true,
'iterator' => '<string>',
'properties' => [
],
'tagArgs' => '<string>',
'tagName' => '<string>',
'trimWhitespace' => true,
'type' => '<string>',
'variable' => '<string>'
]
],
'format' => '<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 := "http://localhost:4005/v1/templates/generate-code"
payload := strings.NewReader("{\n \"blocks\": [\n {\n \"assignment\": \"<string>\",\n \"blockId\": \"<string>\",\n \"children\": \"<array>\",\n \"collection\": \"<string>\",\n \"condition\": \"<string>\",\n \"content\": \"<string>\",\n \"elifBranches\": [\n {\n \"children\": \"<array>\",\n \"condition\": \"<string>\"\n }\n ],\n \"elseChildren\": \"<array>\",\n \"expression\": \"<string>\",\n \"field\": \"<string>\",\n \"filters\": [\n {\n \"args\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"format\": \"<string>\",\n \"function\": \"<string>\",\n \"inline\": true,\n \"iterator\": \"<string>\",\n \"properties\": {},\n \"tagArgs\": \"<string>\",\n \"tagName\": \"<string>\",\n \"trimWhitespace\": true,\n \"type\": \"<string>\",\n \"variable\": \"<string>\"\n }\n ],\n \"format\": \"<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("http://localhost:4005/v1/templates/generate-code")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"blocks\": [\n {\n \"assignment\": \"<string>\",\n \"blockId\": \"<string>\",\n \"children\": \"<array>\",\n \"collection\": \"<string>\",\n \"condition\": \"<string>\",\n \"content\": \"<string>\",\n \"elifBranches\": [\n {\n \"children\": \"<array>\",\n \"condition\": \"<string>\"\n }\n ],\n \"elseChildren\": \"<array>\",\n \"expression\": \"<string>\",\n \"field\": \"<string>\",\n \"filters\": [\n {\n \"args\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"format\": \"<string>\",\n \"function\": \"<string>\",\n \"inline\": true,\n \"iterator\": \"<string>\",\n \"properties\": {},\n \"tagArgs\": \"<string>\",\n \"tagName\": \"<string>\",\n \"trimWhitespace\": true,\n \"type\": \"<string>\",\n \"variable\": \"<string>\"\n }\n ],\n \"format\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:4005/v1/templates/generate-code")
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 \"blocks\": [\n {\n \"assignment\": \"<string>\",\n \"blockId\": \"<string>\",\n \"children\": \"<array>\",\n \"collection\": \"<string>\",\n \"condition\": \"<string>\",\n \"content\": \"<string>\",\n \"elifBranches\": [\n {\n \"children\": \"<array>\",\n \"condition\": \"<string>\"\n }\n ],\n \"elseChildren\": \"<array>\",\n \"expression\": \"<string>\",\n \"field\": \"<string>\",\n \"filters\": [\n {\n \"args\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"format\": \"<string>\",\n \"function\": \"<string>\",\n \"inline\": true,\n \"iterator\": \"<string>\",\n \"properties\": {},\n \"tagArgs\": \"<string>\",\n \"tagName\": \"<string>\",\n \"trimWhitespace\": true,\n \"type\": \"<string>\",\n \"variable\": \"<string>\"\n }\n ],\n \"format\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"code": "<string>",
"mappedFields": {}
}{
"code": "<string>",
"detail": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
],
"instance": "<string>",
"status": 123,
"title": "<string>",
"type": "about:blank"
}{
"code": "<string>",
"detail": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
],
"instance": "<string>",
"status": 123,
"title": "<string>",
"type": "about:blank"
}{
"code": "<string>",
"detail": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
],
"instance": "<string>",
"status": 123,
"title": "<string>",
"type": "about:blank"
}{
"code": "<string>",
"detail": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
],
"instance": "<string>",
"status": 123,
"title": "<string>",
"type": "about:blank"
}Generate template code
Converts template-builder blocks into Pongo2 template code and mapped fields.
POST
/
v1
/
templates
/
generate-code
Generate template code
curl --request POST \
--url http://localhost:4005/v1/templates/generate-code \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"blocks": [
{
"assignment": "<string>",
"blockId": "<string>",
"children": "<array>",
"collection": "<string>",
"condition": "<string>",
"content": "<string>",
"elifBranches": [
{
"children": "<array>",
"condition": "<string>"
}
],
"elseChildren": "<array>",
"expression": "<string>",
"field": "<string>",
"filters": [
{
"args": "<string>",
"name": "<string>"
}
],
"format": "<string>",
"function": "<string>",
"inline": true,
"iterator": "<string>",
"properties": {},
"tagArgs": "<string>",
"tagName": "<string>",
"trimWhitespace": true,
"type": "<string>",
"variable": "<string>"
}
],
"format": "<string>"
}
'import requests
url = "http://localhost:4005/v1/templates/generate-code"
payload = {
"blocks": [
{
"assignment": "<string>",
"blockId": "<string>",
"children": "<array>",
"collection": "<string>",
"condition": "<string>",
"content": "<string>",
"elifBranches": [
{
"children": "<array>",
"condition": "<string>"
}
],
"elseChildren": "<array>",
"expression": "<string>",
"field": "<string>",
"filters": [
{
"args": "<string>",
"name": "<string>"
}
],
"format": "<string>",
"function": "<string>",
"inline": True,
"iterator": "<string>",
"properties": {},
"tagArgs": "<string>",
"tagName": "<string>",
"trimWhitespace": True,
"type": "<string>",
"variable": "<string>"
}
],
"format": "<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({
blocks: [
{
assignment: '<string>',
blockId: '<string>',
children: '<array>',
collection: '<string>',
condition: '<string>',
content: '<string>',
elifBranches: [{children: '<array>', condition: '<string>'}],
elseChildren: '<array>',
expression: '<string>',
field: '<string>',
filters: [{args: '<string>', name: '<string>'}],
format: '<string>',
function: '<string>',
inline: true,
iterator: '<string>',
properties: {},
tagArgs: '<string>',
tagName: '<string>',
trimWhitespace: true,
type: '<string>',
variable: '<string>'
}
],
format: '<string>'
})
};
fetch('http://localhost:4005/v1/templates/generate-code', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "4005",
CURLOPT_URL => "http://localhost:4005/v1/templates/generate-code",
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([
'blocks' => [
[
'assignment' => '<string>',
'blockId' => '<string>',
'children' => '<array>',
'collection' => '<string>',
'condition' => '<string>',
'content' => '<string>',
'elifBranches' => [
[
'children' => '<array>',
'condition' => '<string>'
]
],
'elseChildren' => '<array>',
'expression' => '<string>',
'field' => '<string>',
'filters' => [
[
'args' => '<string>',
'name' => '<string>'
]
],
'format' => '<string>',
'function' => '<string>',
'inline' => true,
'iterator' => '<string>',
'properties' => [
],
'tagArgs' => '<string>',
'tagName' => '<string>',
'trimWhitespace' => true,
'type' => '<string>',
'variable' => '<string>'
]
],
'format' => '<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 := "http://localhost:4005/v1/templates/generate-code"
payload := strings.NewReader("{\n \"blocks\": [\n {\n \"assignment\": \"<string>\",\n \"blockId\": \"<string>\",\n \"children\": \"<array>\",\n \"collection\": \"<string>\",\n \"condition\": \"<string>\",\n \"content\": \"<string>\",\n \"elifBranches\": [\n {\n \"children\": \"<array>\",\n \"condition\": \"<string>\"\n }\n ],\n \"elseChildren\": \"<array>\",\n \"expression\": \"<string>\",\n \"field\": \"<string>\",\n \"filters\": [\n {\n \"args\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"format\": \"<string>\",\n \"function\": \"<string>\",\n \"inline\": true,\n \"iterator\": \"<string>\",\n \"properties\": {},\n \"tagArgs\": \"<string>\",\n \"tagName\": \"<string>\",\n \"trimWhitespace\": true,\n \"type\": \"<string>\",\n \"variable\": \"<string>\"\n }\n ],\n \"format\": \"<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("http://localhost:4005/v1/templates/generate-code")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"blocks\": [\n {\n \"assignment\": \"<string>\",\n \"blockId\": \"<string>\",\n \"children\": \"<array>\",\n \"collection\": \"<string>\",\n \"condition\": \"<string>\",\n \"content\": \"<string>\",\n \"elifBranches\": [\n {\n \"children\": \"<array>\",\n \"condition\": \"<string>\"\n }\n ],\n \"elseChildren\": \"<array>\",\n \"expression\": \"<string>\",\n \"field\": \"<string>\",\n \"filters\": [\n {\n \"args\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"format\": \"<string>\",\n \"function\": \"<string>\",\n \"inline\": true,\n \"iterator\": \"<string>\",\n \"properties\": {},\n \"tagArgs\": \"<string>\",\n \"tagName\": \"<string>\",\n \"trimWhitespace\": true,\n \"type\": \"<string>\",\n \"variable\": \"<string>\"\n }\n ],\n \"format\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:4005/v1/templates/generate-code")
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 \"blocks\": [\n {\n \"assignment\": \"<string>\",\n \"blockId\": \"<string>\",\n \"children\": \"<array>\",\n \"collection\": \"<string>\",\n \"condition\": \"<string>\",\n \"content\": \"<string>\",\n \"elifBranches\": [\n {\n \"children\": \"<array>\",\n \"condition\": \"<string>\"\n }\n ],\n \"elseChildren\": \"<array>\",\n \"expression\": \"<string>\",\n \"field\": \"<string>\",\n \"filters\": [\n {\n \"args\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"format\": \"<string>\",\n \"function\": \"<string>\",\n \"inline\": true,\n \"iterator\": \"<string>\",\n \"properties\": {},\n \"tagArgs\": \"<string>\",\n \"tagName\": \"<string>\",\n \"trimWhitespace\": true,\n \"type\": \"<string>\",\n \"variable\": \"<string>\"\n }\n ],\n \"format\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"code": "<string>",
"mappedFields": {}
}{
"code": "<string>",
"detail": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
],
"instance": "<string>",
"status": 123,
"title": "<string>",
"type": "about:blank"
}{
"code": "<string>",
"detail": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
],
"instance": "<string>",
"status": 123,
"title": "<string>",
"type": "about:blank"
}{
"code": "<string>",
"detail": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
],
"instance": "<string>",
"status": 123,
"title": "<string>",
"type": "about:blank"
}{
"code": "<string>",
"detail": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
],
"instance": "<string>",
"status": 123,
"title": "<string>",
"type": "about:blank"
}Authorizations
JWT bearer token issued by the identity provider.
Body
application/json
Template blocks and target output format.
Was this page helpful?
⌘I

