Skip to main content
POST
/
v1
/
metric
/
policies
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 metricPolicy = await client.metricPolicy.create({
  metrics: [{ id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e' }],
  name: 'Evaluate all inbound calls',
});

console.log(metricPolicy.data);
{
  "data": {
    "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "name": "<string>",
    "type": "SYSTEM",
    "status": "ACTIVE",
    "conditions": [
      {
        "conditions": [
          {
            "conditionType": "AGENT",
            "conditionKey": "<string>",
            "conditionOperator": "EQUALS",
            "conditionValue": "<string>"
          }
        ]
      }
    ],
    "metrics": [
      {
        "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
      }
    ],
    "createdAt": "<string>",
    "updatedAt": "<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 policy

name
string
required

Name of the metric policy

Minimum string length: 1
Example:

"Evaluate all inbound calls"

metrics
object[]
required

Metric definitions to collect when this policy matches

Minimum array length: 1
status
enum<string>
default:ACTIVE

Status of the policy (default: ACTIVE)

Available options:
ACTIVE,
INACTIVE
Example:

"ACTIVE"

conditions
object[]

Condition groups. Omit to match all calls.

Response

The created metric policy

data
object
required

A metric policy defining when metrics should be collected