githubEdit

user-police-tieAI 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:

  1. Organization-Level: Applies to all workspaces and repositories in the organization

  2. Workspace-Level: Applies to all repositories within a specific workspace

  3. 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:

Action Type
Value
Behavior

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

Method
API Reference
Description

POST/policy

Create a new AI policy.

PUT/policy/{policyId}

Update an existing policy.

GET/policy

List policies with optional filtering.

GET/policy/{policyId}

Get detailed information about a specific policy.

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.

GET/policy/{policyId}/alerts

Retrieve all alerts for a specific policy.

DELETE/policy/{policyId}

Permanently delete an AI governance policy.

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:

  1. Request Evaluation: When an AI operation occurs, all applicable policies are evaluated

  2. Policy Matching: Policies are matched based on hierarchy (org → workspace → repo)

  3. 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

  1. Start with Organization-Level: Create baseline security and compliance policies at org level

  2. Be Specific: Write clear, specific policy content with examples

  3. Use Appropriate Actions: Reserve blocking for critical policies

  4. Layer Policies: Use hierarchy to create comprehensive coverage

  5. Review Regularly: Audit and update policies as requirements change

  6. Test Policies: Verify policies work as expected before wide deployment

  7. Document Intent: Include rationale in policy content

  8. Monitor Violations: Regularly review policy violations (see Violations APIs)

Next Steps

  1. Design your policy framework based on organizational requirements

  2. Create organization-level baseline policies

  3. Add workspace-specific policies for different teams or projects

  4. Create repository-specific policies for specialized use cases

  5. Monitor policy violations and adjust as needed

  6. Regularly review and update policies to maintain effectiveness

Last updated

Was this helpful?