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

# List Testcases in Testset

> Retrieve a paginated list of Testcases belonging to a Testset.



## OpenAPI

````yaml get /testsets/{testsetId}/testcases
openapi: 3.1.0
info:
  title: Scorecard API
  description: REST API for Scorecard
  version: 1.0.0
servers:
  - url: https://api2.scorecard.io/api/v2
security:
  - ApiKeyAuth: []
paths:
  /testsets/{testsetId}/testcases:
    get:
      summary: List Testcases in Testset
      description: Retrieve a paginated list of Testcases belonging to a Testset.
      operationId: listTestcases
      parameters:
        - in: path
          name: testsetId
          description: The ID of the Testset to list Testcases from.
          schema:
            type: string
            example: '246'
          required: true
        - in: query
          name: limit
          description: >-
            Maximum number of items to return (1-100). Use with `cursor` for
            pagination through large sets.
          schema:
            type: integer
            exclusiveMinimum: 0
            default: 20
            example: 20
        - in: query
          name: cursor
          description: >-
            Cursor for pagination. Pass the `nextCursor` from the previous
            response to get the next page of results.
          schema:
            type: string
            example: '123'
      responses:
        '200':
          description: Successfully retrieved list of Testcases.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Testcase'
                  nextCursor:
                    type:
                      - string
                      - 'null'
                  hasMore:
                    type: boolean
                  total:
                    type: integer
                    minimum: 0
                required:
                  - data
                  - nextCursor
                  - hasMore
              examples:
                Testcase list with pagination:
                  value:
                    data:
                      - id: '123'
                        testsetId: '246'
                        jsonData:
                          question: What is the capital of France?
                          idealAnswer: Paris
                          provenance: hand_curated
                        inputs:
                          question: What is the capital of France?
                        expected:
                          idealAnswer: Paris
                      - id: '124'
                        testsetId: '246'
                        jsonData:
                          question: What is the largest planet in our solar system?
                          idealAnswer: Jupiter
                          provenance: synthetic
                        inputs:
                          question: What is the largest planet in our solar system?
                        expected:
                          idealAnswer: Jupiter
                      - id: '125'
                        testsetId: '246'
                        jsonData:
                          question: What is the deepest ocean on Earth?
                          provenance: user_feedback
                        inputs:
                          question: What is the deepest ocean on Earth?
                        expected: {}
                        validationErrors:
                          - path: /data
                            message: Required field 'idealAnswer' is missing
                    nextCursor: '126'
                    hasMore: true
                  summary: Testcase list with pagination
                  description: Example response showing a paginated list of Testcases.
        '401':
          $ref: '#/components/responses/UnauthenticatedError'
        '500':
          $ref: '#/components/responses/ServiceError'
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Scorecard from 'scorecard-ai';

            const client = new Scorecard({
              apiKey: 'My API Key',
            });

            // Automatically fetches more pages as needed.
            for await (const testcase of client.testcases.list('246')) {
              console.log(testcase.id);
            }
        - lang: Python
          source: |-
            from scorecard_ai import Scorecard

            client = Scorecard(
                api_key="My API Key",
            )
            page = client.testcases.list(
                testset_id="246",
            )
            page = page.data[0]
            print(page.id)
        - lang: cURL
          source: >-
            curl https://api2.scorecard.io/api/v2/testsets/$TESTSET_ID/testcases
            \
                -H "Authorization: Bearer $SCORECARD_API_KEY"
components:
  schemas:
    Testcase:
      type: object
      properties:
        id:
          type: string
          description: The ID of the Testcase.
        testsetId:
          type: string
          description: The ID of the Testset this Testcase belongs to.
        jsonData:
          type: object
          additionalProperties: true
          description: >-
            The JSON data of the Testcase, which is validated against the
            Testset's schema.
        inputs:
          type: object
          additionalProperties: true
          description: >-
            Derived from data based on the Testset's fieldMapping. Contains all
            fields marked as inputs, including those with validation errors.
        expected:
          type: object
          additionalProperties: true
          description: >-
            Derived from data based on the Testset's fieldMapping. Contains all
            fields marked as expected outputs, including those with validation
            errors.
        validationErrors:
          type: array
          items:
            type: object
            properties:
              path:
                type: string
                description: JSON Pointer to the field with the validation error.
                example: /data/question
              message:
                type: string
                description: Human-readable error description.
                example: Required field missing
            required:
              - path
              - message
          description: >-
            Validation errors found in the Testcase data. If present, the
            Testcase doesn't fully conform to its Testset's schema.
      required:
        - id
        - testsetId
        - jsonData
        - inputs
        - expected
      description: >-
        A test case in the Scorecard system. Contains JSON data that is
        validated against the schema defined by its Testset.

        The `inputs` and `expected` fields are derived from the `data` field
        based on the Testset's `fieldMapping`, and include all mapped fields,
        including those with validation errors.

        Testcases are stored regardless of validation results, with any
        validation errors included in the `validationErrors` field.
    ApiError:
      type: object
      properties:
        code:
          type: string
        message:
          type: string
        details:
          type: object
          additionalProperties: true
          x-stainless-any: true
      required:
        - code
        - message
        - details
      description: An API error.
  responses:
    UnauthenticatedError:
      description: Error indicating that the request is not authenticated.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
          examples:
            Authentication failure:
              value:
                code: UNAUTHORIZED
                message: Invalid or missing authentication token
                details: {}
              summary: Authentication failure
              description: >-
                Error returned when authentication credentials are invalid or
                missing.
    ServiceError:
      description: >-
        An internal service error indicating an issue with the Scorecard
        service.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
          examples:
            Internal error:
              value:
                code: INTERNAL_ERROR
                message: An unexpected error occurred while processing your request.
                details: {}
              summary: Internal error
              description: Generic error when an unexpected internal issue occurs.
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: starts with ak_

````