Answers API
AnswerSet management, Question API, Knowledge, seeding, governance, learning, Question Keys, and portability.
Base URL:
https://lakeshark.dev/api/answers
Management endpoints use an access token with answers.read or answers.write.
POST /v1/questions uses a Question Key instead.
AnswerSets
| Method | Path | Purpose |
|---|---|---|
| GET | /v1/answer-sets |
List AnswerSets |
| POST | /v1/answer-sets |
Build manually |
| GET | /v1/answer-sets/{answer_set_id} |
Read detail |
| PATCH | /v1/answer-sets/{answer_set_id} |
Partially update the resource and create an AnswerSet revision |
| PUT | /v1/answer-sets/{answer_set_id}/apply |
Apply portable AnswerSet JSON with optional revision precondition |
| GET | /v1/answer-sets/{answer_set_id}/config |
Read configuration |
| PATCH | /v1/answer-sets/{answer_set_id}/config |
Update configuration and publish a new ConfigStore version |
| DELETE | /v1/answer-sets/{answer_set_id} |
Delete with confirmation |
| POST | /v1/answer-sets/{answer_set_id}/backend |
Change provider/model |
| GET | /v1/answer-sets/{answer_set_id}/settings |
Read output/settings policy |
| PATCH | /v1/answer-sets/{answer_set_id}/settings |
Change provider/model/output policy |
| POST | /v1/answer-sets/{answer_set_id}/ask |
Management test request |
| GET | /v1/answer-sets/{answer_set_id}/metrics |
AnswerSet metrics |
| GET | /v1/answer-sets/{answer_set_id}/runs |
Recent runs |
Manual create example:
{
"name": "Security help desk",
"purpose": "Answer employee security support questions.",
"provider_connection_id": "30f51446-dd2f-498d-bf0e-c589d4d9de44",
"model": "gpt-5.6",
"fallback_instructions": "Answer from approved company policy. Do not invent policy.",
"answer_type": "text",
"answer_options": [],
"strict_answers": [],
"auto_approve_confidence": null
}
Current console output formats map to text, number, boolean, json, and list.
JSON Editor and apply
The AnswerSet Editor exports editable JSON. To apply a complete portable resource to an existing AnswerSet, call PUT /v1/answer-sets/{answer_set_id}/apply with a bundle object and optional integer expected_revision. The request must match the existing AnswerSet’s provider hint; a revision mismatch returns 409. Applying publishes a configuration version and updates the AnswerSet and Knowledge; treat it as a potentially broad replacement, not a small JSON merge patch.
For small changes to name, purpose, instructions or strict-answer fields, use PATCH /v1/answer-sets/{answer_set_id}; for the immutable configuration specification, use PATCH /v1/answer-sets/{answer_set_id}/config. These routes have different payload contracts. Neither requires creating an unrelated import resource. See AnswerSet import and export for moving portable JSON between workspaces.
Scoring and run evidence
AnswerSet responses and run evidence distinguish routing confidence from answer quality:
| Field | Meaning |
|---|---|
route_confidence |
Confidence that the question matches approved Knowledge, not probability of factual correctness |
route_decision |
Reason and classification for the Knowledge routing decision when available |
score_metric |
answer_quality when a quality score applies |
score |
Agreement with eligible approved Knowledge; null when unscored |
score_threshold |
Effective configured threshold, normally 0.82 by default |
score_passed |
Quality score meets the threshold; null if unscored; not a separate output-enforcement rule |
scoring_version |
Version of deterministic scoring behavior |
The route and quality measurements have different scales of meaning, even when both are represented by values between zero and one. A known answer can score 1.0 by matching its own approved reference; this is not independent factual validation. See the complete AnswerSet scoring guide before interpreting dashboards or enforcing policies based on these fields.
Strict JSON outputs with references
JSON AnswerSets can also save one expression-backed structure directly under strict_answers:
{
"answer_type": "json",
"strict_answers": [
{"color": {"$ref": "answer.text"}}
],
"json_template": null
}
This is a strict response shape, rather than an exact-value whitelist: answer.text is filled after Knowledge or provider resolution, so a grounded green answer produces {"color":"green"} as answer_value. No second provider call is needed for formatting. Only one dynamic strict JSON entry is supported. Do not mix it with fixed alternatives or also configure json_template. Unknown or missing references fail the request.
Deterministic JSON response templates
For an existing JSON AnswerSet, GET /v1/answer-sets/{answer_set_id}/settings returns the optional policy.json_template object when the backend supports templates. Update it using the existing settings PATCH endpoint and the ordinary provider/model and policy fields:
{
"provider_connection_id": "30f51446-dd2f-498d-bf0e-c589d4d9de44",
"model": "gpt-5.6",
"answer_type": "json",
"answer_options": [],
"strict_answers": [],
"auto_approve_confidence": null,
"json_template": {
"user": {"$ref": "context.username"},
"color": {"$ref": "answer.text"}
}
}
Use null for json_template to remove a template. Omit the field to preserve an existing template. Only JSON AnswerSets with no fixed approved values can use this feature. Saving creates an auditable AnswerSet revision.
The application’s Question Key request can supply the referenced data:
{
"question": "What color should I use?",
"context": {"username": "operator"}
}
When the AnswerSet resolves to blue, answer_value is {"user":"operator","color":"blue"}. answer carries serialized JSON for backward compatibility. If the request is missing context.username, the service rejects the template resolution rather than inventing a username.
Only direct context.*, question.text, and answer.text/answer.value/answer.source references are supported in this first release. No functions, boolean expressions, automatic text extraction, or arbitrary code are allowed.
See JSON response templates for the complete contract and limits.
Seed with provider
Use provider seeding to create the initial configuration and Knowledge from a purpose statement.
POST /v1/answer-set-seeds
POST /v1/answer-set-seeds/files
JSON request:
{
"purpose": "Answer employee phishing and incident-reporting questions using approved security policy.",
"provider_connection_id": "30f51446-dd2f-498d-bf0e-c589d4d9de44",
"model": "gpt-5.6",
"knowledge_seed_count": 10,
"references": [
{
"name": "security-policy.md",
"media_type": "text/markdown",
"content": "Employees must report suspected phishing to Security Operations."
}
]
}
knowledge_seed_count supports 1 through 200 (default 10). The backend generates in batches of up to 10; provider limitations can yield fewer drafts than requested. The console initially requests up to 10 and uses subsequent purpose-mode generation calls for additional requested drafts.
The file endpoint accepts TXT, Markdown, CSV, JSON, and PDF reference material.
Guided output-contract authoring also uses POST /v1/answer-set-seeds/strict-preview to preview provider-assisted fixed values, JSON expressions, or configuration drafts before the user approves a new AnswerSet. Existing AnswerSets can request draft fixed values with POST /v1/answer-sets/{answer_set_id}/strict-answers/generate. These generation routes propose candidates; they do not bypass output-policy validation or automatically approve values.
Question API
POST /v1/questions
Authentication: Question Key.
Request:
{
"question": "What should I do with a suspicious email?"
}
Representative response:
{
"run_id": "8bc2d846-4ef8-4ed0-9c99-bef469fa3149",
"answer": "Report the message to Security Operations.",
"answer_type": "text",
"answer_value": "Report the message to Security Operations.",
"strict_answer_enforced": false,
"source": "known",
"score_metric": null,
"score": null,
"latency_ms": 17,
"input_tokens": 0,
"output_tokens": 0
}
Do not send organization, workspace, or AnswerSet IDs. The Question Key resolves them server-side.
Side-effect warning: Approved Automatic ExecutionSet connections can make Question Key requests side-effecting; a legacy beta workspace may also have an AnswerSet-attached graph until migration. Do not infer the execution path from the visual editor. Supply a UUID Idempotency-Key for the same logical attempt and inspect recorded action evidence before retrying uncertain delivery. Independent Flows and Flow Keys use a separate intended API. See action authorization and Flow Studio.
Knowledge
Knowledge management includes direct creation plus list/search/filter/edit operations exposed by the console.
Provider-grounded expansion:
POST /v1/answer-sets/{answer_set_id}/knowledge/generate
Request fields:
source:"approved_knowledge"(default) or"purpose"count: 1 through 50 (default 10)- optional
label - optional
prompt
approved_knowledge mode requires reviewed Knowledge, including reviewed items in the selected label if a label is specified. purpose mode can generate unverified drafts without an approved anchor; drafts are not trusted policy and must be reviewed before publication.
Auto Seed
GET /v1/answer-sets/{answer_set_id}/auto-seed
PUT /v1/answer-sets/{answer_set_id}/auto-seed
Auto Seed is currently supported for text AnswerSets.
Policy fields include enabled, min_knowledge_match, min_purpose_relevance, seeds_per_gap, and daily_seed_limit.
GovernanceSets
GET /v1/governance-sets
POST /v1/governance-sets
POST /v1/governance-sets/draft
POST /v1/governance-sets/evaluate
GET /v1/governance-sets/{governance_set_id}
PUT /v1/governance-sets/{governance_set_id}
PATCH /v1/governance-sets/{governance_set_id}
DELETE /v1/governance-sets/{governance_set_id}
GET /v1/answer-sets/{answer_set_id}/governance-sets
PUT /v1/answer-sets/{answer_set_id}/governance-sets
GovernanceSet assignment is explicit per AnswerSet.
Question Keys
GET /v1/answer-sets/{answer_set_id}/question-keys
POST /v1/answer-sets/{answer_set_id}/question-keys
POST /v1/answer-sets/{answer_set_id}/question-keys/{key_id}/revoke
The raw Question Key is returned only when it is issued.
Learning proposals
POST /v1/answer-sets/{answer_set_id}/proposals/{proposal_id}/approve
POST /v1/answer-sets/{answer_set_id}/proposals/{proposal_id}/reject
Approved proposals create revisioned behavior changes.
Portability
GET /v1/answer-sets/{answer_set_id}/export
POST /v1/answer-set-imports
Portable bundles use:
{
"api_version": "lakeshark.dev/v1alpha1",
"kind": "AnswerSet"
}
Exports intentionally omit credentials, Question Keys, tenant routing identifiers, runtime metrics, and pending proposals.
Independent Flow orchestration
Independent Flows are a separate top-level LakeShark product. An AnswerSet does not need a Flow, and Question Keys do not grant general Flow execution rights. Some beta workspaces may retain legacy AnswerSet-attached graph behavior during migration; confirm the actual deployed behavior before relying on it. See Flow Studio and its API rollout boundary.
Older AnswerSet-attached graph endpoints may remain in beta for compatibility. They do not constitute the independent Flow service. New workflows belong to the top-level Flow Studio; the planned Flow Key endpoint is not considered generally available until deployed and independently verified.