> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getaftercare.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Evaluate Data Quality

> Evaluates the quality of survey responses for potential issues



## OpenAPI

````yaml POST /api/v1/data-quality
openapi: 3.0.0
info:
  title: Followup Generation API
  version: 1.0.0
  description: API for generating followup questions based on survey responses
  contact:
    name: API Support
    email: justin@getaftercare.com
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
servers:
  - url: https://surveys.getaftercare.com
    description: Production server
  - url: https://staging.aftercareai.com
    description: Staging server
security:
  - ApiKeyAuth: []
tags:
  - name: Followups
    description: Operations related to followup question generation
  - name: Data Quality
    description: Operations related to response data quality evaluation
  - name: Coding
    description: Operations related to coding survey responses
paths:
  /api/v1/data-quality:
    post:
      tags:
        - Data Quality
      summary: Evaluate survey response quality
      description: Evaluates the quality of survey responses for potential issues
      operationId: evaluateDataQuality
      parameters:
        - $ref: '#/components/parameters/X-Request-Encoding'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DataQualityRequest'
      responses:
        '200':
          description: Successfully evaluated survey quality
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DataQualityResponse'
              example:
                numIssues: 1
                qualityScore: 30
                demeritScore: 70
                evaluations:
                  - surveyEntry:
                      question: How satisfied were you with our service?
                      answer: I really love playing tennis with my friends on Fridays
                    numIssues: 1
                    qualityScore: 30
                    demeritScore: 70
                    qualityIssueChecks:
                      - type: Irrelevant
                        score: 10
                        isIssue: true
                      - type: Nonsensical
                        score: 80
                        isIssue: true
                      - type: Incomplete
                        score: 60
                        isIssue: false
                      - type: Low Effort
                        score: 95
                        isIssue: true
                      - type: LLM Generated
                        score: 80
                        isIssue: false
                      - type: Self Duplicated
                        score: 30
                        isIssue: false
                      - type: Shared Duplicate
                        score: 30
                        isIssue: false
                aftercareResponseIdentifier: 12345
        '400':
          description: Bad request - invalid input parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                code: INVALID_REQUEST
                message: Invalid request parameters
                details:
                  question: Question is required
        '403':
          description: Forbidden - Missing or invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                code: INVALID_API_KEY
                message: Invalid or missing API key
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                code: NOT_FOUND
                message: Requested resource not found
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                code: INTERNAL_ERROR
                message: An unexpected error occurred
        '504':
          description: Gateway timeout
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                code: GATEWAY_TIMEOUT
                message: The request timed out
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: JavaScript
          source: |-
            const response = await api.quality.evaluate({
              surveyName: 'Customer Satisfaction',
              surveyEntries: [{
                question: 'How satisfied are you?',
                answer: 'I really love playing tennis with my friends on Fridays'
              }]
            });
        - lang: Python
          source: |-
            response = api.quality.evaluate(
                survey_name='Customer Satisfaction',
                survey_entries=[{
                    'question': 'How satisfied are you?',
                    'answer': 'I really love playing tennis with my friends on Fridays'
                }]
            )
components:
  parameters:
    X-Request-Encoding:
      in: header
      name: X-Request-Encoding
      schema:
        type: string
        enum:
          - unicode
          - html
        default: unicode
      required: false
      description: >-
        Specifies the encoding format of the request data. Use `html` if you are
        sending data that HTML entity encodes non-ASCII characters.
  schemas:
    DataQualityRequest:
      type: object
      required:
        - surveyEntries
      properties:
        surveyName:
          type: string
          description: The name of the survey as it will appear in the Aftercare platform
        surveyDescription:
          type: string
          description: >-
            A description of the survey purpose and background.


            It will be used to give the AI more context around specific aspects
            of the survey (e.g. brand/product names, movie names, etc.)
        surveyEntries:
          type: array
          description: >-
            The collection of question-answer pairs to evaluate.


            If a respondent does not answer a question, DO NOT include that
            question in the surveyEntries array.
          items:
            $ref: '#/components/schemas/SurveyEntry'
        surveyIdentifier:
          type: string
          description: >-
            Optional unique identifier for the survey.


            Aftercare will use this to build a data model to associate questions
            and answers with the survey.
        responseIdentifier:
          type: string
          description: >-
            Optional unique identifier for a respondent's entire response to a
            survey.


            Aftercare will use this to build a data model tie together questions
            and answer pairs for a single response.
        aftercareResponseIdentifier:
          type: number
          description: >-
            Optional unique identifier for the survey response. If not provided,
            Aftercare will generate one.


            This identifier is useful for tracking survey responses that are
            submitted in multiple parts or over time.


            If both a responseIdentifier and aftercareResponseIdentifier are
            provided, Aftercare will use the aftercareResponseIdentifier.
        qualityIssues:
          type: array
          items:
            $ref: '#/components/schemas/QualityIssueType'
          description: >-
            Optional array of specific quality issues to evaluate. If not
            provided, all applicable quality issues will be checked.
        detectionMode:
          $ref: '#/components/schemas/QualityDetectionMode'
    DataQualityResponse:
      type: object
      required:
        - numIssues
        - qualityScore
        - demeritScore
        - evaluations
        - aftercareResponseIdentifier
      properties:
        numIssues:
          type: integer
          description: Number of quality issues detected across all survey entries
          minimum: 0
        hasIssues:
          type: boolean
          description: If Aftercare has detected any quality issues for this response
        qualityScore:
          type: number
          description: >-
            A score between 0 and 100 that represents the overall quality of the
            survey response. (Deprecated: use demeritScore instead)
          minimum: 0
          maximum: 100
        demeritScore:
          type: number
          description: >-
            A score between 0 and 100 that represents the overall quality of the
            survey response.


            The score is an average of the quality scores across all survey
            entries.


            The higher the score, the greater the likelihood and severity of
            data quality issues.
          minimum: 0
          maximum: 100
        evaluations:
          type: array
          items:
            $ref: '#/components/schemas/SurveyEntryEvaluation'
        aftercareResponseIdentifier:
          type: number
          description: Unique identifier for the survey response generated by Aftercare
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: Error code
          example: INVALID_REQUEST
        message:
          type: string
          description: Error message
          example: Invalid request parameters
        details:
          type: object
          description: Additional error details
          example:
            question: Question is required
    SurveyEntry:
      type: object
      required:
        - question
        - answer
      properties:
        question:
          type: string
          description: The question that was asked to the respondent
        questionContext:
          type: string
          description: >-
            A description of what you are trying to learn from the respondent
            for this question
        answer:
          type: string
          description: The answer to the question provided by the respondent
        questionIdentifier:
          type: string
          description: >-
            Optional unique identifier for the question.


            Aftercare will use this to build a data model to track questions
            across a survey
        parentQuestionIdentifier:
          type: string
          description: Optional identifier of a previous question in a follow-up thread
        keyEvents:
          type: array
          items:
            $ref: '#/components/schemas/SurveyEntryKeyStroke'
          description: An optional array of key strokes.
        pasteEvents:
          type: array
          items:
            $ref: '#/components/schemas/SurveyEntryPaste'
          description: An optional array of paste events.
        honeypotPhrase:
          type: string
          description: >-
            Optional string. If provided, Aftercare will check if the response
            contains any honey pot words.
    QualityIssueType:
      type: string
      enum:
        - Nonsensical
        - Irrelevant
        - Low Effort
        - LLM Generated
        - Repeated Answers
        - Duplicate Answers
      description: >-
        Types of quality issues that can be detected in survey responses.


        * `Nonsensical` - Response lacks logical meaning or sense. Likely
        gibberish.

        * `Irrelevant` - Response does not address the question.

        * `Low Effort` - Respondent did not put in much effort to answer the
        question. Lacks detail or concrete examples.

        * `LLM Generated` - Response appears to be generated by AI.

        * `Self Duplicated` - Responses from the same respondent contain
        duplicated content across multiple answers. Only evaluated when multiple
        survey entries are provided or if a survey identifier and response
        identifier is provided.

        * `Shared Duplicate` - Responses contain duplicated content across
        different respondents for the same question. Only evaluated if survey
        identifiers and question identifiers are provided.
    QualityDetectionMode:
      type: string
      enum:
        - Responsiveness
        - Authenticity
        - Composite
      description: >-
        The mode in which Aftercare will evaluate the quality of the survey
        responses.


        * `Responsiveness` - Checks for poor responses

        * `Authenticity` - Checks for fraudulent responses

        * `Composite` - Checks for all quality issues


        If both a detectionMode and qualityIssues are provided, Aftercare will
        use the detection mode.
    SurveyEntryEvaluation:
      type: object
      required:
        - surveyEntry
        - numIssues
        - qualityScore
        - demeritScore
        - qualityIssueChecks
      properties:
        surveyEntry:
          $ref: '#/components/schemas/SurveyEntry'
        numIssues:
          type: integer
          description: Number of quality issues detected
          minimum: 0
        hasIssues:
          type: boolean
          description: If Aftercare has detected any quality issues for this survey entry
        qualityScore:
          type: number
          description: >-
            A score between 0 and 100 that represents the overall quality of the
            individual survey entry. (Deprecated: use demeritScore instead)
          minimum: 0
          maximum: 100
          deprecated: true
        demeritScore:
          type: number
          description: >-
            A score between 0 and 100 that represents the overall quality of the
            individual survey entry.


            The score is a weighted average of the quality issue scores.


            The higher the score, the greater the likelihood and severity of
            data quality issues.
          minimum: 0
          maximum: 100
        qualityIssueChecks:
          type: array
          items:
            $ref: '#/components/schemas/QualityIssueCheck'
    SurveyEntryKeyStroke:
      type: object
      required:
        - k
        - t
        - ht
        - c
      properties:
        k:
          type: string
          description: Key value (e.g., "a", "Enter")
        t:
          type: number
          description: Keydown timestamp (from performance.now())
        ht:
          type: number
          description: Hold time of the key
        c:
          type: string
          description: Physical key code (e.g., "KeyA", "Enter")
    SurveyEntryPaste:
      type: object
      required:
        - t
        - c
      properties:
        t:
          type: number
          description: Timestamp of the paste event
        c:
          type: string
          description: Clipboard content that was pasted
    QualityIssueCheck:
      type: object
      required:
        - type
        - score
        - isIssue
      properties:
        type:
          $ref: '#/components/schemas/QualityIssueType'
        score:
          type: number
          description: >-
            Score between 0-100 for this quality issue.


            The higher the score, the greater the likelihood and severity of the
            quality issue.
          minimum: 0
          maximum: 100
        isIssue:
          type: boolean
          description: Indicates if this issue was detected
        evidence:
          type: string
          description: ' An optional string, evidence provides the reason for the quality issue score.'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-Aftercare-Key
      description: API key for authentication

````