AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

How Do Web Developers Integrate the Elai.io API and Webhooks to Automate Personalized Video Rendering at Scale?

Annika Bernklau · 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

Scaling video production from manual studio editing to programmatic generation is a critical milestone for modern growth and technical teams. Delivering dynamic, personalized avatar videos—such as customized SaaS onboarding welcomes, milestone achievements, or personalized sales pitch summaries—boosts user engagement dramatically. However, clicking buttons inside a browser-based creative suite fails the moment user sign-ups reach hundreds or thousands per day.

To solve this operational bottleneck, Elai.io provides a robust REST API and webhook infrastructure designed to run headless video pipelines. At 365Finds, our research indicates that building an enterprise-grade automated pipeline on Elai.io requires more than firing simple HTTP POST requests. Because video rendering is computationally heavy, Elai.io adopts an asynchronous, fire-and-forget architecture. Developers must master exact JSON slide composition, implement bulletproof webhook receivers with HMAC signature verification, and build a hybrid reconciliation loop to guard against dropped events and rolling quota constraints.

Here is 365Finds' definitive technical blueprint for integrating the Elai.io API and webhooks into high-throughput production environments.


Architectural Pathways: Template Batching vs. Headless Canvas Assembly

When automating video creation in Elai.io, developers face a foundational architectural choice between two distinct API strategies:

                      ┌───────────────────────────────────────┐
                      │ Dynamic Business Data / User Profiles │
                      └──────────────────┬────────────────────┘
                                         │
                 ┌───────────────────────┴───────────────────────┐
                 │                                               │
                 ▼                                               ▼
      [Approach A: Template Batch]                  [Approach B: Headless Canvas]
   POST /videos/renderTemplate/{id}                       POST /videos
   - Visual layout built in studio               - Programmatic JSON slide composition
   - Dynamic tag substitution ({{name}})         - Dynamic avatar, voice, and canvas math
   - Up to 200 items per request                 - POST /videos/render/{id} trigger
                 │                                               │
                 └───────────────────────┬───────────────────────┘
                                         │
                                         ▼
                      ┌───────────────────────────────────────┐
                      │       Elai.io Render Cluster          │
                      │  (Asynchronous Fire-and-Forget 200)   │
                      └──────────────────┬────────────────────┘
                                         │
                         Webhook Callback│(POST, 10s timeout)
                                         ▼
                      ┌───────────────────────────────────────┐
                      │    Ingestion Gateway / Buffer Queue   │
                      │   - HMAC-SHA256 Raw Body Check        │
                      │   - Immediate 200 OK (< 50ms)         │
                      │   - Push to BullMQ / SQS Worker       │
                      └──────────────────┬────────────────────┘
                                         │
                                         ▼
                      ┌───────────────────────────────────────┐
                      │ Downstream Delivery & Media CDN Sync  │
                      └───────────────────────────────────────┘

1. Approach A: Template Personalization (POST /videos/renderTemplate/{videoId})

2. Approach B: Programmatic Headless Assembly (POST /videos + POST /videos/render/{videoId})

DimensionTemplate Personalization (/renderTemplate)Headless Assembly (/videos)
Primary EndpointPOST /api/v1/videos/renderTemplate/{videoId}POST /api/v1/videos followed by /videos/render/{id}
Batch CapacityUp to 200 rows per request1 video document per request
Layout ControlManaged visually in Elai BuilderProgrammed in JSON via Fabric.js objects
Development ComplexityLow to moderate; JSON tag mappingHigh; requires exact canvas math and schema handling
Maintenance BurdenLow; visual updates require no code changesHigh; slide coordinate changes require code updates

Authentication and Workspace Prerequisites

All calls to the Elai.io API operate under the base URL:

https://apis.elai.io/api/v1

1. Bearer Token Provisioning

Authentication is handled via HTTP Bearer tokens in the Authorization header:

Authorization: Bearer <YOUR_API_TOKEN>
Accept: application/json
Content-Type: application/json

Workspace administrators can generate, rotate, or revoke keys under Settings → API in the Elai.io web application, or programmatically via POST /generateToken. Note that tokens are bound to the workspace administrator and carry full workspace privileges.

2. The Unlimited Plan API Gotcha

365Finds highlights a critical documentation detail: organizations on Elai.io's Unlimited plan cannot access the REST API. API requests made with tokens from an Unlimited workspace are rejected with a bare HTTP 401 Unauthorized without a JSON error body. If a freshly generated admin token consistently returns 401, verify that your workspace is on a Creator, Team, or Enterprise plan before troubleshooting network headers.


Constructing the Multi-Slide Dynamic JSON Payload

When implementing Approach B via POST /api/v1/videos, you must provide a valid slides array and video configuration. Elai.io uses Fabric.js (v4.4.0) under the hood for canvas rendering.

Key Payload Rules

  1. Slide and Canvas Object IDs: Every slide must have a unique numeric integer id. Within canvas.objects, every visual element must also feature an integer id.
  2. Avatar Specification: An avatar must be defined in two complementary places per slide:
    • avatar: A high-level object containing code (formatted as {avatarCode}.{variantCode}, e.g., gia.casual or dylan.casual), gender, and thumbnail canvas URL.
    • canvas.objects: Exactly one object with "type": "avatar", providing spatial coordinates (top, left, scaleX, scaleY, avatarType: "transparent").
  3. Canvas Scaling Math: To position and scale the avatar accurately on a standard 1080p canvas, use Elai's editor conversion formula: $$\text{scaleY} = \frac{360}{1080} \times \text{targetHeightRatio}$$ $$\text{scaleX} = \frac{640}{1080} \times \text{targetWidthRatio}$$
  4. Voice Engine Integration: The voiceProvider parameter accepts azure, google, or elevenlabs. Pair this with a corresponding voice identifier from the platform's voice catalog (such as en-US-AriaNeural).
  5. Speech Duration Constraints: Standard avatars enforce a 60-second limit per slide. Avatars marked with "limit": 300 support extended speech up to 5 minutes per slide. Exceeding these thresholds results in asynchronous render errors.

Complete Production Payload Example

{
  "name": "Personalized Welcome - Customer #10842",
  "tags": ["automated-onboarding", "tier-enterprise"],
  "data": {
    "format": "16_9",
    "resolution": "FullHD",
    "subtitlesEnabled": "burn",
    "musicUrl": "https://elai-media.s3.eu-west-2.amazonaws.com/music/mixkit-driving-ambition-32.mp3",
    "musicVolume": 0.15
  },
  "slides": [
    {
      "id": 1,
      "status": "edited",
      "language": "English",
      "speech": "Welcome aboard, Sarah! We have configured your cloud workspace with enterprise SSO and high-throughput API clusters.",
      "voiceType": "text",
      "voiceProvider": "azure",
      "voice": "en-US-AriaNeural",
      "animation": "fade_in",
      "avatar": {
        "code": "gia.casual",
        "gender": "female",
        "name": "Gia Casual",
        "canvas": "https://elai-avatars.s3.us-east-2.amazonaws.com/common/gia/casual/gia_casual.png"
      },
      "canvas": {
        "version": "4.4.0",
        "background": "#0f172a",
        "objects": [
          {
            "id": 101,
            "type": "avatar",
            "avatarType": "transparent",
            "src": "https://elai-avatars.s3.us-east-2.amazonaws.com/common/gia/casual/gia_casual.png",
            "left": 120.0,
            "top": 40.0,
            "scaleX": 0.32,
            "scaleY": 0.32,
            "width": 1080,
            "height": 1080,
            "animation": { "type": null, "exitType": null }
          },
          {
            "id": 102,
            "type": "textbox",
            "text": "Welcome Sarah | Acme Corp",
            "fontSize": 24,
            "fontFamily": "Inter",
            "fill": "#38bdf8",
            "left": 400.0,
            "top": 120.0,
            "width": 500
          }
        ]
      }
    }
  ]
}

Once posted to POST /api/v1/videos, Elai returns the draft video object with an assigned _id. To initiate compilation, execute:

curl -X POST "https://apis.elai.io/api/v1/videos/render/420c6769343dc7bb51513e63" \
  -H "Authorization: Bearer <API_TOKEN>" \
  -H "Accept: application/json"

Configuring Webhooks and Cryptographic Verification

Because video compilation takes between 45 seconds and several minutes depending on duration, synchronous polling degrades server performance and exhausts network sockets. Webhooks provide real-time notification when rendering finishes or fails.

1. Subscription Protocol & The Secret Order Trap

You can register your webhook listener programmatically:

curl -X POST "https://apis.elai.io/api/v1/webhook/" \
  -H "Authorization: Bearer <API_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://api.yourdomain.com/v1/webhooks/elai",
    "techEmail": "devops-alerts@yourdomain.com",
    "enabled": true
  }'

[!CAUTION] The Secret Order Trap: Elai.io only stores a signing secret if an active webhook is already enabled. If you call POST /api/v1/webhook/secret before POST /api/v1/webhook/, or while the webhook is disabled, the secret is silently dropped. The endpoint still returns HTTP 200, but outgoing deliveries will arrive completely unsigned. Always subscribe first, set the secret second, and verify the configuration with GET /apiConfig.

Set the signing secret immediately after subscription:

curl -X POST "https://apis.elai.io/api/v1/webhook/secret" \
  -H "Authorization: Bearer <API_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{ "secret": "your-cryptographically-secure-random-secret" }'

2. Event Types and Webhook Payload

Elai.io emits exactly two webhook events:

{
  "event": "video_ready",
  "error": null,
  "requestId": "FKdFTb5MciFRG1QD",
  "batchRowId": 0,
  "video": {
    "_id": "627e1c5ef461482766f35f4a",
    "name": "Personalized Welcome - Customer #10842",
    "status": "ready",
    "duration": 14.8,
    "thumbnail": "https://elai-media.s3.eu-west-2.amazonaws.com/videos/.../thumbnail.jpg",
    "url": "https://elai-media.s3.eu-west-2.amazonaws.com/videos/.../video.mp4",
    "createdAt": "2026-11-05T06:00:00.000Z",
    "updatedAt": "2026-11-05T06:02:15.000Z"
  }
}

3. The Single-Attempt Zero-Retry Rule

This is the most critical operational constraint in Elai.io's developer documentation:

Production Webhook Implementation (Node.js & Express)

To prevent lost events and timing attacks, the receiver must capture raw request bytes, verify HMAC-SHA256 signatures in constant time, enforce timestamp freshness, and acknowledge with HTTP 200 immediately before dispatching tasks to an internal message queue.

import crypto from 'node:crypto';
import express from 'express';

const app = express();
const WEBHOOK_SECRET = process.env.ELAI_WEBHOOK_SECRET;
const MAX_DRIFT_MS = 5 * 60 * 1000; // 5-minute replay tolerance

// Capture exact raw bytes prior to JSON parsing
app.use(
  express.json({
    verify: (req, _res, buf) => {
      req.rawBody = buf.toString('utf8');
    },
  })
);

function verifyElaiSignature(req) {
  const timestamp = req.headers['elai-timestamp'];
  const signature = req.headers['elai-signature'];

  if (!timestamp || !signature || !req.rawBody) return false;

  // Protect against replay attacks
  const eventTime = parseInt(timestamp, 10);
  if (Math.abs(Date.now() - eventTime) > MAX_DRIFT_MS) return false;

  const expectedSignature = crypto
    .createHmac('sha256', WEBHOOK_SECRET)
    .update(`${timestamp}.${req.rawBody}`)
    .digest('hex');

  // Constant-time comparison prevents timing analysis
  if (signature.length !== expectedSignature.length) return false;
  return crypto.timingSafeEqual(
    Buffer.from(signature, 'hex'),
    Buffer.from(expectedSignature, 'hex')
  );
}

app.post('/api/v1/webhooks/elai', async (req, res) => {
  if (!verifyElaiSignature(req)) {
    return res.status(401).json({ error: 'Invalid HMAC signature or expired timestamp' });
  }

  // Acknowledge within 50ms to satisfy the strict 10s single-attempt window
  res.status(200).json({ received: true });

  const { event, error, video, requestId, batchRowId } = req.body;

  try {
    if (event === 'video_ready') {
      // Offload to worker queue (BullMQ, Celery, or AWS SQS)
      await messageQueue.add('process_video_ready', {
        videoId: video._id,
        downloadUrl: video.url,
        duration: video.duration,
        requestId,
        batchRowId,
      });
    } else if (event === 'video_error') {
      await messageQueue.add('process_video_error', {
        videoId: video?._id,
        errorMessage: error,
        requestId,
      });
    }
  } catch (queueErr) {
    console.error('Failed to enqueue webhook task:', queueErr);
  }
});

Quotas, Rate Limits, and High-Throughput Engineering

When generating thousands of personalized videos, enterprise systems encounter two distinct types of HTTP 429 errors. Handling them identically will cause pipeline stalls.

1. Differentiating the Two Flavors of HTTP 429

Plan TierRolling 8-Hour Video Creation LimitUpload Media CapMax Slides per Video
Free50 videos200 assets3 slides rendered
Creator1,000 videos1,000 assets100 slides
Team1,000 videos1,000 assets100 slides
Enterprise6,000 videos1,000 assets100 slides

2. The Hybrid Reconciliation Strategy

Because Elai.io webhooks do not retry dropped packets, resilient production architectures must not rely on callbacks alone. 365Finds strongly advises implementing a Hybrid Push-Pull Reconciler:

  1. Primary Push Path: Webhooks process 99% of completed videos instantly.
  2. Safety Net Polling Cron: A scheduled cron worker queries GET /api/v1/videos?status=rendering every 5 to 10 minutes. Any video that has been in rendering status for longer than 20 minutes is actively checked via GET /api/v1/videos/{videoId}. If the video is marked ready or error, the system triggers the downstream worker and resolves the internal database record.

365Finds Institutional Verdict & Recommendations

Automating personalized video rendering via Elai.io provides substantial efficiency gains over manual studio production, but developer teams must architect around the platform's distributed constraints:

  1. Default to Template Personalization: Unless your application requires entirely unpredictable multi-scene canvas logic, use POST /videos/renderTemplate/{videoId}. Passing arrays of up to 200 recipients per batch drastically reduces API overhead and insulates backend code from layout redesigns.
  2. Never Execute Business Logic in Webhook Handlers: Respond with HTTP 200 inside 50ms and push payloads to a background worker queue. A slow database query or synchronous S3 download inside the webhook handler will trigger a 10-second timeout, risking lost events and automatic webhook shutdown.
  3. Always Subscribe Before Setting Secrets: Remember the webhook secret ordering trap. Test your webhook pipeline by verifying that incoming requests include both Elai-Timestamp and Elai-Signature headers.
  4. Deploy the Push-Pull Safety Net: Due to Elai's single-attempt webhook delivery model, pairing your webhook listener with a lightweight polling cron is mandatory for zero-loss enterprise workflows.

References