Create Content from Template
curl --request POST \
--url https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/content/from-template \
--header 'Content-Type: application/json' \
--data '
{
"templateId": "<string>",
"name": "<string>",
"content": {},
"tags": [
"<string>"
]
}
'import requests
url = "https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/content/from-template"
payload = {
"templateId": "<string>",
"name": "<string>",
"content": {},
"tags": ["<string>"]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({templateId: '<string>', name: '<string>', content: {}, tags: ['<string>']})
};
fetch('https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/content/from-template', 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://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/content/from-template",
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([
'templateId' => '<string>',
'name' => '<string>',
'content' => [
],
'tags' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"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://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/content/from-template"
payload := strings.NewReader("{\n \"templateId\": \"<string>\",\n \"name\": \"<string>\",\n \"content\": {},\n \"tags\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
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://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/content/from-template")
.header("Content-Type", "application/json")
.body("{\n \"templateId\": \"<string>\",\n \"name\": \"<string>\",\n \"content\": {},\n \"tags\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/content/from-template")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"templateId\": \"<string>\",\n \"name\": \"<string>\",\n \"content\": {},\n \"tags\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_bodyContent
Create Content from Template
Create new content based on an existing template
POST
/
app
/
v1
/
organizations
/
{organizationId}
/
projects
/
{projectId}
/
content
/
from-template
Create Content from Template
curl --request POST \
--url https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/content/from-template \
--header 'Content-Type: application/json' \
--data '
{
"templateId": "<string>",
"name": "<string>",
"content": {},
"tags": [
"<string>"
]
}
'import requests
url = "https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/content/from-template"
payload = {
"templateId": "<string>",
"name": "<string>",
"content": {},
"tags": ["<string>"]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({templateId: '<string>', name: '<string>', content: {}, tags: ['<string>']})
};
fetch('https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/content/from-template', 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://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/content/from-template",
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([
'templateId' => '<string>',
'name' => '<string>',
'content' => [
],
'tags' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"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://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/content/from-template"
payload := strings.NewReader("{\n \"templateId\": \"<string>\",\n \"name\": \"<string>\",\n \"content\": {},\n \"tags\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
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://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/content/from-template")
.header("Content-Type", "application/json")
.body("{\n \"templateId\": \"<string>\",\n \"name\": \"<string>\",\n \"content\": {},\n \"tags\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/content/from-template")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"templateId\": \"<string>\",\n \"name\": \"<string>\",\n \"content\": {},\n \"tags\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_bodyCreates a new content item using an existing template as a starting point. The new content inherits the template’s structure, ContentType, and package version.
Path Parameters
string
required
Organization ID
string
required
Project ID
Request Body
string
required
ID of the template content to use
string
required
Display name for the new content
object
Content data that overrides template values. Merged with template content.
string[]
Tags for the new content (replaces template tags if provided)
Example Request
{
"templateId": "cont123",
"name": "My New Article",
"content": {
"title": "Custom Title",
"subtitle": "My custom subtitle",
"author": "John Smith",
"components": [
{
"type": "ArticleParagraph",
"text": "This is my custom opening paragraph..."
}
]
}
}
Response
Returns the created Content object.{
"data": {
"id": "cont126",
"typeId": "ct123",
"version": null,
"lastPublishedVersion": null,
"packageVersion": "1.0.0",
"name": "My New Article",
"description": "Custom Article. A personalized article based on the template.",
"status": "draft",
"isTemplate": false,
"content": {
"title": "Custom Title",
"subtitle": "My custom subtitle",
"heroImage": "asset123",
"author": "John Smith",
"publishDate": "2024-03-21",
"components": [
{
"type": "ArticleParagraph",
"text": "This is my custom opening paragraph..."
}
]
},
"compiled": "const body = () => { ... }",
"tags": ["Template", "Article"],
"metadata": {
"createdBy": "user123",
"locale": "en-US"
},
"createdAt": "2024-03-22T10:00:00Z",
"updatedAt": "2024-03-22T10:00:00Z"
}
}
Content created from a template inherits the template’s
typeId and packageVersion. The provided content object is merged with the template’s content, allowing you to override specific fields.Error Responses
Template Not Found
{
"error": {
"code": "TEMPLATE_NOT_FOUND",
"message": "Template content not found",
"details": {
"templateId": "cont123"
}
}
}
Not a Template
{
"error": {
"code": "INVALID_TEMPLATE",
"message": "Content with ID cont123 is not a template"
}
}
Validation Failed
{
"error": {
"code": "CONTENT_VALIDATION_FAILED",
"message": "Content does not match the ContentType schema"
}
}
Code Examples
curl -X POST "https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/content/from-template" \
-H "Authorization: Bearer YOUR_JWT" \
-H "Content-Type: application/json" \
-d '{
"templateId": "cont123",
"name": "My New Article",
"content": {
"title": "Custom Title",
"author": "John Smith"
}
}'
const response = await fetch(
'https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/content/from-template',
{
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_JWT',
'Content-Type': 'application/json'
},
body: JSON.stringify({
templateId: 'cont123',
name: 'My New Article',
content: {
title: 'Custom Title',
author: 'John Smith'
}
})
}
);
const { data: content } = await response.json();
console.log(`Created content from template: ${content.id}`);