Skip to content

feat(api): add API endpoints for survey response answers #179

@ericfitz

Description

@ericfitz

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

  1. Add endpoints to OpenAPI spec (api-schema/tmi-openapi.json)
  2. Define response schemas for answer listings
  3. Regenerate API code (make generate-api)
  4. Implement handlers using existing SurveyAnswerStore interface
  5. Respect existing authorization (same access rules as the parent survey response)
  6. Add unit and integration tests

Dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiAPI design and implementation

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions