Testcases
Create multiple Testcases
Create multiple Testcases in the specified Testset.
POST
/
testsets
/
{testsetId}
/
testcases
JavaScript
import Scorecard from 'scorecard-ai';
const client = new Scorecard({
apiKey: process.env['SCORECARD_API_KEY'], // This is the default and can be omitted
});
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);import os
from scorecard_ai import Scorecard
client = Scorecard(
api_key=os.environ.get("SCORECARD_API_KEY"), # This is the default and can be omitted
)
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)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api2.scorecard.io/api/v2/testsets/{testsetId}/testcases"
payload := strings.NewReader("{\n \"items\": [\n {\n \"jsonData\": {\n \"question\": \"What is the capital of France?\",\n \"idealAnswer\": \"Paris\",\n \"provenance\": \"hand_curated\"\n }\n },\n {\n \"jsonData\": {\n \"question\": \"What is the largest planet in our solar system?\",\n \"idealAnswer\": \"Jupiter\",\n \"provenance\": \"synthetic\"\n }\n },\n {\n \"jsonData\": {\n \"question\": \"How many planets are in our solar system?\",\n \"idealAnswer\": 8,\n \"provenance\": \"user_feedback\"\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}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"
}
}
]
}'{
"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"
}
]
}
]
}{
"code": "UNAUTHORIZED",
"message": "Invalid or missing authentication token",
"details": {}
}{
"code": "INTERNAL_ERROR",
"message": "An unexpected error occurred while processing your request.",
"details": {}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The ID of the Testset to add the Testcases to.
Example:
"246"
Body
application/json
Testcases to create (max 100).
Required array length:
1 - 100 elementsShow child attributes
Show child attributes
Response
Testcases created successfully
Show child attributes
Show child attributes
Was this page helpful?
⌘I
JavaScript
import Scorecard from 'scorecard-ai';
const client = new Scorecard({
apiKey: process.env['SCORECARD_API_KEY'], // This is the default and can be omitted
});
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);import os
from scorecard_ai import Scorecard
client = Scorecard(
api_key=os.environ.get("SCORECARD_API_KEY"), # This is the default and can be omitted
)
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)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api2.scorecard.io/api/v2/testsets/{testsetId}/testcases"
payload := strings.NewReader("{\n \"items\": [\n {\n \"jsonData\": {\n \"question\": \"What is the capital of France?\",\n \"idealAnswer\": \"Paris\",\n \"provenance\": \"hand_curated\"\n }\n },\n {\n \"jsonData\": {\n \"question\": \"What is the largest planet in our solar system?\",\n \"idealAnswer\": \"Jupiter\",\n \"provenance\": \"synthetic\"\n }\n },\n {\n \"jsonData\": {\n \"question\": \"How many planets are in our solar system?\",\n \"idealAnswer\": 8,\n \"provenance\": \"user_feedback\"\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}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"
}
}
]
}'{
"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"
}
]
}
]
}{
"code": "UNAUTHORIZED",
"message": "Invalid or missing authentication token",
"details": {}
}{
"code": "INTERNAL_ERROR",
"message": "An unexpected error occurred while processing your request.",
"details": {}
}