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

# Credit Calculation

> API endpoint for calculating the required number of credits for a respondent.

If you need to estimate the number of credits required to add a respondent, you can use this endpoint.

<Note>This endpoint is optional and serves informational purposes only. It provides an estimate of the credits required based on the selected quality scores.</Note>


## OpenAPI

````yaml POST /v2/creditCalculation
openapi: 3.0.1
info:
  title: API Documentation
  description: API Documentation for Redem 3.0
  version: 1.0.0
  license:
    name: MIT
servers:
  - url: https://api.redem.io
security:
  - apiKeyAuth: []
tags:
  - name: Survey
    description: Survey management
  - name: Respondent
    description: Respondent management
paths:
  /v2/creditCalculation:
    post:
      tags:
        - Respondent
      summary: Calculate the maximum number of credits needed for a respondent
      description: >-
        API endpoint for calculating the required number of credits for a
        respondent.
      operationId: creditCalculationV3
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreditCalculationRequest'
            example:
              OESDataPoints: 2
              GQSAnswers: 35
              TSDataPoints: 2
              CHSAnswers: 25
              BASDataPoints: 2
      responses:
        '200':
          description: >-
            When a request is successfully processed, the API returns a 200 OK
            status code along with the expected data.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    description: >-
                      A variable indicating whether the **operation was
                      successful**.
                    enum:
                      - true
                      - false
                  message:
                    type: string
                    description: >-
                      A variable that **human-readable message** providing
                      additional context or confirmation of the requested
                      action.
                  results:
                    type: object
                    description: >-
                      This object serves as a **container to hold the results
                      for the requested data**, encapsulating all relevant
                      information and outputs in a structured format.
                    properties:
                      creditCalculation:
                        description: >-
                          This variable **represents the detailed breakdown of
                          the number of credits** calculated for a respondent.
                        type: object
                        properties:
                          totalCredits:
                            type: number
                            description: >-
                              This variable **represents the total number of
                              credits** calculated for a respondent.
                          calculationBreakdown:
                            $ref: '#/components/schemas/CalculationBreakdown'
                            description: >-
                              This variable **represents the detailed breakdown
                              of the number of credits** calculated for a
                              respondent.
              example:
                success: true
                message: Credit calculation successfully retrieved
                results:
                  creditCalculation:
                    totalCredits: 12
                    calculationBreakdown:
                      OES:
                        credits: 4
                        dataPoints: 2
                      GQS:
                        credits: 3
                        answers: 35
                      TS:
                        credits: 1
                        dataPoints: 2
                      CHS:
                        credits: 4
                        answers: 25
                      BAS:
                        credits: 4
                        dataPoints: 2
        '400':
          description: >-
            When a request fails due to invalid input or other errors, the API
            returns a 400 Bad Request status code. The response includes a
            descriptive `message` explaining the issue and an `error` object
            containing additional details to aid in diagnosing and resolving the
            problem.
          content:
            application/json:
              schema:
                oneOf:
                  - title: Validation Error
                    description: >-
                      Indicating a validation failure, the response includes a
                      `message` field specifying the issue and an `errors`
                      object listing the missing or incorrect fields to help
                      clients resolve them. 

                       **⭕ Note:** Refer to the [response structure](/api-reference/api-specifications/response-structure) for the format of the error response.
                    type: object
                  - title: Failed to calculate credits
                    description: >-
                      This error occurs when the **system fails to calculate the
                      credits**. 

                       **⭕ Note:** Refer to the [response structure](/api-reference/api-specifications/response-structure) for the format of the error response.
                    type: object
              examples:
                Validation Error:
                  value:
                    success: false
                    message: Validation Error
                    errors:
                      '0': '"OESDataPoints" is required'
                      '1': '"GQSAnswers" is required'
                      '2': '"TSDataPoints" is required'
                      '3': '"CHSAnswers" is required'
                      '4': '"BASDataPoints" is required'
                Failed to calculate credits:
                  value:
                    success: false
                    message: Failed to calculate credits
                    errors: {}
components:
  schemas:
    CreditCalculationRequest:
      description: >-
        Request body for calculating the maximum number of credits needed for a
        respondent
      required:
        - OESDataPoints
        - GQSAnswers
        - TSDataPoints
        - CHSAnswers
        - BASDataPoints
      type: object
      properties:
        OESDataPoints:
          type: number
          description: >-
            **The number of data points** to be used for the Open-Ended Score
            (OES). 
             **⭕ Note:** If no OES data points are available, this value can be set to `0`.
        GQSAnswers:
          type: number
          description: >-
            **The number of data points** to be used for the Grid-Question Score
            (GQS). 
             **⭕ Note:** If no GQS answers are available, this value can be set to `0`.
        TSDataPoints:
          type: number
          description: |-
            **The number of data points** to be used for the Time Score (TS). 
             **⭕ Note:** If no TS data points are available, this value can be set to `0`.
        CHSAnswers:
          type: number
          description: >-
            **The number of data points** to be used for the Coherence Score
            (CHS). 
             **⭕ Note:** If no CHS answers are available, this value can be set to `0`.
        BASDataPoints:
          type: number
          description: >-
            **The number of data points** to be used for the
            Behavioral-Analytics Score (BAS). 
             **⭕ Note:** If no BAS data points are available, this value can be set to `0`.
    CalculationBreakdown:
      description: Detailed breakdown of the number of credits estimated for a respondent
      type: object
      properties:
        OES:
          type: object
          description: >-
            Detailed breakdown of the number of OES credits estimated for a
            respondent
          properties:
            credits:
              type: number
              description: Number of OES credits estimated for a respondent
            dataPoints:
              type: number
              description: Number of OES data points estimated for a respondent
        GQS:
          type: object
          description: >-
            Detailed breakdown of the number of GQS credits estimated for a
            respondent
          properties:
            credits:
              type: number
              description: Number of GQS credits estimated for a respondent
            answers:
              type: number
              description: Number of GQS answers estimated for a respondent
        TS:
          type: object
          description: >-
            Detailed breakdown of the number of TS credits estimated for a
            respondent
          properties:
            credits:
              type: number
              description: Number of TS credits estimated for a respondent
            dataPoints:
              type: number
              description: Number of TS data points estimated for a respondent
        CHS:
          type: object
          description: >-
            Detailed breakdown of the number of CHS credits estimated for a
            respondent
          properties:
            credits:
              type: number
              description: Number of CHS credits estimated for a respondent
            answers:
              type: number
              description: Number of CHS interviews estimated for a respondent
        BAS:
          type: object
          description: >-
            Detailed breakdown of the number of BAS credits estimated for a
            respondent
          properties:
            credits:
              type: number
              description: Number of BAS credits estimated for a respondent
            answers:
              type: number
              description: Number of BAS data points estimated for a respondent
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: api-key

````