Skip to navigation

Create policy

Create a new policy configuration

Authentication

AuthorizationBearer

Bearer authentication using API key. Generate an API key from the AI Guardrails Dashboard. Example: Bearer sk_123…

Keys carry one of two access scopes, chosen when the key is created:

  • Read and write — may call every endpoint. This is the default, and the scope of every key created before scopes were introduced.
  • Read only — may call read endpoints such as /v1-beta/logs, /v1-beta/analytics and the GET endpoints. Write endpoints return 403.

Issue a read-only key to anything that only needs to retrieve data, such as a log-shipping job or a dashboard, so that it cannot modify your policies or projects.

Request

This endpoint expects an object.
namestringRequired1-100 characters
A descriptive name for the policy. Leading and trailing whitespace is stripped. Must be unique within your organization.
default_thresholdenumRequired

The confidence level at or above which the policy’s detectors flag content. l1_confident is the most lenient and l4_less_likely the strictest. Thresholds are inclusive — l2_very_likely flags on both l2_very_likely and l1_confident detections.

Allowed values:
detectorslist of objectsOptional

The detectors to run. Each entry pairs a detector type with the location in the conversation it screens.

custom_guardrail_idslist of stringsOptional
IDs of the custom guardrails to attach to this policy.

Response

Policy created successfully
statusenumOptional
Response status
Allowed values:
messagestringOptional

Human-readable response message

idstringOptional
Policy ID

Errors

400
Bad Request Error
403
Forbidden Error
422
Unprocessable Entity Error