Brand Studio docs
Engineering manualAPI route source

/api/brands/watch

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

Methods: GET, POST. Input signals: JSON body. Literal response-status signals: none detected.

Source: hosted-app/app/api/brands/watch/route.js. Imports: ../../../../lib/basic-watches.mjs, ../../../../lib/comprehensive-pull.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

// /api/brands/watch — weekly basic checks for saved brands.
//
//   GET                       the account's checks (read_reports)
//   POST { domain, action }   start | pause | resume | stop one brand's check
//
// Changing a check needs a browser session or an API key with run_pulls;
// assistant connections are read-only. A check is free: it re-reads the public
// homepage once a week and keeps a copy only when something changed. See
// lib/basic-watches.mjs.

import { NextResponse } from "next/server";
import { supabaseConfigFromEnv } from "../../../../lib/supabase-rest.mjs";
import { bearerTokenFromHeader } from "../../../../lib/comprehensive-pull.mjs";
import { listBasicWatches, setBasicWatch } from "../../../../lib/basic-watches.mjs";

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

const PRIVATE = { "cache-control": "private, no-store", "x-content-type-options": "nosniff" };
const reply = (result) => NextResponse.json(result.body, { status: result.http_status, headers: PRIVATE });
const tokenOf = (request) => bearerTokenFromHeader(request.headers.get("authorization"));

export async function GET(request) {
  return reply(await listBasicWatches({ token: tokenOf(request), config: supabaseConfigFromEnv(process.env) }));
}

export async function POST(request) {
  const body = await request.json().catch(() => null);
  return reply(await setBasicWatch({ token: tokenOf(request), config: supabaseConfigFromEnv(process.env), body: body || {} }));
}