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

# Create Test Cases For Dataset

> Adds items/test cases to a dataset. If the dataset does not exist, it will be created.
Returns the IDs of the created items/test cases.

Returns:
    List[int]: List of IDs of the created items/test cases.

<RequestExample>
  ```python python theme={null}
  p = Parea(api_key="PAREA_API_KEY")  # replace with your API key

  data = [
      {"problem": "1+2", "target": 3, "tags": ["easy"]},
      {"problem": "Solve the differential equation dy/dx = 3y.", "target": "y = c * e^(3x)", "tags": ["hard"]}
  ]

  # this will add the new test cases to the existing "Math problems" dataset.
  # New test cases must have the same columns as the existing dataset.
  p.add_test_cases(data, name="Math problems")
  ```

  ```typescript typescript theme={null}
  const p = new Parea("PAREA_API_KEY"); // replace with your API key

  const data = [
      { problem: '1+2', target: 3, tags: ['easy'] },
      { problem: 'Solve the differential equation dy/dx = 3y.', target: 'y = c * e^(3x)', tags: ['hard'] },
  ];

  // this will add the new test cases to the existing "Math problems" dataset.
  // New test cases must have the same columns as the existing dataset.
  p.addTestCases(data, 'Math problems');
  ```

  ```bash curl theme={null}
  curl --location 'https://parea-ai-backend-us-9ac16cdbc7a7b006.onporter.run/api/parea/v1/testcases' \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: PAREA_API_KEY' \
  --data '{
    "name": "Math problems",
    "test_cases": [
      {
        "inputs": {
          "problem": "1+2"
        },
        "tags": [
          "easy"
        ],
        "target": "3"
      }
    ]
  }'
  ```
</RequestExample>


## OpenAPI

````yaml post /api/parea/v1/testcases
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers: []
security: []
paths:
  /api/parea/v1/testcases:
    post:
      summary: Create Test Cases For Dataset
      description: >-
        Adds items/test cases to a dataset. If the dataset does not exist, it
        will be created.

        Returns the IDs of the created items/test cases.


        Returns:
            List[int]: List of IDs of the created items/test cases.
      operationId: create_test_cases_for_dataset_api_parea_v1_testcases_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTestCasesSchema'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                items:
                  type: integer
                type: array
                title: >-
                  Response Create Test Cases For Dataset Api Parea V1 Testcases
                  Post
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
        - APIKeyHeader: []
        - APIKeyHeader: []
components:
  schemas:
    CreateTestCasesSchema:
      properties:
        id:
          anyOf:
            - type: integer
            - type: 'null'
          title: Id
          description: >-
            ID for the dataset/test case collection. Either ID or name is
            required to identify the dataset.
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          description: >-
            Name for the dataset/test case collection. Either ID or name is
            required to identify the dataset.
        test_cases:
          items:
            $ref: '#/components/schemas/TestCaseSchema'
          type: array
          title: Test Cases
          description: List of items which should be added to dataset.
      type: object
      required:
        - test_cases
      title: CreateTestCasesSchema
      examples:
        - name: Hello World Programs
          test_cases:
            - inputs:
                framework: fastapi
                language: python
              tags:
                - easy
              target: a good program here
        - id: 5000
          test_cases:
            - inputs:
                framework: fastapi
                language: python
              tags:
                - easy
              target: a good program here
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    TestCaseSchema:
      properties:
        inputs:
          additionalProperties:
            type: string
          type: object
          title: Inputs
          description: >-
            Dictionary mapping input names to values. Input names correspond to
            the column names of the test case collection.
        target:
          anyOf:
            - type: string
            - type: 'null'
          title: Target
          description: Optional target/ground truth value for the test case/inputs
        tags:
          items:
            type: string
          type: array
          title: Tags
          description: List of tags associated with the test case
          default: []
      type: object
      required:
        - inputs
      title: TestCaseSchema
      examples:
        - inputs:
            framework: fastapi
            language: python
          tags:
            - easy
          target: a good program here
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: x-user-id

````