> ## 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.

# Create multiple Testcases

> Create multiple Testcases in the specified Testset.



## OpenAPI

````yaml post /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:
    post:
      summary: Create multiple Testcases
      description: Create multiple Testcases in the specified Testset.
      operationId: createTestcases
      parameters:
        - in: path
          name: testsetId
          description: The ID of the Testset to add the Testcases to.
          schema:
            type: string
            example: '246'
          required: true
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                items:
                  type: array
                  items:
                    type: object
                    properties:
                      jsonData:
                        type: object
                        additionalProperties: true
                        description: >-
                          The JSON data of the Testcase, which is validated
                          against the Testset's schema.
                    required:
                      - jsonData
                  minItems: 1
                  maxItems: 100
                  description: Testcases to create (max 100).
              required:
                - items
            examples:
              Create multiple Testcases:
                value:
                  items:
                    - jsonData:
                        question: What is the capital of France?
                        idealAnswer: Paris
                        provenance: hand_curated
                    - jsonData:
                        question: What is the largest planet in our solar system?
                        idealAnswer: Jupiter
                        provenance: synthetic
                    - jsonData:
                        question: How many planets are in our solar system?
                        idealAnswer: 8
                        provenance: user_feedback
                summary: Create multiple Testcases
                description: Create multiple Testcases in a single request.
      responses:
        '201':
          description: Testcases created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      $ref: '#/components/schemas/Testcase'
                required:
                  - items
              examples:
                Created Testcases response:
                  value:
                    items:
                      - 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: How many planets are in our solar system?
                          idealAnswer: 8
                          provenance: user_feedback
                        inputs:
                          question: How many planets are in our solar system?
                        expected:
                          idealAnswer: 8
                        validationErrors:
                          - path: /data/idealAnswer
                            message: Expected string, received number
                  summary: Created Testcases
                  description: Example response showing successfully created 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',
            });

            const testcase = await client.testcases.create('246', {
              items: [
                {
                  jsonData: {
                    question: 'What is the capital of France?',
                    idealAnswer: 'Paris',
                    provenance: 'hand_curated',
                  },
                },
                {
                  jsonData: {
                    question: 'What is the largest planet in our solar system?',
                    idealAnswer: 'Jupiter',
                    provenance: 'synthetic',
                  },
                },
                {
                  jsonData: {
                    question: 'How many planets are in our solar system?',
                    idealAnswer: 8,
                    provenance: 'user_feedback',
                  },
                },
              ],
            });

            console.log(testcase.items);
        - lang: Python
          source: |-
            from scorecard_ai import Scorecard

            client = Scorecard(
                api_key="My API Key",
            )
            testcase = client.testcases.create(
                testset_id="246",
                items=[{
                    "json_data": {
                        "question": "What is the capital of France?",
                        "idealAnswer": "Paris",
                        "provenance": "hand_curated",
                    }
                }, {
                    "json_data": {
                        "question": "What is the largest planet in our solar system?",
                        "idealAnswer": "Jupiter",
                        "provenance": "synthetic",
                    }
                }, {
                    "json_data": {
                        "question": "How many planets are in our solar system?",
                        "idealAnswer": 8,
                        "provenance": "user_feedback",
                    }
                }],
            )
            print(testcase.items)
        - lang: cURL
          source: >-
            curl https://api2.scorecard.io/api/v2/testsets/$TESTSET_ID/testcases
            \
                -H 'Content-Type: application/json' \
                -H "Authorization: Bearer $SCORECARD_API_KEY" \
                -d '{
                      "items": [
                        {
                          "jsonData": {
                            "question": "bar",
                            "idealAnswer": "bar",
                            "provenance": "bar"
                          }
                        },
                        {
                          "jsonData": {
                            "question": "bar",
                            "idealAnswer": "bar",
                            "provenance": "bar"
                          }
                        },
                        {
                          "jsonData": {
                            "question": "bar",
                            "idealAnswer": "bar",
                            "provenance": "bar"
                          }
                        }
                      ]
                    }'
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_

````