Create Control
POSThttps://api.confident-ai.com/v2/organization/governance-controls
Creates a governance control and returns its id. Supplying the config that matches the control's type snapshots its first version in the same call; omitting it creates the control with no definition, which assesses as ERROR until you add a version. Operational controls are seeded by Confident AI and cannot be created here. A new control governs nothing until a governance policy holds it.
curl -X POST "https://api.confident-ai.com/v2/organization/governance-controls" \
-H "CONFIDENT_API_KEY: <ORGANIZATION-API-KEY>" \
-H "Content-Type: application/json" \
-d '{
"name": "Production error rate under 2%",
"description": "Traces must error on fewer than 2% of production requests over the last day.",
"type": "RUNTIME",
"runtimeConfig": {
"dataModel": "TRACE",
"aggregation": "Avg cost",
"thresholdSettings": {
"value": 0.02,
"direction": "above"
},
"extraQueryParams": {
"category": "TRACE"
},
"filters": {
"operator": "AND",
"groups": [
{
"operator": "AND",
"filters": [
{
"category": "User Id",
"condition": "Is less than",
"value": "string",
"key": "string"
}
]
}
]
},
"severity": "CRITICAL"
},
"preDeploymentConfig": {
"identifier": "pre-release",
"window": {
"days": 30
},
"officialOnly": false,
"filters": {
"operator": "AND",
"groups": [
{
"operator": "AND",
"filters": [
{
"category": "User Id",
"condition": "Is less than",
"value": "string",
"key": "string"
}
]
}
]
},
"severity": "CRITICAL"
},
"governancePolicyId": "<GOVERNANCE-POLICY-ID>"
}'{
"success": true,
"data": {
"id": "<GOVERNANCE-CONTROL-ID>"
},
"link": "https://app.confident-ai.com/organization/<ORGANIZATION-ID>/governance/controls/<GOVERNANCE-CONTROL-ID>",
"deprecated": false
}Headers
CONFIDENT_API_KEYstringRequiredThe organization API key for your Confident AI organization.
Request body
namestringRequiredThe name of the control, unique within your organization.
descriptionstring | nullWhat the control checks and why. Send null to leave it unset.
typeenumRequiredThe control types you can create. OPERATIONAL is absent because Confident AI seeds those controls from its own registry.
Show 3 enum valuesHide 3 enum values
RUNTIMEPRE_DEPLOYMENT_EVALSPRE_DEPLOYMENT_RED_TEAMING
runtimeConfigobjectThe rule a RUNTIME control evaluates, read as one sentence: aggregate
aggregationoverdataModelfor the trailing 24 hours, restricted tofilters, and fail when the result sits on thedirectionside of the threshold. AggregatingError rateoverTRACEagainst a threshold of 0.02abovefails a project whose traces errored on more than 2% of requests in the last day. The window is fixed and is not part of the definition. The aggregation has to be one the data model supports.Show 6 propertiesHide 6 properties
dataModelenum | nullRequiredThe production data a runtime control measures: TRACE for whole requests, SPAN for individual steps, THREAD for conversations, METRIC_DATA for evaluation scores, and ANNOTATION for human ratings. It decides which aggregations are valid.
Show 5 enum valuesHide 5 enum values
TRACESPANTHREADMETRIC_DATAANNOTATION
aggregationenum | nullRequiredHow a runtime control reduces the data it measures to the single number it compares against its threshold. Each aggregation is only valid for some data models —
Avg scoreandPass rateneed METRIC_DATA,Avg ratingneeds ANNOTATION,Input tokensneeds SPAN — and a pairing the selecteddataModeldoes not support is rejected.Show 22 enum valuesHide 22 enum values
Avg costAvg latencyAvg ratingAvg scoreCountError countError rateFailure rateInput costInput tokensMedian scoreOutput costOutput tokensP50 latencyP90 latencyP99 latencyPass rateTotal costTotal tokensUnique end usersUnique metadata valuesUnique threads
thresholdSettingsobject | nullRequiredThe comparison that turns a runtime control's measured value into a verdict.
Show 2 propertiesHide 2 properties
valuenumberRequiredThe number the aggregated value is compared against, in the unit the aggregation produces — a rate is a fraction between 0 and 1, a latency is in milliseconds, a cost is in USD.
directionenumRequiredWhich side of the threshold fails:
abovefails once the measured value rises pastvalue,belowfails once it drops under it.Show 2 enum valuesHide 2 enum values
abovebelow
extraQueryParamsobject | nullExtra scoping for the data a runtime control measures, beyond its data model and filters.
Show 1 propertyHide 1 property
categoryenumWhich kind of item the evaluation scores were recorded on, for a control measuring METRIC_DATA.
Show 3 enum valuesHide 3 enum values
TRACESPANTHREAD
filtersobject | nullRequiredA set of filter groups combined by a top-level operator. Each group combines its filter rows by its own operator, and each row matches one property, such as
NameorUser Id, against a value with a condition such asIsorContains.Show 2 propertiesHide 2 properties
operatorenumRequiredShow 2 enum valuesHide 2 enum values
ANDOR
groupslist of objectsRequiredShow 2 propertiesHide 2 properties
operatorenumRequiredShow 2 enum valuesHide 2 enum values
ANDOR
filterslist of objectsRequiredShow 4 propertiesHide 4 properties
categoryenumRequiredShow 80 enum valuesHide 80 enum values
User IdThread IdTrace UuidTrace NameTrace VersionTrace StatusTrace TagsTraceSpan UuidNameSpan NameSpan TypeSpan StatusMetrics StatusError StatusNameModelProviderIntegrationEmbedderChunk SizeTop-KHyperparameterDatasetDataset NameTest Run IDIdentifierTest FileStatusOfficialEvals ModeTests PassedTests FailedPass RateFail RateStar RatingThumbs RatingExplanationExpected OutputExpected OutcomeAnnotatorEnd UserAnnotation TypeAnnotation NameCriteriaAnnotation DateMetric ScoreMetric StatusNameMetadataClassifierMetricMetric NameTrace CountTest Case IDRequested review fromAssigned toTagsLabelsTools CalledFinalizedGolden IDIngestion TaskLatencyEnvironmentReview flagVulnerabilityVulnerability TypeAttack MethodRisk CategoryFrameworkAssessment IDPrompt AliasPrompt VersionPrompt LabelPrompt Commit HashPromptAnnotationsStatus CodeActor Type
conditionenum | enum | enum | enum | enum | enum | enum | enum | enum | enumRequiredShow 10 variantsHide 10 variants
enum
Show 6 enum valuesHide 6 enum values
Is less thanIs equal or less thanIs greater thanIs equal or greater thanIs equal toDoes not equal
- OR
enum
Show 2 enum valuesHide 2 enum values
HasHas not
- OR
enum
Show 2 enum valuesHide 2 enum values
IsIs not
- OR
enum
Show 2 enum valuesHide 2 enum values
Is one ofIs not one of
- OR
enum
Show 4 enum valuesHide 4 enum values
IsIs notIs emptyIs not empty
- OR
enum
Show 2 enum valuesHide 2 enum values
ContainsDoes not contain
- OR
enum
Show 3 enum valuesHide 3 enum values
ContainsContains onlyDoes not contain
- OR
enum
Show 4 enum valuesHide 4 enum values
Has decreased by more thanHas decreased by less thanHas increased by more thanHas increased by less than
- OR
enum
Show 1 enum valueHide 1 enum value
Has changed from
- OR
enum
Show 1 enum valueHide 1 enum value
Is between
valuestring | number | list of stringsRequiredShow 3 variantsHide 3 variants
string
- OR
number
- OR
list of strings
keystring
severityenum | nullRequiredHow much a failing control matters, set per version rather than per control. LOW never blocks a deployment gate; CRITICAL, HIGH and MEDIUM block, and so does leaving the severity unset.
Show 4 enum valuesHide 4 enum values
CRITICALHIGHMEDIUMLOW
preDeploymentConfigobjectThe rule a PRE_DEPLOYMENT_EVALS or PRE_DEPLOYMENT_RED_TEAMING control evaluates, read as one sentence: find the project's newest completed run whose identifier is
identifierwithin the lastwindow.daysdays, and pass when that run satisfiesfilters. An identifier ofpre-releasewith a 30-day window and a filter ofPass rate>=0.9fails a project whose last pre-release run scored below 90%, and reports NO_DATA when it has not run one at all. PRE_DEPLOYMENT_EVALS looks at test runs and PRE_DEPLOYMENT_RED_TEAMING at red teaming runs; the endpoint picks which by the control's own type, so the same shape serves both. Send a non-emptyidentifierunlessofficialOnlyis true.Show 5 propertiesHide 5 properties
identifierstringRequiredThe identifier of the run to gate on, as sent when the test run or red teaming run was created. Send an empty string when
officialOnlyis true.windowobjectRequiredThe rolling lookback a pre-deployment control searches for the run it gates on.
Show 1 propertyHide 1 property
daysintegerRequiredHow many days back the control looks for a run. It is stored as a day count rather than as dates, so the gate does not go stale as it is re-assessed.
officialOnlybooleanGate on the project's most recent official run instead of on a run matching
identifier, which ignoresidentifierand the window. Defaults to false.filtersobject | nullRequiredA set of filter groups combined by a top-level operator. Each group combines its filter rows by its own operator, and each row matches one property, such as
NameorUser Id, against a value with a condition such asIsorContains.Show 2 propertiesHide 2 properties
operatorenumRequiredShow 2 enum valuesHide 2 enum values
ANDOR
groupslist of objectsRequiredShow 2 propertiesHide 2 properties
operatorenumRequiredShow 2 enum valuesHide 2 enum values
ANDOR
filterslist of objectsRequiredShow 4 propertiesHide 4 properties
categoryenumRequiredShow 80 enum valuesHide 80 enum values
User IdThread IdTrace UuidTrace NameTrace VersionTrace StatusTrace TagsTraceSpan UuidNameSpan NameSpan TypeSpan StatusMetrics StatusError StatusNameModelProviderIntegrationEmbedderChunk SizeTop-KHyperparameterDatasetDataset NameTest Run IDIdentifierTest FileStatusOfficialEvals ModeTests PassedTests FailedPass RateFail RateStar RatingThumbs RatingExplanationExpected OutputExpected OutcomeAnnotatorEnd UserAnnotation TypeAnnotation NameCriteriaAnnotation DateMetric ScoreMetric StatusNameMetadataClassifierMetricMetric NameTrace CountTest Case IDRequested review fromAssigned toTagsLabelsTools CalledFinalizedGolden IDIngestion TaskLatencyEnvironmentReview flagVulnerabilityVulnerability TypeAttack MethodRisk CategoryFrameworkAssessment IDPrompt AliasPrompt VersionPrompt LabelPrompt Commit HashPromptAnnotationsStatus CodeActor Type
conditionenum | enum | enum | enum | enum | enum | enum | enum | enum | enumRequiredShow 10 variantsHide 10 variants
enum
Show 6 enum valuesHide 6 enum values
Is less thanIs equal or less thanIs greater thanIs equal or greater thanIs equal toDoes not equal
- OR
enum
Show 2 enum valuesHide 2 enum values
HasHas not
- OR
enum
Show 2 enum valuesHide 2 enum values
IsIs not
- OR
enum
Show 2 enum valuesHide 2 enum values
Is one ofIs not one of
- OR
enum
Show 4 enum valuesHide 4 enum values
IsIs notIs emptyIs not empty
- OR
enum
Show 2 enum valuesHide 2 enum values
ContainsDoes not contain
- OR
enum
Show 3 enum valuesHide 3 enum values
ContainsContains onlyDoes not contain
- OR
enum
Show 4 enum valuesHide 4 enum values
Has decreased by more thanHas decreased by less thanHas increased by more thanHas increased by less than
- OR
enum
Show 1 enum valueHide 1 enum value
Has changed from
- OR
enum
Show 1 enum valueHide 1 enum value
Is between
valuestring | number | list of stringsRequiredShow 3 variantsHide 3 variants
string
- OR
number
- OR
list of strings
keystring
severityenum | nullRequiredHow much a failing control matters, set per version rather than per control. LOW never blocks a deployment gate; CRITICAL, HIGH and MEDIUM block, and so does leaving the severity unset.
Show 4 enum valuesHide 4 enum values
CRITICALHIGHMEDIUMLOW
governancePolicyIdstringAccepted but not acted on: the control is created unattached whether or not you send it. Attach it through the governance policy's own controls endpoint.
Response
Create Control succeeded.
successbooleanIndicates if the request was successful.
dataobjectA reference to a governance control by its id.
Show 1 propertyHide 1 property
idstringThe id of the governance control.
linkstringThis is the URL of the resource on the Confident AI platform.
deprecatedbooleanIndicates if this endpoint is deprecated.