Metrics API Code Samples

Selection of code samples that demonstrate the use of the Metrics API. Copy and edit these code samples to suit your needs.

When using the code samples, remember to replace:

  • {vanity_name} with your tenant name
  • {api_key} with your API key
  • {security_token} with a valid security token

These code samples may not include all available parameters and request body fields for each endpoint. For the endpoint's full request schema, see "Metrics V2" in API Reference.

Retrieve a list of metrics by analytic object

Use this sample request to retrieve all the metrics for a specific analytic object. Optionally, specify the query parameters type to only retrieve a specific metric type and with to retrieve more detailed information about each metric. Default is to return basic information.

Copy
cURL sample request: Retrieve a list of all simple metrics for Employee in tenant WFF_j1r~c7o
curl -X GET --url 'https://{vanity_name}.api.visier.io/v2alpha/data/model/analytic-objects/Employee/metrics?type=simple' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}' \
-H 'TargetTenantID:WFF_j1r~c7o'

The response returns the details of all simple metrics for the analytic object, including object names and descriptions.

Retrieve a list of metrics

Use this sample request to retrieve all the metrics in the specified project. To retrieve metrics from production, omit ProjectID.

Copy
cURL sample request: Retrieve a list of all metrics in tenant WFF_j1r~c7o
curl -X GET --url 'https://{vanity_name}.api.visier.io/v2alpha/data/model/metrics' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}' \
-H 'TargetTenantID:WFF_j1r~c7o'

Optionally, specify type to only retrieve a specific metric type.

Copy
cURL sample request: Retrieve a list of all simple metrics
curl -X GET --url 'https://{vanity_name}.api.visier.io/v2alpha/data/model/metrics?type=simple' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}'

Optionally, specify with to retrieve more detailed information about each metric. Default is to return basic information.

Copy
cURL sample request: Retrieve a list of all simple metrics with detailed information
curl -X GET --url 'https://{vanity_name}.api.visier.io/v2alpha/data/model/metrics?type=simple&with=details' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}'

The response returns the details of all metrics, including object names and descriptions.

Retrieve a metric's details

Use this sample request to retrieve the details of a specific metric.

Copy
cURL sample request: Retrieve the details of customStrongRelationships in tenant WFF_j1r~c7o
curl -X GET --url 'https://{vanity_name}.api.visier.io/v2alpha/data/model/metrics/customStrongRelationships' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}' \
-H 'TargetTenantID:WFF_j1r~c7o'

The response returns the details of the requested metric, including its object name and description.

Create metrics

Use this sample request to create a new metric. To create new metrics that publish directly to production, omit projectId.

Copy
cURL sample request: Create a new metric
curl -X POST --url 'https://{vanity_name}.api.visier.io/v2alpha/data/model/metrics' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}' \
-H 'Content-Type: application/json' \
-d '{
  "metrics": [
    {
      "executionContext": {
        "tenantCode": "WFF_j1r",
        "projectId": "8a0fd408-cee9-49ee-9a1d-857b43b7fae9"
      },
      "metric": {
        "objectName": "customStrongRelationships",
        "basicInformation": {
          "displayName": "Custom Strong Relationships",
          "description": "The total number of strong relationships within the team.",
          "explanation": "<html><head></head><body><h1>Strong Relationships</h1><p>The total number of strong relationships within the team.</p><h2>Calculation details</h2><p>This is the sum of the total number of strong relationships.</p><h2>Guidance</h2><p>Explanation://TrustSphere_ONA_Guidance_Explanation</p></body></html>"
        },
        "details": {
          "simple": {
            "formula": " on Employee validUntil instant filterBy isActiveEmployee aggregate sum(Employee.Strong_Relationships)",
            "dataType": "Number"
          }
        },
        "additiveType": "balance",
        "visibleInAnalytics": true,
        "includeWithVee": true,
        "analyticObjectName": "Employee",
        "tagList": {
          "tags": [
            {
              "objectName": "Network_Analysis_Tag"
            }
          ]
        }
      }

    }
  ]
}'

The response returns the successful and unsuccessful changes.

Update metrics

Use this sample request to update an existing metric. The request body is similar to POST, but requires the metric's UUID.

Copy
cURL sample request: Update customStrongRelationships
curl -X PUT --url 'https://{vanity_name}.api.visier.io/v2alpha/data/model/metrics' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}' \
-H 'Content-Type: application/json' \
-d '{
  "metrics": [
    {
      "executionContext": {
        "tenantCode": "WFF_d3m",
        "projectId": "8a0fd408-cee9-49ee-9a1d-857b43b7fae9"
      },
      "metric": {
        "uuid": "6a40703f-4589-4c9f-a433-a4ff19d743e9",
        "objectName": "customStrongRelationships",
        "basicInformation": {
          "displayName": "Modified Strong Relationships",
          "description": "The total number of strong relationships within the team.",
          "explanation": "<html><head></head><body><h1>Strong Relationships</h1><p>The total number of strong relationships within the team.</p><h2>Calculation details</h2><p>This is the sum of the total number of strong relationships.</p><h2>Guidance</h2><p>Explanation://TrustSphere_ONA_Guidance_Explanation</p></body></html>"
        },
        "details": {
          "simple": {
            "formula": "on Employee validUntil instant filterBy isActiveEmployee aggregate sum(Employee.Strong_Relationships)",
            "dataType": "Number"
          }
        },
        "additiveType": "balance",
        "visibleInAnalytics": true,
        "includeWithVee": false,
        "analyticObjectName": "Employee",
        "tagList": {
          "tags": [
            {
              "objectName": "Network_Analysis_Tag"
            }
          ]
        }
      }
    }
  ]
}'

The response returns the successful and unsuccessful changes.

Partially update metrics

Use this sample request to patch an existing metric.

Copy
cURL sample request: Update the display name and description of metric 6a40703f-4589-4c9f-a433-a4ff19d743e9
curl -X PATCH --url 'https://{vanity_name}.api.visier.io/v2alpha/data/model/metrics' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}' \
-H 'Content-Type: application/json' \
-d '{
  "metrics": [
    {
      "executionContext": {
        "tenantCode": "WFF_d3m",
        "projectId": "8a0fd408-cee9-49ee-9a1d-857b43b7fae9"
      },
      "metric": {
        "uuid": "6a40703f-4589-4c9f-a433-a4ff19d743e9",
        "basicInformation": {
          "displayName": "A Patched strong relationship metric",
          "description": "Adapted version of how strong relationships in a team are counted."
        }
      }
    }
  ]
}'

The response returns the successful and unsuccessful changes.

Delete metrics

Use this sample request to delete an existing metric. To delete the metric and publish it to production immediately, omit projectId.

Copy
cURL sample request: Delete metric 6a40703f-4589-4c9f-a433-a4ff19d743e9
curl -X DELETE --url 'https://{vanity_name}.api.visier.io/v2alpha/data/model/metrics' \
-H 'apikey:{api_key}' \
-H 'Cookie:VisierASIDToken={security_token}' \
-H 'Content-Type: application/json' \
-d '{
  "metrics": [
    {
      "executionContext": {
        "tenantCode": "WFF_d3m",
        "projectId": "8a0fd408-cee9-49ee-9a1d-857b43b7fae9"
      },
      "metric": {
        "uuid": "6a40703f-4589-4c9f-a433-a4ff19d743e9"
      }
    }
  ]
}'

The response returns the successful and unsuccessful changes.