PUT
/
records
/
{recordId}
/
scores
/
{metricConfigId}
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 score = await client.scores.upsert('a1b2c3d4-e5f6-7890-1234-567890abcdef', {
    recordId: '777',
    score: { value: true, reasoning: 'The response is correct' },
  });

  console.log(score.validationErrors);
}

main();
{
  "recordId": "777",
  "metricConfigId": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
  "score": {
    "value": true,
    "reasoning": "The response is correct"
  },
  "validationErrors": []
}

Authorizations

Authorization
string
header
required

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

Path Parameters

recordId
string
required

The ID of the Record.

Example:

"777"

metricConfigId
string
required

The ID of the MetricConfig.

Example:

"a1b2c3d4-e5f6-7890-1234-567890abcdef"

Body

application/json

Response

200
application/json

Score upserted successfully.

A Score represents the evaluation of a Record against a specific MetricConfig. The actual score is stored as flexible JSON. While any JSON is accepted, it is expected to conform to the output schema defined by the MetricConfig. Any discrepancies will be noted in the validationErrors field, but the Score will still be stored.