API Creator & Live HTTP Runner
Architect typed API routes to instantly generate production Next.js 15 App Router handlers, OpenAPI 3.1 specifications, TypeScript fetch clients, and cURL commands—or switch to the Live Runner to send real HTTP requests and inspect latency and payloads.
Request JSON Fields
Response JSON Fields
// File: app/api/v1/clips/route.ts
import { NextRequest, NextResponse } from 'next/server';
export const runtime = 'nodejs';
export const dynamic = 'force-dynamic';
interface RequestPayload {
sourceUrl: string;
targetFormat?: string;
maxHeight?: number;
}
export async function POST(req: NextRequest) {
try {
const authHeader = req.headers.get('authorization') || '';
if (!authHeader.startsWith('Bearer ') || authHeader.length < 16) {
return NextResponse.json({ error: 'Missing or invalid Bearer token.' }, { status: 401 });
}
const body = (await req.json().catch(() => null)) as RequestPayload | null;
if (!body) {
return NextResponse.json({ error: 'Invalid JSON request body.' }, { status: 400 });
}
if (body.sourceUrl === undefined || body.sourceUrl === null || body.sourceUrl === '') {
return NextResponse.json({ error: 'Field "sourceUrl" is required.' }, { status: 400 });
}
// Replace with your real database/service call
const result = {
"jobId": "job_98f2a1",
"status": "queued",
"estimatedSeconds": 14
};
return NextResponse.json(result, {
status: 201,
headers: { 'Cache-Control': 'no-store' },
});
} catch (err) {
return NextResponse.json(
{ error: err instanceof Error ? err.message : 'Internal server error' },
{ status: 500 }
);
}
}