AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

Integrating the Fliki REST API: Automated Video Generation, Asynchronous Task Polling, and Brand Kit Enforcement

小森夏平 · 365Finds Editorial
Indexed 88,650 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

Manual video production breaks the moment marketing demands hundreds of localized, personalized creative variants a week. Web dashboards with drag-and-drop editors are intuitive for human creators, but asking an operations team to manually paste scripts, select aspect ratios, and hit "Export" 400 times a day is an operational dead end. At 365Finds, we evaluate AI automation tools not by the glossiness of their web interfaces, but by whether their developer infrastructure can withstand headless, high-throughput batch generation without human babysitting.

Fliki provides an official REST API (v1) specifically built to trigger video rendering programmatically. However, developers treating Fliki like a standard synchronous REST endpoint—firing an HTTP POST and waiting for a binary MP4 in the response—will quickly crash their infrastructure with 504 Gateway Timeout errors. Rendering high-definition AI media takes anywhere from 45 seconds to several minutes.

To build a production-grade automated pipeline, engineering teams must decouple trigger ingestion from rendering through asynchronous polling, enforce visual governance programmatically via Brand Kits, and safely persist ephemeral output files into enterprise object storage like AWS S3. Here is the architectural guide to integrating Fliki's REST API correctly.


1. Authentication and Endpoint Architecture

Fliki exposes its programmatic video creation suite under https://api.fliki.ai/v1. Access requires an API key generated from the account's Automation dashboard.

Commercial reality check: at 365Finds, we emphasize that API access is not available on Fliki's Free or Standard plans. Your workspace must be on the Premium tier (which includes API access and up to 1080p rendering) or an Enterprise contract. Attempting to authenticate with an API token from an unsupported tier will return 401 Unauthorized or 403 Forbidden.

Every outbound request must include standard JSON headers and Bearer authentication:

POST /v1/generate/video HTTP/1.1
Host: api.fliki.ai
Content-Type: application/json
Authorization: Bearer YOUR_FLIKI_API_KEY

Security hygiene matters here. Never embed this Bearer token in frontend clients, public repositories, or client-side marketing automation scripts. Fliki API calls must be proxied through your backend microservice or a serverless worker where credentials reside in an encrypted secret manager (such as AWS Secrets Manager or HashiCorp Vault).


2. Payload Anatomy: Workflows, Visual Layers, and Brand Governance

The core generation endpoint is POST https://api.fliki.ai/v1/generate/video. The request body requires an optional project file folder name and an array of generation objects inside payload.

Understanding workflowType

Fliki supports three distinct generation modes:

  1. script: You supply the exact voiceover text line-by-line via the content property. Fliki splits sentences into discrete scenes, assigns background media, and generates synchronized speech.
  2. idea: You provide a conceptual prompt via the prompt property (e.g., "3 practical tips to optimize AWS Lambda cold starts"). Fliki's backend LLM synthesizes the script, generates narration, and maps visual media.
  3. url: You provide an article or blog URL in content. Fliki parses the webpage HTML, summarizes the narrative into scene segments, and builds a video recap.

For dynamic e-commerce marketing, catalog retargeting, and programmatic UGC, script is almost always the institutional choice. It gives engineering full determinism over brand messaging without relying on LLM prompt unpredictability.

Programmatic Brand Kit Enforcement (brandId)

One of the most frequent mistakes engineering teams make when automating Fliki is omitting the brandId. Without an explicit brand kit reference, Fliki applies default system typography, random text box positions, and no watermark. Over hundreds of automated runs, this results in discordant video layouts.

Inside your Fliki web workspace, configure your official Brand Kit: upload your PNG logo mark (setting exact corner coordinates and opacity), specify brand hex colors (primary subtitle highlights, secondary background cards), and assign approved corporate typography. Once saved, extract the 24-character hexadecimal brandId (or retrieve it via GET https://api.fliki.ai/v1/brands).

Passing brandId in every API payload forces Fliki's render engine to lock logo placement, caption styles, subtitle animation pacing, and branded intro/outro clips across every dynamically generated video.

Production-Ready JSON Payload

Here is a hardened payload structure for an automated 9:16 vertical video (TikTok / Instagram Reels / YouTube Shorts):

{
  "file": "Automated_Campaign_2026_Q4",
  "payload": [
    {
      "workflowType": "script",
      "workflowFormat": "video",
      "content": "Discover how automated inventory syncing cuts fulfillment lag by forty percent. Step one: connect your warehouse webhook. Step two: let our cloud worker reconcile stock in real time. Experience frictionless logistics today.",
      "voiceId": "644917a80b91e1d03375b47a",
      "aspectRatio": "9:16",
      "resolution": "1080p",
      "visuals": "stock",
      "brandId": "651234abcd5678ef90123456",
      "highlightSubtitles": true,
      "generateSfx": false,
      "addPauses": true
    }
  ]
}

Initial Response: Grabbing the fileId

Unlike traditional data APIs, Fliki does not block the HTTP socket until the video file is assembled. Instead, it queues the render job and returns an immediate acknowledgment:

{
  "status": "success",
  "data": {
    "filesCreated": [
      {
        "id": "673f1a2b89c0de3456789abc",
        "name": "Automated_Campaign_2026_Q4",
        "status": "processing"
      }
    ]
  }
}

Your service must extract the target identifier (id or fileId) and commit it immediately to your internal database or message queue alongside metadata like campaign ID, target SKU, and timestamp.


3. Asynchronous Orchestration: Polling via Exponential Backoff

Because video generation involves AI voice synthesis, stock media transcode, canvas compositing, and H.264 video encoding, rendering can take from 30 seconds for a short clip up to 5 minutes for longer formats.

Holding an HTTP connection open against Fliki for 180 seconds will trigger timeout limits on Cloudflare, AWS API Gateway (29-second hard limit), or Nginx reverse proxies. The only stable architecture is a decoupled background worker pattern.

The Polling Endpoint

Fliki provides an inspection endpoint:

GET https://api.fliki.ai/v1/generate/status?fileId=673f1a2b89c0de3456789abc HTTP/1.1
Host: api.fliki.ai
Authorization: Bearer YOUR_FLIKI_API_KEY

Possible status values returned:

Polling Algorithm: Backoff with Jitter

Hammering GET /v1/generate/status every 500 milliseconds is poor engineering that risks HTTP 429 rate-limiting. Instead, implement exponential backoff with full jitter:

  1. Initial Silence Window: Render jobs rarely complete under 15 seconds. Sleep for 15 seconds before the first status inquiry.
  2. Interval Scaling: Set an initial poll interval of 8 seconds, scaling with a multiplier of 1.4 up to a ceiling of 30 seconds.
  3. Randomized Jitter: Add $\pm 2$ seconds of pseudo-random noise to prevent synchronized burst polling across parallel worker threads.
  4. Hard Timeout: If the status does not reach "completed" within 12 minutes (720 seconds), mark the job as timed out internally and log an alert for operational inspection.

Here is a clean Python implementation showing the polling orchestration:

import time
import random
import requests

FLIKI_API_BASE = "https://api.fliki.ai/v1"

def poll_fliki_render(file_id: str, api_key: str, max_timeout: int = 720) -> str:
    headers = {
        "Authorization": f"Bearer {api_key}",
        "Content-Type": "application/json"
    }
    url = f"{FLIKI_API_BASE}/generate/status"
    params = {"fileId": file_id}
    
    start_time = time.time()
    current_interval = 10.0
    max_interval = 30.0
    backoff_factor = 1.3
    
    # Initial sleep period to allow rendering engine startup
    time.sleep(15)

    while (time.time() - start_time) < max_timeout:
        resp = requests.get(url, headers=headers, params=params, timeout=15)
        
        if resp.status_code == 429:
            # Respect rate limit warnings with temporary cooldown
            time.sleep(20)
            continue
            
        resp.raise_for_status()
        data = resp.json()
        
        status = data.get("status") or data.get("data", {}).get("status")
        
        if status == "completed":
            download_url = data.get("downloadUrl") or data.get("data", {}).get("downloadUrl")
            if not download_url:
                raise ValueError("Completed response missing downloadUrl payload.")
            return download_url
            
        elif status == "failed":
            error_msg = data.get("error", "Unknown Fliki rendering error")
            raise RuntimeError(f"Fliki generation failed for file {file_id}: {error_msg}")
            
        # Add jitter to backoff interval
        jitter = random.uniform(-1.5, 1.5)
        sleep_time = min(max_interval, current_interval) + jitter
        time.sleep(max(3.0, sleep_time))
        current_interval *= backoff_factor

    raise TimeoutError(f"Fliki render job {file_id} exceeded maximum timeout of {max_timeout}s")

4. Asset Ingestion, AWS S3 Persistence, and Distribution

A critical vulnerability in many naive pipelines is storing Fliki's downloadUrl directly into production databases as the permanent video URL.

Fliki's rendered output links point to ephemeral cloud storage buckets. These URLs can expire, and workspace retention policies or billing cycle resets may purge older assets. For an enterprise backend, Fliki's downloadUrl must be treated as a temporary transfer buffer, not a persistent content delivery network (CDN).

Streaming to AWS S3 without Local Disk Bloat

When running workers inside ephemeral containers (e.g., AWS ECS Fargate or Kubernetes pods), avoid writing 200MB video binaries to the container disk. Instead, stream the response body directly to S3 using multi-part or streaming upload:

import requests
import boto3
from urllib.parse import urlparse

s3_client = boto3.client("s3")

def persist_video_to_s3(download_url: str, bucket_name: str, s3_key: str) -> str:
    # Stream download from Fliki CDN directly to S3 bucket
    with requests.get(download_url, stream=True, timeout=60) as stream_resp:
        stream_resp.raise_for_status()
        
        s3_client.upload_fileobj(
            Fileobj=stream_resp.raw,
            Bucket=bucket_name,
            Key=s3_key,
            ExtraArgs={
                "ContentType": "video/mp4",
                "CacheControl": "public, max-age=31536000, immutable"
            }
        )
        
    return f"https://{bucket_name}.s3.amazonaws.com/{s3_key}"

Once the asset lives safely inside your S3 bucket fronted by Amazon CloudFront (or Cloudflare R2), your downstream message broker can emit a VIDEO_READY event. Dedicated publishers then grab the S3 object URL and trigger external platform APIs:

flowchart LR
    A["Marketing Trigger / CRM"] --> B["Backend Ingestion Service"]
    B -->|"POST /v1/generate/video"| C["Fliki API Engine"]
    C -->|"200 OK (fileId)"| B
    B -->|"Enqueue Task"| D["Asynchronous Worker"]
    D -->|"GET /v1/generate/status"| C
    C -->|"status: completed + downloadUrl"| D
    D -->|"Stream MP4"| E["Enterprise AWS S3"]
    E -->|"CloudFront CDN"| F["Multi-Channel Distribution<br/>(Meta / TikTok / YouTube)"]

5. Failure Modes, Rate Limits, and Credit Management

Running high-volume programmatic video generation requires rigorous error handling:

ScenarioSymptom / CodeInstitutional Remedy
Plan Gatekeeping401 Unauthorized / 403 ForbiddenVerify account tier. Fliki requires an active Premium or Enterprise plan for API key usage.
Credit DepletionStatus "failed" with quota errorFliki deducts minutes based on render length and voice tier. Configure account-level credit alerting at 20% remaining threshold.
Rate Limiting429 Too Many RequestsFliki throttles aggressive polling. Ensure polling workers maintain minimum 8–10s intervals per file.
Invalid Brand Kit ID400 Bad RequestValidate that the brandId exists in the exact workspace owning the API key; brand kits do not cross workspace boundaries.
Voice IncompatibilityGeneration fails during TTSConfirm voiceId belongs to supported locales. Ultra-realistic voices consume standard credits differently than base voices.

Institutional Verdict: When Fliki API Makes Sense

Fliki's REST API is one of the fastest routes to market for companies wanting to turn catalog feeds, dynamic copy, and localized scripts into polished video assets without maintaining their own GPU rendering clusters or FFmpeg canvas pipelines.

However, at 365Finds, our stance is pragmatic: Fliki's API shines when you need turn-key packaging of TTS voiceover, synchronized subtitles, and automated stock visuals under strict brand kits. If your engineering objective requires pixel-level timeline keyframing, multi-track audio ducking, or raw canvas manipulation, you will outgrow Fliki's declarative payload and require a lower-level composition engine like Remotion or AWS Elemental MediaConvert.

For high-volume marketing automation, dynamic e-commerce catalog promotion, and localized social video engines, pairing Fliki's POST /v1/generate/video with decoupled SQS/Celery workers and persistent AWS S3 streaming creates a reliable, fully autonomous creative factory.


References