> ## 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 Testsets in Project

> Retrieve a paginated list of Testsets belonging to a Project.



## OpenAPI

````yaml get /projects/{projectId}/testsets
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:
  /projects/{projectId}/testsets:
    get:
      summary: List Testsets in Project
      description: Retrieve a paginated list of Testsets belonging to a Project.
      operationId: listTestsets
      parameters:
        - in: path
          name: projectId
          description: The ID of the Project.
          schema:
            type: string
            example: '314'
          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 Testsets.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Testset'
                  nextCursor:
                    type:
                      - string
                      - 'null'
                  hasMore:
                    type: boolean
                  total:
                    type: integer
                    minimum: 0
                required:
                  - data
                  - nextCursor
                  - hasMore
              examples:
                Testset list with fields:
                  value:
                    data:
                      - id: '246'
                        name: Long Context Q&A
                        description: Testset for long context Q&A chatbot.
                        jsonSchema:
                          type: object
                          properties:
                            question:
                              type: string
                            idealAnswer:
                              type: string
                            provenance:
                              type: string
                            geo:
                              type: string
                        fieldMapping:
                          inputs:
                            - question
                          expected:
                            - idealAnswer
                          metadata:
                            - provenance
                            - geo
                    nextCursor: '247'
                    hasMore: true
                  summary: Testset list with fields
                  description: >-
                    Example response showing a paginated list of Testsets with
                    schema and field mapping details.
        '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 testset of client.testsets.list('314')) {
              console.log(testset.id);
            }
        - lang: Python
          source: |-
            from scorecard_ai import Scorecard

            client = Scorecard(
                api_key="My API Key",
            )
            page = client.testsets.list(
                project_id="314",
            )
            page = page.data[0]
            print(page.id)
        - lang: cURL
          source: >-
            curl https://api2.scorecard.io/api/v2/projects/$PROJECT_ID/testsets
            \
                -H "Authorization: Bearer $SCORECARD_API_KEY"
components:
  schemas:
    Testset:
      type: object
      properties:
        id:
          type: string
          description: The ID of the Testset.
        name:
          type: string
          description: The name of the Testset.
        description:
          type: string
          description: The description of the Testset.
        jsonSchema:
          type: object
          description: The JSON schema for each Testcase in the Testset.
          additionalProperties: true
        fieldMapping:
          type: object
          properties:
            inputs:
              type: array
              items:
                type: string
              description: Fields that represent inputs to the AI system.
            expected:
              type: array
              items:
                type: string
              description: Fields that represent expected outputs.
            metadata:
              type: array
              items:
                type: string
              description: Fields that are not inputs or expected outputs.
          required:
            - inputs
            - expected
            - metadata
          description: >-
            Maps top-level keys of the Testcase schema to their roles
            (input/expected output). Unmapped fields are treated as metadata.
      required:
        - id
        - name
        - description
        - jsonSchema
        - fieldMapping
      description: >-
        A collection of Testcases that share the same schema.

        Each Testset defines the structure of its Testcases through a JSON
        schema.

        The `fieldMapping` object maps top-level keys of the Testcase schema to
        their roles (input/expected output).

        Fields not mentioned in the `fieldMapping` during creation or update are
        treated as metadata.


        ## JSON Schema validation constraints supported:


        - **Required fields** - Fields listed in the schema's `required` array
        must be present in Testcases.

        - **Type validation** - Values must match the specified type (string,
        number, boolean, null, integer, object, array).

        - **Enum validation** - Values must be one of the options specified in
        the `enum` array.

        - **Object property validation** - Properties of objects must conform to
        their defined schemas.

        - **Array item validation** - Items in arrays must conform to the
        `items` schema.

        - **Logical composition** - Values must conform to at least one schema
        in the `anyOf` array.


        Testcases that fail validation will still be stored, but will include
        `validationErrors` detailing the issues.

        Extra fields in the Testcase data that are not in the schema will be
        stored but are ignored during validation.
    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_

````