Brand Studio docs
Engineering manualAPI route source

/api/brands/search-changes

Exact current route handler: hosted-app/app/api/brands/search-changes/route.js

Methods: GET. Input signals: query parameters. Literal response-status signals: none detected.

Source: hosted-app/app/api/brands/search-changes/route.js. Imports: ../../../../lib/comprehensive-pull.mjs, ../../../../lib/search-changes.mjs, ../../../../lib/supabase-rest.mjs, next/server. Exact source is shown for inspection; its presence does not prove authentication, validation or live behavior.

All API routes · API and execution contract

// GET /api/brands/search-changes?domain= — the brand's latest two finished
// reports that read its Google rankings, what changed between them (totals,
// position moves in the sampled searches, ranking pages, backlinks), and the
// date of the provider's current Google data. Sessions and API keys with
// read_reports. Reads saved reports and the free Labs status only. See
// lib/search-changes.mjs.

import { NextResponse } from "next/server";
import { supabaseConfigFromEnv } from "../../../../lib/supabase-rest.mjs";
import { bearerTokenFromHeader } from "../../../../lib/comprehensive-pull.mjs";
import { getSearchChanges } from "../../../../lib/search-changes.mjs";

export const runtime = "nodejs";
export const dynamic = "force-dynamic";
export const maxDuration = 30;

const PRIVATE = { "cache-control": "private, no-store", "x-content-type-options": "nosniff" };

export async function GET(request) {
  const result = await getSearchChanges({ token: bearerTokenFromHeader(request.headers.get("authorization")), config: supabaseConfigFromEnv(process.env), domain: new URL(request.url).searchParams.get("domain") || "" });
  return NextResponse.json(result.body, { status: result.http_status, headers: PRIVATE });
}