Publish a document as a template
curl --request POST \
--url https://api.varg.ai/v2/templates \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"document_id": "7c1d2a0e-5b4f-4f0e-9a52-0d3a1c6b8e11",
"description": "Product teaser with a slow dolly-in",
"tags": [
"product",
"teaser"
]
}
'import requests
url = "https://api.varg.ai/v2/templates"
payload = {
"document_id": "7c1d2a0e-5b4f-4f0e-9a52-0d3a1c6b8e11",
"description": "Product teaser with a slow dolly-in",
"tags": ["product", "teaser"]
}
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({
document_id: '7c1d2a0e-5b4f-4f0e-9a52-0d3a1c6b8e11',
description: 'Product teaser with a slow dolly-in',
tags: ['product', 'teaser']
})
};
fetch('https://api.varg.ai/v2/templates', 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.varg.ai/v2/templates",
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([
'document_id' => '7c1d2a0e-5b4f-4f0e-9a52-0d3a1c6b8e11',
'description' => 'Product teaser with a slow dolly-in',
'tags' => [
'product',
'teaser'
]
]),
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://api.varg.ai/v2/templates"
payload := strings.NewReader("{\n \"document_id\": \"7c1d2a0e-5b4f-4f0e-9a52-0d3a1c6b8e11\",\n \"description\": \"Product teaser with a slow dolly-in\",\n \"tags\": [\n \"product\",\n \"teaser\"\n ]\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://api.varg.ai/v2/templates")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"document_id\": \"7c1d2a0e-5b4f-4f0e-9a52-0d3a1c6b8e11\",\n \"description\": \"Product teaser with a slow dolly-in\",\n \"tags\": [\n \"product\",\n \"teaser\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.varg.ai/v2/templates")
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 \"document_id\": \"7c1d2a0e-5b4f-4f0e-9a52-0d3a1c6b8e11\",\n \"description\": \"Product teaser with a slow dolly-in\",\n \"tags\": [\n \"product\",\n \"teaser\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "pending",
"sourceDocumentId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"createdAt": "2023-11-07T05:31:56Z"
}{
"error": {
"code": "invalid_request",
"message": "Request failed validation"
}
}{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key or JWT"
}
}{
"error": {
"code": "not_found",
"message": "Template not found"
}
}{
"error": {
"code": "conflict",
"message": "A template already exists for this document (status: pending)"
}
}{
"error": {
"code": "no_user_identity",
"message": "This API key is not bound to a user account"
}
}Templates
Publish a document as a template
Copies one of your media documents into a new template and submits it
for moderation. The template is a frozen copy, so later edits to the
document do not change it. Requires a key bound to a user (a personal
API key, or on_behalf_of_user_id).
POST
/
templates
Publish a document as a template
curl --request POST \
--url https://api.varg.ai/v2/templates \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"document_id": "7c1d2a0e-5b4f-4f0e-9a52-0d3a1c6b8e11",
"description": "Product teaser with a slow dolly-in",
"tags": [
"product",
"teaser"
]
}
'import requests
url = "https://api.varg.ai/v2/templates"
payload = {
"document_id": "7c1d2a0e-5b4f-4f0e-9a52-0d3a1c6b8e11",
"description": "Product teaser with a slow dolly-in",
"tags": ["product", "teaser"]
}
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({
document_id: '7c1d2a0e-5b4f-4f0e-9a52-0d3a1c6b8e11',
description: 'Product teaser with a slow dolly-in',
tags: ['product', 'teaser']
})
};
fetch('https://api.varg.ai/v2/templates', 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.varg.ai/v2/templates",
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([
'document_id' => '7c1d2a0e-5b4f-4f0e-9a52-0d3a1c6b8e11',
'description' => 'Product teaser with a slow dolly-in',
'tags' => [
'product',
'teaser'
]
]),
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://api.varg.ai/v2/templates"
payload := strings.NewReader("{\n \"document_id\": \"7c1d2a0e-5b4f-4f0e-9a52-0d3a1c6b8e11\",\n \"description\": \"Product teaser with a slow dolly-in\",\n \"tags\": [\n \"product\",\n \"teaser\"\n ]\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://api.varg.ai/v2/templates")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"document_id\": \"7c1d2a0e-5b4f-4f0e-9a52-0d3a1c6b8e11\",\n \"description\": \"Product teaser with a slow dolly-in\",\n \"tags\": [\n \"product\",\n \"teaser\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.varg.ai/v2/templates")
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 \"document_id\": \"7c1d2a0e-5b4f-4f0e-9a52-0d3a1c6b8e11\",\n \"description\": \"Product teaser with a slow dolly-in\",\n \"tags\": [\n \"product\",\n \"teaser\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "pending",
"sourceDocumentId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"createdAt": "2023-11-07T05:31:56Z"
}{
"error": {
"code": "invalid_request",
"message": "Request failed validation"
}
}{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key or JWT"
}
}{
"error": {
"code": "not_found",
"message": "Template not found"
}
}{
"error": {
"code": "conflict",
"message": "A template already exists for this document (status: pending)"
}
}{
"error": {
"code": "no_user_identity",
"message": "This API key is not bound to a user account"
}
}Authorizations
varg API key (varg_...). Get one at app.varg.ai
or run bunx vargai login. App sessions may alternatively send a
Supabase JWT.
Body
application/json
Was this page helpful?