Skip to main content
Add metrics to a surface to make them easier to find for experimenters, or enforce that all experiments on the surface check this metric for regressions.

Add a Required Metric

Confidence enforces required metrics for all experiments on the surface. Use the following to add a required metric metrics/<metric> to a surface with resource name surfaces/<surface>:
curl -X PATCH "https://api.confidence.dev/v1/surfaces/<surface>?updateMask=metricConfig.mandatoryMetrics" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "metricConfig": {
      "mandatoryMetrics": [{
        "metric": "metrics/<metric>",
        "guardrailMetric": {},
        "preferredDirection": "INCREASE"
      }]
    }
  }'
The preferredDirection can be INCREASE or DECREASE, indicating which direction the metric should move in for a successful experiment.

Add an Associated Metric

Confidence suggests associated metrics for experiments on the surface but doesn’t enforce them. Use the following to add an associated metric:
curl -X PATCH "https://api.confidence.dev/v1/surfaces/<surface>?updateMask=metricConfig.associatedMetrics" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "metricConfig": {
      "associatedMetrics": [{
        "metric": "metrics/<metric>"
      }]
    }
  }'