AI Policy
The AI Policy APIs enable you to create, manage, and enforce governance policies for AI operations across your organization. These policies help ensure compliance, security, and responsible AI usage at organization, workspace, or repository levels.
Overview
AI Policies are flexible governance rules that can be applied at different organizational levels to control and monitor AI usage. They provide a powerful framework for:
Compliance Enforcement: Ensure AI operations comply with regulatory requirements
Security Control: Prevent sensitive data leakage through AI interactions
Content Moderation: Define acceptable use policies for AI services
Risk Management: Classify and respond to different risk levels
Audit Trail: Track policy violations and enforcement actions
Policy Scope Hierarchy
Policies can be created at three levels, forming an inheritance hierarchy:
Organization-Level: Applies to all workspaces and repositories in the organization
Workspace-Level: Applies to all repositories within a specific workspace
Repository-Level: Applies only to a specific repository
Lower-level policies can supplement (but not override) higher-level policies.
Policy Components
Risk Types
Classify policies based on their risk level:
LOW - Informational policies, minimal impact if violated
MEDIUM - Important policies with moderate business impact
HIGH - Critical policies requiring immediate attention
Action Types
Define what happens when a policy is violated:
Log Only
0
Record the violation for audit purposes
Alert
1
Log violation and send notifications to administrators
Block
2
Prevent the action from completing and alert administrators
Policy Content
Policy content is defined in natural language and describes:
What actions are prohibited or required
Context and rationale for the policy
Specific examples of violations
Any exceptions or special cases
Example Policy Contents:
Available Endpoints
GET/policy/violations
Retrieve a list of policy violations that have occurred during AI operations.
GET/policy/{policyId}/violations
Retrieve all violations for a specific policy.
GET/policy/alerts
Retrieve all policy alerts across your organization with optional filtering.
Common Use Cases
1. Creating an Organization-Level Policy
2. Creating a Workspace-Level Policy
3. Creating a Repository-Specific Policy
4. Listing Policies
5. Updating a Policy
6. Deleting a Policy
Policy Design Best Practices
1. Clear and Specific Content
Good:
Avoid:
2. Appropriate Risk Classification
HIGH: Data breaches, regulatory violations, security threats
MEDIUM: Business process violations, quality issues
LOW: Best practice recommendations, style guidelines
3. Balanced Action Types
Use Block (2) sparingly for critical security policies
Use Alert (1) for important policies that need review
Use Log (0) for informational policies and monitoring
4. Layered Policy Strategy
Permission Model
Policy operations require different permission levels based on scope:
Organization-Level Policies
Create: Organization owner or administrator
Read: All organization members can read org-level policies
Update/Delete: Organization owner or administrator
Workspace-Level Policies
Create: Organization administrators or workspace administrators
Read: Workspace members can read workspace policies
Update/Delete: Organization administrators or workspace administrators
Repository-Level Policies
Create: Users with repository access
Read: Users with repository access
Update/Delete: Users with repository write access
Audit and Compliance
All policy operations maintain a complete audit trail:
Creator Information
Each policy tracks:
User who created it
Creation timestamp
Original policy configuration
Update Tracking
Each update records:
User who made the change
Update timestamp
Changed fields
Example Audit Information
Policy Enforcement
Policies are enforced in real-time during AI operations:
Request Evaluation: When an AI operation occurs, all applicable policies are evaluated
Policy Matching: Policies are matched based on hierarchy (org → workspace → repo)
Action Execution: Based on policy actionType:
Log (0): Violation is recorded
Alert (1): Violation is recorded and administrators are notified
Block (2): Operation is prevented and administrators are notified
Error Handling
Common error scenarios when working with policies:
400 Bad Request
Causes:
Missing required fields
Invalid repoId/workspaceId combination
No fields provided for update
403 Forbidden
Causes:
User doesn't belong to the organization
Insufficient permissions for policy scope level
Attempting to modify policy user doesn't have access to
404 Not Found
Causes:
Policy doesn't exist
Policy has been deleted
TypeScript Client Library
The Flashback TypeScript client provides convenient methods for all policy operations:
Integration Examples
Setting Up a Comprehensive Policy Framework
Best Practices Summary
Start with Organization-Level: Create baseline security and compliance policies at org level
Be Specific: Write clear, specific policy content with examples
Use Appropriate Actions: Reserve blocking for critical policies
Layer Policies: Use hierarchy to create comprehensive coverage
Review Regularly: Audit and update policies as requirements change
Test Policies: Verify policies work as expected before wide deployment
Document Intent: Include rationale in policy content
Monitor Violations: Regularly review policy violations (see Violations APIs)
Related Documentation
AI LLM Management APIs - Configure AI provider connections
AI API Keys - Manage repository-specific API keys for AI operations
Policy Violations - Monitor and analyze policy violations
Next Steps
Design your policy framework based on organizational requirements
Create organization-level baseline policies
Add workspace-specific policies for different teams or projects
Create repository-specific policies for specialized use cases
Monitor policy violations and adjust as needed
Regularly review and update policies to maintain effectiveness
Last updated
Was this helpful?