Documentation

POST /api/discover

Run the discovery script and return its terminal output verbatim.

RequestPOST /api/discover
AuthenticationSession cookie required
Handlerbackend/server.py

What it does

Runs the sourcing script and hands back what the terminal would have shown, line by line, plus the exit code. The engine does not summarise the run: `log` and `stderr` are the script's own words, so the operator sees the same thing a shell would show. `status` is `ok` only on a zero exit code.

Authentication

Session cookie required. Send the ff_session cookie. Without one the engine treats the caller as a new visitor with no holds and no claims, and returns a new cookie to use from then on.

Parameters

ParameterInTypeRequiredDescription
ff_sessioncookiestringOptionalThe session identifier. Omit it on the first call and store the value the response sets; every later call must send the same one or the engine treats the caller as a new visitor with no holds and no claims.
qbodystringOptionalA query to discover against. When absent, the scheduled discovery script is run instead and `ran` names the script path.
modebodystringOptionalSelects the discovery mode the script runs in.
use_research_briefbodybooleanOptionalSeed the run from the nightly research brief rather than from the query alone.

Request

The cookie jar carries the session between calls. Angle-bracketed values are the parameter types from the table above.

curl -s -b cookies.txt -c cookies.txt \
  -X POST -H 'Content-Type: application/json' \
  -d '{"q":"<string>","mode":"<string>","use_research_brief":"<boolean>"}' \
  "https://flowfinds.ai/api/discover"
const res = await fetch("https://flowfinds.ai/api/discover", {
  method: "POST",
  credentials: "include",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "q": "<string>",
    "mode": "<string>",
    "use_research_brief": "<boolean>"
  }),
});
const data = await res.json();
import requests

s = requests.Session()
r = s.post("https://flowfinds.ai/api/discover", json={
    "q": "<string>",
    "mode": "<string>",
    "use_research_brief": "<boolean>"
  })
data = r.json()

Recorded example

curl -s -b cookies.txt -c cookies.txt \
  -X POST -H 'Content-Type: application/json' \
  -d '{"q":"…"}' \
  "$FLOWFINDS_ORIGIN/api/discover"

Responses

200The run completed, successfully or not.

FieldTypeDescription
statusstring`ok` on exit code 0, otherwise `refused`.
querystring | nullThe query as run.
ranstring | nullPath of the script that was run, relative to the repository root, when no query was supplied.
exit_codenumberThe process exit code.
logstring[]Non-empty stdout lines, unedited.
stderrstring[]Non-empty stderr lines, unedited.

Errors

This endpoint has no failure path of its own. An uncaught exception anywhere in the engine is still returned as structured JSON by the shared guard.

Related

Back to the API reference index, or read the cookbook for recipes that compose this endpoint with others.