Skip to content

Context API

Push and pull recipes

These snippets show the basic push, poll, and pull flow for Context API. Replace the placeholders with your Context API key (sk_ctx_…), your account ID, and the API base URL for your environment.

Procurement packet: Trust & security, Sub-processors, Track A contracting placeholders, and security.txt.

First integration (~5 minutes)

Mint an API key with read + ingest in the signed-in API Console. Replace <WORKSPACE_HEX_PREFIX> with the first 8 hexadecimal characters from your account ID (omit dashes) so searches stay identifiable.

  1. Open API Console → enable Ingest capability → Create API key.
  2. Push the ingest body below (anchors search on the prefixed text).
  3. Poll job id when async.
  4. Confirm readback with GET /api/context/search?q=….

Ingest probe

curl -sS -X POST "https://api.neither.online/api/ingest" \
  -H "Authorization: Bearer <CONTEXT_API_KEY>" \
  -H "Content-Type: application/json" \
  -d "{\"workspace_id\":\"<WORKSPACE_ID>\",\"source_id\":\"fir-integ-quickstart-run\",\"content_type\":\"generic_snippet\",\"text\":\"fir-integ-anchor-<WORKSPACE_HEX_PREFIX>\",\"title\":\"First ingest probe\"}"

Poll ingest job (optional)

curl -sS "https://api.neither.online/api/ingest/jobs/<JOB_ID>" \
  -H "Authorization: Bearer <CONTEXT_API_KEY>"

Pull via search readback

curl -sS "https://api.neither.online/api/context/search?q=fir-integ-anchor-<WORKSPACE_HEX_PREFIX>&limit=5" \
  -H "Authorization: Bearer <CONTEXT_API_KEY>"

Canonical written walkthrough mirroring UI copy: repo file docs/api/first-integration-quickstart.md.

Push — single ingest

Body fields must match the published ingest schema. Use async ingest for larger payloads and poll the returned job until processing is complete.

curl -sS -X POST "https://api.neither.online/api/ingest" \
  -H "Authorization: Bearer <CONTEXT_API_KEY>" \
  -H "Content-Type: application/json" \
  -d "{\"workspace_id\":\"<WORKSPACE_ID>\",\"source_id\":\"example-source-1\",\"content_type\":\"generic_snippet\",\"text\":\"Hello\",\"title\":\"T\"}"

TypeScript (fetch)

// Node 18+ ESM ("type":"module") or paste inside async function/worker — top-level await.
const baseUrl = process.env.API_BASE ?? "https://api.neither.online";
const apiKey = process.env.CONTEXT_API_KEY;
if (!apiKey) throw new Error("Set CONTEXT_API_KEY");
const workspaceId = process.env.WORKSPACE_ID ?? "<WORKSPACE_ID>";
const res = await fetch(`${baseUrl}/api/ingest`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${apiKey}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    workspace_id: workspaceId,
    source_id: "example-source-1",
    content_type: "generic_snippet",
    text: "Hello",
    title: "T",
  }),
});
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
console["log"](await res.json());

Poll ingest job

Use the job_id from the ingest response.

curl -sS "https://api.neither.online/api/ingest/jobs/<JOB_ID>" \
  -H "Authorization: Bearer <CONTEXT_API_KEY>"

Pull — list projects

Example read on GET /api/context/projects. Optional BC query parameters are in OpenAPI.

curl -sS "https://api.neither.online/api/context/projects" \
  -H "Authorization: Bearer <CONTEXT_API_KEY>"

TypeScript (fetch)

// Node 18+ ESM ("type":"module") or paste inside async function/worker.
const baseUrl = process.env.API_BASE ?? "https://api.neither.online";
const apiKey = process.env.CONTEXT_API_KEY;
if (!apiKey) throw new Error("Set CONTEXT_API_KEY");

const res = await fetch(`${baseUrl}/api/context/projects`, {
  headers: { Authorization: `Bearer ${apiKey}` },
});
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
const data = (await res.json()) as { projects?: unknown[] };
console["log"](data.projects?.length ?? 0, "projects");

Delete by source ID (replay)

Remove all processed rows for a stable source_id, confirm residual counts return to zero, then post a corrected envelope with the same id. The sample uses example-source-1 — swap the path segment for your own stable identifier.

curl -sS -X DELETE "https://api.neither.online/api/ingest/<SOURCE_ID>" \
  -H "Authorization: Bearer <CONTEXT_API_KEY>"

API overview · Hosted OpenAPI

We use privacy-friendly analytics to improve the public site. No tracking runs until you accept. Essential operational telemetry stays on either way.