Summary
Add REST API endpoints for reading and querying extracted survey response answers from the survey_answers table.
Background
Issue #178 added the internal survey_answers table and SurveyAnswerStore interface, which extracts and stores structured answers on every response save. Currently this data is only accessible internally (e.g., by create_threat_model via GetFieldMappings). External API access would enable:
- Clients to display individual answers with question metadata
- Dashboards to query answers by field mapping
- Integrations to read structured answer data without parsing opaque
survey_json + answers blobs
Proposed Endpoints
| Method |
Path |
Description |
GET |
/intake/survey_responses/{id}/answers |
List extracted answers for a response |
GET |
/intake/survey_responses/{id}/answers/field_mappings |
List answers with mapsToTmField annotations, keyed by target field |
GET |
/triage/survey_responses/{id}/answers |
Same as above, for triage context |
GET |
/triage/survey_responses/{id}/answers/field_mappings |
Same as above, for triage context |
Requirements
- Add endpoints to OpenAPI spec (
api-schema/tmi-openapi.json)
- Define response schemas for answer listings
- Regenerate API code (
make generate-api)
- Implement handlers using existing
SurveyAnswerStore interface
- Respect existing authorization (same access rules as the parent survey response)
- Add unit and integration tests
Dependencies
Summary
Add REST API endpoints for reading and querying extracted survey response answers from the
survey_answerstable.Background
Issue #178 added the internal
survey_answerstable andSurveyAnswerStoreinterface, which extracts and stores structured answers on every response save. Currently this data is only accessible internally (e.g., bycreate_threat_modelviaGetFieldMappings). External API access would enable:survey_json+answersblobsProposed Endpoints
GET/intake/survey_responses/{id}/answersGET/intake/survey_responses/{id}/answers/field_mappingsmapsToTmFieldannotations, keyed by target fieldGET/triage/survey_responses/{id}/answersGET/triage/survey_responses/{id}/answers/field_mappingsRequirements
api-schema/tmi-openapi.json)make generate-api)SurveyAnswerStoreinterfaceDependencies
survey_answerstable andSurveyAnswerStoreinterface