Skip to main content
POST
/
v1
/
metric
/
definitions
JavaScript
import Roark from '@roarkanalytics/sdk';

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

const response = await client.metric.createDefinition({
  analysisPackageId: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
  name: 'Customer Satisfaction',
  outputType: 'BOOLEAN',
});

console.log(response.data);
{
  "data": {
    "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "metricId": "<string>",
    "name": "<string>",
    "description": "<string>",
    "type": "COUNT",
    "scope": "GLOBAL",
    "supportedContexts": [
      "CALL"
    ],
    "unit": {
      "name": "<string>",
      "symbol": "<string>"
    }
  }
}

Authorizations

Authorization
string
header
required

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

Body

application/json

Input for creating a new metric definition

name
string
required

Name of the metric

Required string length: 1 - 100
Example:

"Customer Satisfaction"

outputType
enum<string>
required

Type of value this metric produces

Available options:
COUNT,
NUMERIC,
BOOLEAN,
SCALE,
TEXT,
CLASSIFICATION,
OFFSET
Example:

"BOOLEAN"

analysisPackageId
string<uuid>
required

ID of the analysis package to add this metric to

metricId
string

Unique identifier for the metric (e.g. "customer_satisfaction"). Auto-generated from name if not provided.

Required string length: 1 - 50
Example:

"customer_satisfaction"

scope
enum<string>
default:GLOBAL

Whether metric is global or per-participant (default: GLOBAL)

Available options:
GLOBAL,
PER_PARTICIPANT
Example:

"GLOBAL"

participantRole
enum<string>

Participant role to evaluate. Required when scope is PER_PARTICIPANT.

Available options:
AGENT,
CUSTOMER,
SIMULATED_CUSTOMER,
BACKGROUND_SPEAKER
supportedContexts
enum<string>[]

Which levels this metric can produce values at (default: ["CALL"])

Minimum array length: 1
Available options:
CALL,
SEGMENT,
TURN
Example:
["CALL"]
llmPrompt
string

LLM prompt/criteria for evaluating this metric. Used to instruct the model on how to score. Required for BOOLEAN, NUMERIC, TEXT, and SCALE types.

Maximum string length: 2000
Example:

"Evaluate whether the customer expressed satisfaction with the service provided."

booleanTrueLabel
string

Label for the true/positive case (only for BOOLEAN type)

Example:

"Satisfied"

booleanFalseLabel
string

Label for the false/negative case (only for BOOLEAN type)

Example:

"Not Satisfied"

scaleMin
integer

Minimum value for scale. Required for SCALE type.

Required range: 0 <= x <= 100
Example:

1

scaleMax
integer

Maximum value for scale. Required for SCALE type.

Required range: 0 <= x <= 100
Example:

5

scaleLabels
object[]

Labels for scale ranges (only for SCALE type)

classificationOptions
object[]

Options for classification. Required for CLASSIFICATION type.

Minimum array length: 1
maxClassifications
integer

Maximum number of classifications that can be selected (only for CLASSIFICATION type)

Required range: x >= 1

Response

The created metric definition

data
object
required

Metric definition data