HappyWan
Developer API PlaybookIntermediate·12 min read
Verified 2026-12-02

HappyWan API Quickstart: Forward-Compatible REST Schema & Webhooks

Production developer quickstart for the HappyWan REST API: copy-ready curl and TypeScript workers on POST /api/jobs that ship live on Wan 3.0 today, flip to happywan-1.0 in one config line at December launch, dispatch signed webhooks, and guarantee 100% auto-refunds.

HappyWan API Quickstart: Forward-Compatible REST Schema & Webhooks
Plate 01 · Developer API Playbook · IntermediateVerified 2026-12-02

Before You Start · Practitioner Brief

3 Checks
  1. 01Generate a scoped Bearer token (hwk_live_*) inside Studio -> API Keys (/studio/api-keys) and fund your balance with any non-expiring PAYG pack from $19 or subscription.
  2. 02Live production status (2026-12-02): wan-3.0, wan-3.0-pro, and happyhorse-1.1 execute live on POST https://happywanvideo.ai/api/jobs. Submitting engine: "happywan-1.0" prior to December 2026 GA returns an HTTP 400 pre-launch notice and deducts 0 credits.
  3. 03Always send a unique Idempotency-Key header per logical render so network retries never double-charge your credit balance.

Section 01

One Normalized REST Contract Across Live Wan 3.0, HappyHorse 1.1 & Day-1 HappyWan

Engineering teams integrating the HappyWan API across agencies, creative SaaS apps, and automated localization pipelines run into the same integration tax on raw multi-model gateways: every generation renames fields (duration vs. duration_seconds, ratio vs. aspect_ratio, image_url vs. reference_images) and breaks TypeScript types on launch day.

The HappyWan REST API eliminates that churn by pinning all four Alibaba video engines—live wan-3.0, live wan-3.0-pro, live happyhorse-1.1, and pre-launch December 2026 happywan-1.0—behind a single normalized endpoint: POST https://happywanvideo.ai/api/jobs and GET https://happywanvideo.ai/api/jobs/{id}. Build, load-test, and ship paid customer traffic against wan-3.0 or happyhorse-1.1 this afternoon; when December GA opens, flipping one environment variable (VIDEO_ENGINE=happywan-1.0) unlocks 45-second runtimes and 50-reference arrays with zero payload rewrites.

HappyWan API Pricing, Engine Limits & Live Availability (Verified 2026-12-02)

Engine SlugStatusDurationModes & ReferencesCredits / SecEffective Cost / 10s (Annual $0.0142–$0.0148 · PAYG $0.0169–$0.0190)
wan-3.0Live Today2–30sAll 5 modes (incl. video-edit) · 10 img + 5 vid + 5 audio480p: 5 · 720p: 10 · 1080p: 20480p: $0.71–$0.95 · 720p: $1.42–$1.90 · 1080p: $2.85–$3.80
wan-3.0-proLive Today2–30s4 modes (no video-edit) · 10 img + 5 vid + 5 audio1080p: 16 · 2K: 18 · 4K: 211080p: $2.28–$3.04 · 2K: $2.56–$3.42 · 4K: $2.99–$3.99
happyhorse-1.1Live Today3–15sT2V / I2V / R2V · 9 referenceImages · 7 languages720p: 16 · 1080p: 20720p: $2.28–$3.04 · 1080p: $2.85–$3.80
happywan-1.0Pre-Launch (Dec 2026 Target)2–45s (target)All 5 modes · Up to 50 multimodal refs · 7 languages (target)Est. 720p: 14 · 1080p: 20 · 2K: 24Est. 720p: $1.99–$2.66 · 1080p: $2.85–$3.80 · 2K: $3.42–$4.56

Section 02

Working `curl` Quickstart: Live Wan 3.0 Today -> 1-Line HappyWan 1.0 Switch

Test your API key in sixty seconds with standard curl. Notice two production details verified against the live route handler: POST /api/jobs returns HTTP 201 Created with job.id, job.status, job.credits_charged, and your updated creditsBalance, while polling GET /api/jobs/{id} reconciles upstream completion and returns job.output_url once job.status === "completed" (or job.status === "refunded" with 100% credit reversal if upstream faults).

curl — Submit Live Wan 3.0 480p Draft (25 Credits = 5s) & Poll Statusbash
export HAPPYWAN_API_KEY="hwk_live_replace_with_your_token"
# Live today: "wan-3.0" | "wan-3.0-pro" | "happyhorse-1.1"
# Launch day (Dec 2026): flip this single env var to "happywan-1.0"
export VIDEO_ENGINE="wan-3.0"

# 1. Create an idempotent 10-second 480p test render (10s x 5 cr/s = 50 credits)
RESPONSE=$(curl -sS -w "\n%{http_code}" -X POST "https://happywanvideo.ai/api/jobs" \
  -H "Authorization: Bearer ${HAPPYWAN_API_KEY}" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: campaign-402-shot-01-v1" \
  -d "{
    \"engine\": \"${VIDEO_ENGINE}\",
    \"mode\": \"text-to-video\",
    \"duration\": 10,
    \"resolution\": \"480p\",
    \"aspectRatio\": \"16:9\",
    \"generateAudio\": true,
    \"enablePromptExpansion\": false,
    \"seed\": 88214,
    \"prompt\": \"Steady 35mm dolly push along a sunlit Milan espresso bar. 0-5s: Barista sets a steaming porcelain cup beside a silver spoon on travertine stone. 5-10s: Camera settles calmly onto the hero cup as faint steam curls upward. Crisp porcelain clink, quiet morning cafe tone, no background music.\"
  }")

HTTP_CODE=$(echo "${RESPONSE}" | tail -n1)
BODY=$(echo "${RESPONSE}" | sed '$d')
echo "HTTP ${HTTP_CODE}: ${BODY}"

# Extract job.id and poll GET /api/jobs/{id} until completed or refunded
JOB_ID=$(echo "${BODY}" | node -e "const d = JSON.parse(require('fs').readFileSync(0,'utf8')); console.log(d.job?.id || '');")
curl -sS "https://happywanvideo.ai/api/jobs/${JOB_ID}" \
  -H "Authorization: Bearer ${HAPPYWAN_API_KEY}"

Tip: For 1080p production jobs that do not need video-edit, set VIDEO_ENGINE="wan-3.0-pro" (16 cr/s)—20% cheaper than standard wan-3.0 1080p (20 cr/s).

Section 03

TypeScript Production Worker: 1-Line Cutover, Exponential Backoff & Downstream Webhooks

In real multi-tenant web apps, browser requests should never block waiting 45–120 seconds for video diffusion. The clean production pattern pairs HappyWan's async POST /api/jobs + GET /api/jobs/{id} polling inside a lightweight background worker (Queue, Temporal, Trigger.dev, or BullMQ) that emits an HMAC-SHA256 signed webhook event to your application backend the instant status transitions to completed or refunded.

Drop this zero-dependency TypeScript worker into Node 20+ or Bun. Notice the pre-flight per-job credit guard—critical before December 2026 because a single 45-second 1080p HappyWan 1.0 render (est. 900 credits) carries 4.5× the credit exposure of a 10-second render:

typescript — Forward-Compatible HappyWan API Worker + Signed Webhook Emittertypescript
import crypto from "node:crypto";

type EngineId = "wan-3.0" | "wan-3.0-pro" | "happyhorse-1.1" | "happywan-1.0";

interface JobRow {
  id: string;
  engine: EngineId;
  mode: string;
  status: "queued" | "processing" | "completed" | "failed" | "refunded";
  credits_charged: number;
  output_url: string | null;
  error_message: string | null;
}

const API_BASE = "https://happywanvideo.ai";
const API_KEY = process.env.HAPPYWAN_API_KEY!;
// Flip ONLY this env var from "wan-3.0" to "happywan-1.0" when Dec 2026 GA opens:
const ACTIVE_ENGINE = (process.env.VIDEO_ENGINE || "wan-3.0") as EngineId;
const MAX_CREDITS_PER_JOB = Number(process.env.MAX_CREDITS_PER_JOB || 650);

export async function renderAndNotify(input: {
  shotId: string;
  prompt: string;
  duration: number;
  resolution: "480p" | "720p" | "1080p" | "2k" | "4k";
  webhookUrl?: string;
  webhookSecret?: string;
}) {
  const rateTable: Record<EngineId, Partial<Record<string, number>>> = {
    "wan-3.0": { "480p": 5, "720p": 10, "1080p": 20 },
    "wan-3.0-pro": { "1080p": 16, "2k": 18, "4k": 21 },
    "happyhorse-1.1": { "720p": 15, "1080p": 20 },
    "happywan-1.0": { "720p": 14, "1080p": 20, "2k": 24 },
  };
  const estCredits = (rateTable[ACTIVE_ENGINE][input.resolution] ?? 20) * input.duration;
  if (estCredits > MAX_CREDITS_PER_JOB) {
    throw new Error(`Guard blocked job: ${estCredits} cr exceeds MAX_CREDITS_PER_JOB=${MAX_CREDITS_PER_JOB}`);
  }

  const createRes = await fetch(`${API_BASE}/api/jobs`, {
    method: "POST",
    headers: {
      Authorization: `Bearer ${API_KEY}`,
      "Content-Type": "application/json",
      "Idempotency-Key": `shot-${input.shotId}-${ACTIVE_ENGINE}`,
    },
    body: JSON.stringify({
      engine: ACTIVE_ENGINE,
      mode: "text-to-video",
      prompt: input.prompt,
      duration: input.duration,
      resolution: input.resolution,
      aspectRatio: "16:9",
      generateAudio: true,
      enablePromptExpansion: false,
    }),
  });

  const created = (await createRes.json()) as { job?: JobRow; creditsBalance?: number; error?: string };
  if (createRes.status === 402) throw new Error(`Insufficient credits: ${created.error}`);
  if (createRes.status === 502) throw new Error(`Upstream fault (100% auto-refunded): ${created.error}`);
  if (!createRes.ok || !created.job) throw new Error(created.error || `HTTP ${createRes.status}`);

  // Poll GET /api/jobs/{id} with capped backoff (3s -> 8s)
  let delayMs = 3000;
  let finalJob = created.job;
  while (finalJob.status === "queued" || finalJob.status === "processing") {
    await new Promise((r) => setTimeout(r, delayMs));
    delayMs = Math.min(8000, Math.round(delayMs * 1.25));

    const pollRes = await fetch(`${API_BASE}/api/jobs/${finalJob.id}`, {
      headers: { Authorization: `Bearer ${API_KEY}` },
    });
    if (!pollRes.ok) throw new Error(`Poll failed: HTTP ${pollRes.status}`);
    const polled = (await pollRes.json()) as { job: JobRow; creditsBalance: number };
    finalJob = polled.job;
  }

  // Emit signed internal webhook to your app backend on terminal state
  if (input.webhookUrl && input.webhookSecret) {
    const payload = JSON.stringify({
      event: finalJob.status === "completed" ? "video.completed" : "video.refunded",
      shotId: input.shotId,
      jobId: finalJob.id,
      engine: finalJob.engine,
      creditsCharged: finalJob.status === "completed" ? finalJob.credits_charged : 0,
      outputUrl: finalJob.output_url,
      errorMessage: finalJob.error_message,
    });
    const sig = crypto.createHmac("sha256", input.webhookSecret).update(payload).digest("hex");
    await fetch(input.webhookUrl, {
      method: "POST",
      headers: { "Content-Type": "application/json", "X-Worker-Signature": `sha256=${sig}` },
      body: payload,
    });
  }

  return finalJob;
}

Every terminal upstream failure or moderation halt sets finalJob.status = "refunded" and reverses 100% of credits_charged automatically inside the server ledger.

Section 04

Auto-Refund Ledger Mechanics & NOWPayments Billing Webhooks

Two financial guarantees separate production-grade video APIs from toy wrappers: deterministic failure refunds and idempotent billing settlement. On HappyWan Video, credit debits execute atomically inside transactional ledger entries the instant POST /api/jobs validates your parameters. If the upstream submission fails immediately (HTTP 502) or if GET /api/jobs/{id} later observes an upstream crash, queue expiration, empty output, or content-moderation halt, the server transitions the job to status: "refunded" and posts a matching positive credit delta referencing job.id—zero support tickets required.

For borderless programmatic top-ups via POST /api/billing/checkout (non-expiring Spark $19 / 1,000 cr and Showrunner $59 / 3,500 cr packs, plus Filmmaker, Studio Pro, and Enterprise API tiers down to $0.0142/cr, all-in USD with payment processing included), HappyWan Video settles crypto invoices through NOWPayments IPN webhooks (/api/billing/webhooks/nowpayments) verified in constant time via HMAC-SHA512 (x-nowpayments-sig) with duplicate-delivery protection and 99% underpayment dust tolerance.

  • 01HTTP 400 validation errors (such as sending video-edit to happyhorse-1.1 or engine: "happywan-1.0" pre-launch) fail fast before touching your balance—0 credits reserved.
  • 02HTTP 402 balance errors tell automated pipelines cleanly when to alert ops or pause batch queues without leaving half-written job records.
  • 03Plan launch-week resilience now: track wall-clock queued time on happywan-1.0 after GA opens, and fall back automatically to wan-3.0-pro (2–30s 1080p–4K) or happyhorse-1.1 (3–15s 7-language speech) if launch-day latency spikes past your SLA.

Production Templates

Copyable Production Prompts

01API Smoke-Test Prompt: 5-Second Wan 3.0 480p Sanity Check (25 Credits)

wan-3.0 · text-to-video · 480p · 5s
Locked 50mm tabletop shot under clean studio daylight. Amber cold-brew coffee pours smoothly from a glass carafe into a fluted tumbler over clear ice cubes. Crisp liquid pour, gentle ice clink, quiet room tone, no background music.

Costs just 25 credits (~$0.36–$0.48) to verify auth headers, polling loops, and output MP4 ingestion end-to-end.

Test in Studio

02API Batch Localization Prompt: HappyHorse 1.1 German Spokesperson (8s)

happyhorse-1.1 · reference-to-video · 1080p · 8s
Eye-level 50mm medium close-up inside a bright Munich studio with soft frontal window fill. Facing camera at a relaxed 10-degree angle, presenter Lukas (reference images 1-2) rests his hand beside the matte steel travel flask (reference image 3) below chest height and speaks warmly in natural German: 'Zwölf Stunden heiß, null Auslaufen—bereit für jede Zugfahrt.' Calm closing nod, dry studio acoustics, no background music.

10 German words fit cleanly inside 8 seconds (160 credits at 1080p; 120 credits at 720p) with zero post-dubbing pipeline.

Test in Studio

Failure Diagnostics

Common Pitfalls & Fixes

ERR 01Omitting Idempotency-Key inside retry-enabled HTTP clients or serverless functions.

Why It Fails: A transient TLS reset after POST /api/jobs succeeds server-side causes blind retries to enqueue duplicate 30–45s jobs.

Fix: Pass a deterministic Idempotency-Key tied to your shot ID and revision number on every submission.

ERR 02Checking camelCase job.outputUrl instead of the live REST response key job.output_url.

Why It Fails: Live POST /api/jobs and GET /api/jobs/{id} serialize SQLite job rows with snake_case (output_url, credits_charged, error_message), so misnamed field lookups evaluate to undefined.

Fix: Type your response interface strictly against output_url, credits_charged, duration_seconds, and error_message as shown in the TypeScript worker above.

ERR 03Skipping per-job credit ceilings before enabling 45-second happywan-1.0 batches.

Why It Fails: A loop accidentally sending duration: 45 at 1080p (est. 900 cr/job) across 50 SKUs can consume 45,000 credits in minutes.

Fix: Enforce a hard MAX_CREDITS_PER_JOB software guard and audition batches on wan-3.0 480p (5 cr/s) before promoting to HD.

ERR 04Treating happywan-1.0 HTTP 400 pre-launch responses as retryable 5xx outages.

Why It Fails: Infinite retry loops on HTTP 400 waste compute without generating video until December 2026 GA flips on.

Fix: Only retry HTTP 429/5xx with backoff, and route live traffic to wan-3.0, wan-3.0-pro, or happyhorse-1.1 until launch activation.

Apply This Playbook Live

Fund non-expiring credits from $19 and model exact campaign budgets.

Draft at 480p on live Wan 3.0 (5 cr/s), print 1080p–4K on Wan 3.0 Pro (16–21 cr/s), or generate 7-language lip-sync on HappyHorse 1.1—backed by 100% automatic refunds on failed or filtered renders.

Related Technical Monographs

HappyWan API Quickstart: REST Schema, Pricing & Webhooks