API reference

This is a source-derived reference for the routes currently implemented in v2/api/worker.ts and v2/api/investigations.ts. It is not an OpenAPI document and it does not claim that the API Worker is deployed.

For copyable, source-checked requests and error handling, start with Get started and API examples. For per-endpoint parameter tables and request/response examples in three languages, see API endpoints.

Common behavior

  • /health is public and returns Cache-Control: no-store.
  • Internal callback/publication routes require the configured Automation signature and are not browser endpoints.
  • Every /api/v1/* route requires an authenticated actor, a configured SQL database, an organization/workspace scope, and the required capability.
  • Product-scoped routes require an enabled product selected by x-harvy-product or the product query/body field.
  • Writes use bounded JSON, revision checks, and tenant/workspace/product predicates.
  • Errors have a stable code, an HTTP status, and a trace identifier.
  • Private or tenant-scoped responses must not be publicly cached.

Availability

The API Worker implements GET /health as a public health endpoint. Product requests under /api/v1/ require an authenticated actor and configured storage; Automation callbacks are internal-only and are intentionally omitted from the public route inventory. See the repository source for those private contracts.

Context and administration

MethodPathCapability / scopeNotes
GET/api/v1/contextAuthenticated actorReturns tenant/workspace, role, products, capabilities, revisions, HQL version, and configured service health.
GET/api/v1/entitlementsentitlements.manageLists product grants for the actor’s tenant.
PUT/api/v1/entitlementsentitlements.manageRevision-checked product grant update; writes an audit record.
GET/api/v1/admin/auditentitlements.manageBounded audit feed for entitlement, monitor, and dashboard state.
GET/api/v1/sourcesmonitors.viewApproved sources only; non-managers see enabled sources only; capped at 200.
PATCH/api/v1/sources/:source_idmonitors.managePause/resume an approved monitor with expected_revision.

Search and events

MethodPathCapability / scopeNotes
GET/api/v1/searchquery.viewSearches scoped events, evidence metadata, Newsk stories, dashboards, Ops actions, investigations, and entities. q max 120 characters; limit max 20.
GET/api/v1/eventsevents.viewProduct-scoped event list with bounded filters and pagination.
GET/api/v1/events/:event_idevidence.viewReturns one scoped event and source evidence.
PATCH/api/v1/events/:event_idevents.editRevision-checked status/assignment update. Statuses: new, reviewing, saved, closed.
POST/api/v1/events/:event_id/handoffevents.handoffCreates an Ops action only for Tower/Civic events with evidence and Ops enabled. Idempotent for the same event.

Analytics and query

MethodPathCapability / scopeNotes
GET/api/v1/cube/metaquery.view + enabled productReturns registered cube metadata.
GET/api/v1/cube/load?query=<JSON>query.view + enabled productParses a bounded JSON cube query from the query string; encoded query max 65,536 bytes.
POST/api/v1/cube/loadquery.view + enabled productParses the bounded Drizzle Cube query body.
POST/api/v1/queryquery.view + enabled productParses the bounded HQL subset; dispatches engine-marked cubes to Basin and other cubes to the local analytics layer.

The query contracts are defined in v2/shared/hql.ts, v2/shared/cubes.ts, and v2/api/analytics.ts. Raw SQL, unregistered cubes/fields, unbounded limits, joins, and unsupported operators are rejected.

Newsk stories and briefs

MethodPathCapability / scopeNotes
GET/api/v1/storiesNewsk + stories.viewLists up to 100 workspace stories.
POST/api/v1/storiesNewsk + stories.editCreates a draft from a scoped Newsk event.
GET/api/v1/stories/:story_idNewsk + stories.viewReads one story.
PATCH/api/v1/stories/:story_idNewskRevision-checked story update through updateStory.
POST/api/v1/stories/:story_id/handoffNewsk + Ops + stories.handoffRequires ready state and source evidence; creates an Ops action.
POST/api/v1/briefsNewsk + stories.editCreates an extractive, citation-bearing brief from a story.
GET/api/v1/briefsNewsk + stories.viewLists up to 100 briefs.

Dashboards

MethodPathCapability / scopeNotes
GET/api/v1/dashboardsdashboards.viewReturns visible dashboards for entitled products.
POST/api/v1/dashboardsdashboards.editCreates a bounded private/workspace dashboard config.
PATCH/api/v1/dashboards/:dashboard_iddashboards.editOwner-only revision-checked update.
DELETE/api/v1/dashboards/:dashboard_iddashboards.editOwner-only revision-checked soft delete.

Dashboard configs are validated by the shared schema; arbitrary JSON is not accepted as a dashboard contract.

Runs and Automation dispatch

MethodPathCapability / scopeNotes
POST/api/v1/runsruns.manageRegisters an approved source snapshot, consumes quota, enforces idempotency, claims dispatch, and sends a bounded signed envelope.
GET/api/v1/runsruns.viewLists up to 100 product-scoped runs. Idempotency keys are visible only to managers.
GET/api/v1/runs/:run_idruns.viewReads one scoped run.

The run envelope requires an approved registered source, required_proxy: webshare, preflight_required: true, direct_fallback_allowed: false, a 300-second deadline, and a stable idempotency key. The live Automation workflow and provider egress remain unverified.

Investigations and graph

Implemented in v2/api/investigations.ts:

MethodPathNotes
GET/api/v1/investigationsLists scoped investigations.
POST/api/v1/investigationsCreates an investigation.
GET/api/v1/investigations/:idReads an investigation with up to 100 items.
PATCH/api/v1/investigations/:idRevision-checked title/summary/status update.
POST/api/v1/investigations/:id/itemsAdds a note or scoped event/evidence/entity/relationship item.
DELETE/api/v1/investigations/:id/items/:item_idRemoves an item with revision checking.
GET/api/v1/entitiesSearches scoped entities.
POST/api/v1/entitiesCreates a typed entity.
GET/api/v1/entities/:idReads an entity with evidence-backed relationships.
POST/api/v1/relationshipsCreates an evidence-backed observed/inferred/disputed relationship.
GET/api/v1/graphReturns capped scoped graph nodes and edges, optionally filtered by investigation.