POST
/
testsets
/
{testsetId}
/
testcases
import Scorecard from 'scorecard-ai';

const client = new Scorecard({
  apiKey: process.env['SCORECARD_API_KEY'], // This is the default and can be omitted
});

async function main() {
  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);
}

main();
{
  "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?"
      },
      "labels": {
        "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?"
      },
      "labels": {
        "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?"
      },
      "labels": {
        "idealAnswer": 8
      },
      "validationErrors": [
        {
          "path": "/data/idealAnswer",
          "message": "Expected string, received number"
        }
      ]
    }
  ]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

testsetId
string
required

The ID of the Testset to add the Testcases to.

Example:

"246"

Body

application/json

Response

201
application/json

Testcases created successfully

The response is of type object.