GET
/
projects
/
{projectId}
/
testsets
import Scorecard from 'scorecard-ai';

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

async function main() {
  // Automatically fetches more pages as needed.
  for await (const testset of client.testsets.list('314')) {
    console.log(testset.id);
  }
}

main();
{
  "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"
        ],
        "labels": [
          "idealAnswer"
        ],
        "metadata": [
          "provenance",
          "geo"
        ]
      }
    }
  ],
  "nextCursor": "247",
  "hasMore": true
}

Authorizations

Authorization
string
header
required

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

Path Parameters

projectId
string
required

The ID of the Project.

Example:

"314"

Query Parameters

limit
integer
default:20

Maximum number of items to return (1-100). Use with cursor for pagination through large sets.

Required range: x > 0
Example:

20

cursor
string

Cursor for pagination. Pass the nextCursor from the previous response to get the next page of results.

Example:

"123"

Response

200
application/json
Successfully retrieved list of Testsets.
data
object[]
required

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/label). 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.

nextCursor
string | null
required
hasMore
boolean
required
total
integer
Required range: x >= 0