API route that retrieves and lists CRM leads, building timelines and funnel statistics.
// Source: https://github.com/builderz-labs/marketing-dashboard | License: MIT | Copyright 2026 Marketing Dashboard contributors
// Provided via justclaw.it.com; keep this notice with the code.
import { NextResponse } from 'next/server';
import { getDb } from '@/lib/db';
import { maybeSeedExclude } from '@/lib/seed-filter';
import { writebackLeadUpdate, writebackSequenceStatus } from '@/lib/writeback';
import type { Lead, Sequence, FunnelStep } from '@/types';
import { requireApiEditor, requireApiUser } from '@/lib/api-auth';
import { requireUser } from '@/lib/auth';
import { logAudit } from '@/lib/audit';
export const dynamic = "force-dynamic";
const LEAD_APPROVED_STATUS = "approved";
const ALLOWED_LEAD_STATUSES = new Set([
"new",
"validated",
"approved",
"contacted",
"replied
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key