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.
| View | Purpose |
|---|---|
| Overview | See the control-plane summary and move between operational areas. |
POST /api/admin/ingest | Authenticated multipart ingestion for command-line and integration clients; returns a pollable job URL. |
| Ingestion | Bulk-select or drag files, check duplicates, admit batches and follow document Workflows. |
| Content library | Navigate documents, immutable versions and generation-scoped evidence units, including lineage and index state. |
| Collections | Publish stable reading lists or validated live article sets. |
| Article trust | Manage the marker registry, journal defaults and article-level overrides. |
| Product plans | Compose access modules, content types and date policy; inspect assigned customers and safely retire unused plans. |
| Customers | Manage plans, entitlements and key issuance; inspect retained search/question activity; assign only physically reachable, indexed execution profiles through an audited version change. |
| API key management | Filter all active or revoked credentials by customer or plan, see key-attributed usage and customer-wide plan consumption, and revoke an active key. |
| Usage dashboard | Group settled activity by customer, API key, document or evidence unit. |
| Customer requests | Inspect retained searches, questions and chunk reads across customers with customer, key, operation, outcome, date-period and text filters. |
| Rolling answers | Follow monthly checkpoints, explicit evidence gaps, cache reuse, grounding and the final longitudinal trend. |
| Architecture reference | Read 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
| Audience | Method | Used for | Rules |
|---|---|---|---|
| Customer or agent | Authorization: Bearer bmjp_… | /mcp, /v1/collections, /v1/articles/:id/trust, search, answers and chunks | Keys are shown once. Store them as secrets; never put them in URLs or logs. |
| Public transparency | None | /v1/trust/schema, /v1/trust/markers, /v1/trust/articles/:id | Returns only public effective assertions; editor identities remain in internal audit storage. |
| Administrator via browser | Cloudflare Access identity or the login form backed by ADMIN_TOKEN | Overview, ingestion, content, customer, usage and architecture pages | Do not use administrator credentials for customer search. |
| Administrator via API | Authorization: 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
retrievalhybrid,vectororkeywordrerank- 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
| Status | Meaning | Agent action |
|---|---|---|
| 200 | Search or answer completed, including a valid empty search result | Use only returned evidence and provenance. |
| 202 | A rolling-answer Workflow was admitted | Poll the returned status_url with the same customer key. |
| 400 | Invalid request | Correct the payload; do not retry unchanged. |
| 401 | Missing, invalid or revoked key | Stop and request a valid customer key. |
| 403 | Suspended customer or missing scope | Stop and contact an administrator. |
| 429 | Customer quota exhausted | Respect Retry-After; do not rotate keys. |
| 503 | The physical generation is unavailable, or synthesis returned empty/truncated output or lacks a registered adapter | Retry once with the same request ID. Then report the returned code; an administrator should check the execution profile and synthesis telemetry. |