Content Gateway Prototype API (beta)

Connect products and agents to BMJ content through one stable contract.

Authentication performs reads only. The active contract supplies capabilities and a BMJ content grant; a separate execution profile selects the retrieval and generation stack; billable work is reserved and then settled or refunded.

Discover the permitted corpus

GET /v1/customer/corpus-summary reports scoped content-type, journal, date, document, evidence and topic coverage. GET /v1/documents browses only documents admitted to the customer’s release and contract scope.

curl 'https://content-gateway.bmj-cloudflare-hackathon.com/v1/customer/corpus-summary' \
  -H "Authorization: Bearer ${BMJ_EVIDENCE_API_KEY}"

curl 'https://content-gateway.bmj-cloudflare-hackathon.com/v1/documents?journal_id=bmjonc&limit=25' \
  -H "Authorization: Bearer ${BMJ_EVIDENCE_API_KEY}"

Resolve editorial collections

GET /v1/collections discovers published static and dynamic collections. Membership is always resolved inside the authenticated customer’s release and contract scope.

curl 'https://content-gateway.bmj-cloudflare-hackathon.com/v1/collections?limit=25' \
  -H "Authorization: Bearer ${BMJ_EVIDENCE_API_KEY}"

curl 'https://content-gateway.bmj-cloudflare-hackathon.com/v1/collections/open-data-research/documents?limit=25' \
  -H "Authorization: Bearer ${BMJ_EVIDENCE_API_KEY}"

Search evidence

POST /v1/search performs semantic, keyword or hybrid retrieval against the customer policy’s active index generation.

curl -X POST 'https://content-gateway.bmj-cloudflare-hackathon.com/v1/search' \
  -H "Authorization: Bearer ${BMJ_EVIDENCE_API_KEY}" \
  -H 'Content-Type: application/json' \
  -H 'X-Request-Id: client-generated-unique-id' \
  --data '{
    "query": "What evidence discusses treatment adherence?",
    "max_results": 5,
    "retrieval": "hybrid",
    "rerank": true
  }'

Build with canonical chunks

GET /v1/chunks/:evidence_id returns a stable BMJ paragraph chunk only when the key scope, independent source-chunk entitlement, release grant and paragraph execution profile all permit it. The add-on can accompany search with or without grounded answers.

Chunk responses include offsets, content hash, citation metadata and the licensed_content_1k_tokens settlement.

Track a rolling answer

POST /v1/rolling-answers is an optional, asynchronous grounded-answer capability. It evaluates a customer-scoped rolling evidence window at monthly checkpoints, records months with no evidence, and then reports deterministic stability/change signals plus a separate trend synthesis.

curl -X POST 'https://content-gateway.bmj-cloudflare-hackathon.com/v1/rolling-answers' \
  -H "Authorization: Bearer ${BMJ_EVIDENCE_API_KEY}" \
  -H 'Content-Type: application/json' \
  -H 'X-Request-Id: client-generated-unique-id' \
  --data '{
    "query": "What does the evidence report about diabetes prevention, treatment and outcomes?",
    "window_months": 1,
    "checkpoint_from": "2025-08",
    "checkpoint_to": "2026-07",
    "max_results": 5,
    "retrieval": "hybrid",
    "rerank": true
  }'

# The POST returns HTTP 202. Poll the relative status_url with the same key.

window_months: 1 makes each checkpoint use only evidence published in that calendar month. This example uses diabetes because the current POC catalogue has diabetes-tagged articles in every month from July 2025 through July 2026. Corpus summary remains authoritative for each customer’s narrower scope.

Administrator console

The administrator pages use Cloudflare Access or ADMIN_TOKEN. A customer API key never authorizes these views.

ViewPurpose
OverviewSee the control-plane summary and move between operational areas.
POST /api/admin/ingestAuthenticated multipart ingestion for command-line and integration clients; returns a pollable job URL.
IngestionBulk-select or drag files, check duplicates, admit batches and follow document Workflows.
Content libraryNavigate documents, immutable versions and generation-scoped evidence units, including lineage and index state.
CollectionsPublish stable reading lists or validated live article sets.
Article trustManage the marker registry, journal defaults and article-level overrides.
Product plansCompose access modules, content types and date policy; inspect assigned customers and safely retire unused plans.
CustomersManage plans, entitlements and key issuance; inspect retained search/question activity; assign only physically reachable, indexed execution profiles through an audited version change.
API key managementFilter all active or revoked credentials by customer or plan, see key-attributed usage and customer-wide plan consumption, and revoke an active key.
Usage dashboardGroup settled activity by customer, API key, document or evidence unit.
Customer requestsInspect retained searches, questions and chunk reads across customers with customer, key, operation, outcome, date-period and text filters.
Rolling answersFollow monthly checkpoints, explicit evidence gaps, cache reuse, grounding and the final longitudinal trend.
Architecture referenceRead service-boundary and entity documentation with widescreen, zoomable diagrams.

How usage is counted: customer and API-key views show settled meter units. Document and evidence-unit views show distinct settled request exposure, preventing a grounded answer’s answer and token settlements from being counted as separate content uses.

Request-text retention: authenticated search and grounded-answer text, sanitized options, outcomes and evidence IDs are retained for 30 days in the separate request-audit service. Bearer tokens and arbitrary HTTP headers are never sent to it. Do not put credentials or personal data in a query.

Authentication methods

AudienceMethodUsed forRules
Customer or agentAuthorization: Bearer bmjp_…/mcp, /v1/collections, /v1/articles/:id/trust, search, answers and chunksKeys are shown once. Store them as secrets; never put them in URLs or logs.
Public transparencyNone/v1/trust/schema, /v1/trust/markers, /v1/trust/articles/:idReturns only public effective assertions; editor identities remain in internal audit storage.
Administrator via browserCloudflare Access identity or the login form backed by ADMIN_TOKENOverview, ingestion, content, customer, usage and architecture pagesDo not use administrator credentials for customer search.
Administrator via APIAuthorization: Bearer <ADMIN_TOKEN>/api/admin/*Control-plane access only; configure as a Worker secret.

Request

query
Required string, 2–2,000 characters
max_results
Optional, 1–50; capped by customer policy
retrieval
hybrid, vector or keyword
rerank
Optional boolean; defaults to true
match_threshold
Optional number from 0–1; defaults to 0.35
filters
Optional narrower journal/date filters; cannot broaden contract scope
window_months
Rolling answers only: evidence lookback, constrained by the named offer
checkpoint_from/to
Rolling answers only: optional monthly range in YYYY-MM; publication dates are derived per checkpoint
X-Request-Id
Recommended 8–128 character idempotency key

Response

Results include evidence_id, score, bounded text, item key and safe metadata. The execution_context reports policy, content release, logical generation, physical backend, segmentation and embedding method.

/v1/search returns retrieval directly. /v1/answers adds generation and returns the same sources, explicit component provenance, model-token meters and grounding warnings.

Inspect the authenticated context

Use this endpoint before search when an agent needs to explain its current limits or active corpus.

curl 'https://content-gateway.bmj-cloudflare-hackathon.com/v1/customer/context' \
  -H "Authorization: Bearer ${BMJ_EVIDENCE_API_KEY}"

Status and error contract

StatusMeaningAgent action
200Search or answer completed, including a valid empty search resultUse only returned evidence and provenance.
202A rolling-answer Workflow was admittedPoll the returned status_url with the same customer key.
400Invalid requestCorrect the payload; do not retry unchanged.
401Missing, invalid or revoked keyStop and request a valid customer key.
403Suspended customer or missing scopeStop and contact an administrator.
429Customer quota exhaustedRespect Retry-After; do not rotate keys.
503The physical generation is unavailable, or synthesis returned empty/truncated output or lacks a registered adapterRetry once with the same request ID. Then report the returned code; an administrator should check the execution profile and synthesis telemetry.