Template
Generate video, audio or design file using a templated file.
Request
POSThttps://api.fliki.ai/v1/generate/template
Headers
{
"Content-type": "application/json",
"Authorization": "Bearer API_KEY"
}
Key | Value | Description |
---|---|---|
Content-Type | application/json | Specifies that the request body format is JSON, allowing the server to parse the data correctly. |
Authorization | Bearer YOUR_API_KEY | Generate your API Key in the account/api. section and replace YOUR_API_KEY with your actual key. |
Body
{
"fileId": String,
"webhook": String,
"scenes": [
{
"key": String,
"layers": [
{
"key": String,
"text": String
},
...
]
},
...
]
}
Key | Type | Description |
---|---|---|
fileId | string | The fileId is a unique identifier for the template you created earlier. You can retrieve it from the Templating popup when you first set it as a template. |
webhook | string | The webhook is a public URL from your server that Fliki will call after your content has been generated. It should be a POST method endpoint to receive responses. |
scenes | array | Array of scene objects, each representing a scene in the template. |
→ key | string | Unique key identifier for the scene. |
→ layers | array | Array of layer objects representing the elements within a scene. |
→ → key | string | Unique key identifier for each layer within a scene. |
→ → text | string | Text content for the corresponding layer. |
Response
{
"fileId": String
}
Key | Type | Description |
---|---|---|
fileId | string | Unique identifier of the file created |
Example
- Bash
- TypeScript
- Python
- Go
cURL Request
curl
-H "Authorization: Bearer <API KEY>"
-H "Content-Type: application/json"
-d '{"fileId": "...", "name": "...", "webhook": "https://...", "scenes": [...]}'
-X POST https://api.fliki.ai/v1/generate/template
TypeScript Request
const apiKey = '<API KEY>'; // Replace with your actual API key
const fileId = '...'; // Replace with your actual file ID
const name = '...'; // Replace with your actual name
const webhook = 'https://...'; // Replace with your actual webhook URL
const scenes = [...]; // Replace with your actual scenes array
async function generateTemplate(apiKey: string, fileId: string, name: string, webhook: string, scenes: any[]) {
const url = 'https://api.fliki.ai/v1/generate/template';
const data = {
fileId,
name,
webhook,
scenes,
};
try {
const response = await fetch(url, {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
});
if (!response.ok) {
throw new Error(`Error: ${response.status} - ${response.statusText}`);
}
const result = await response.json();
return result;
} catch (error) {
console.error('Error generating template:', error);
throw error; // Re-throw the error for further handling if needed
}
}
generateTemplate(apiKey, fileId, name, webhook, scenes)
.then(data => console.log(data))
.catch(error => console.error(error));
Python Request
import requests
import json
api_key = "<API KEY>"
file_id = "..." # Replace with your actual file ID
name = "..." # Replace with your actual name
webhook = "https://..." # Replace with your actual webhook URL
scenes = [...] # Replace with your actual scenes list
url = "https://api.fliki.ai/v1/generate/template"
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
data = {
"fileId": file_id,
"name": name,
"webhook": webhook,
"scenes": scenes
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
Go Request
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
apiKey := "<API KEY>"
fileID := "..." // Replace with your actual file ID
name := "..." // Replace with your actual name
webhook := "https://..." // Replace with your actual webhook URL
scenes := []string{"scene1", "scene2"} // Replace with your actual scenes
url := "https://api.fliki.ai/v1/generate/template"
data := map[string]interface{}{
"fileId": fileID,
"name": name,
"webhook": webhook,
"scenes": scenes,
}
jsonData, _ := json.Marshal(data)
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+apiKey)
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
}