Publish Content
curl --request POST \
--url https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/content/{id}/publishimport requests
url = "https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/content/{id}/publish"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/content/{id}/publish', 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/{id}/publish",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/content/{id}/publish"
req, _ := http.NewRequest("POST", url, nil)
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/{id}/publish")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/content/{id}/publish")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyContent
Publish Content
Publish content, creating a new version
POST
/
app
/
v1
/
organizations
/
{organizationId}
/
projects
/
{projectId}
/
content
/
{id}
/
publish
Publish Content
curl --request POST \
--url https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/content/{id}/publishimport requests
url = "https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/content/{id}/publish"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/content/{id}/publish', 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/{id}/publish",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/content/{id}/publish"
req, _ := http.NewRequest("POST", url, nil)
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/{id}/publish")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/content/{id}/publish")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyPublishing content creates a new immutable version that becomes the active version for end users. The compiled BindJS code is locked at this version.
Path Parameters
string
required
Organization ID
string
required
Project ID
string
required
Content ID
Response
Returns the published Content object with the new version number.{
"data": {
"id": "cont123",
"typeId": "ct123",
"version": 3,
"lastPublishedVersion": 3,
"packageVersion": "1.0.0",
"name": "Getting Started Guide",
"status": "published",
"isTemplate": false,
"content": { ... },
"compiled": "const body = () => { ... }",
"tags": ["Tutorial"],
"metadata": {
"createdBy": "user123",
"publishedAt": "2024-03-21T10:00:00Z",
"publishedBy": "user123",
"locale": "en-US"
},
"createdAt": "2024-03-20T10:00:00Z",
"updatedAt": "2024-03-21T10:00:00Z"
}
}
Status Transitions
| Current Status | After Publish |
|---|---|
draft | published (version 1) |
modified | published (version incremented) |
Only
draft or modified content can be published, and its ContentType must be published.Error Responses
Invalid Status
{
"error": {
"code": "INVALID_CONTENT_STATUS",
"message": "Only draft or modified content can be published. Current status: deleted"
}
}
Validation Failed
{
"error": {
"code": "CONTENT_VALIDATION_FAILED",
"message": "Content does not match the ContentType schema. Fix the row via PUT /content/:id (which validates the same way) and retry publish."
}
}
Code Examples
curl -X POST "https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/content/cont123/publish" \
-H "Authorization: Bearer YOUR_JWT"
const response = await fetch(
'https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/content/cont123/publish',
{
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_JWT'
}
}
);
const { data: content } = await response.json();
console.log(`Published version ${content.version}`);