Skip to main content

What is Policy as Code?

Policy as Code (PaC) lets you define Charley security policies in YAML files, store them in Git, and deploy them automatically through CI/CD — the same way teams manage infrastructure as code. Instead of clicking through the dashboard, you declare policies in files, preview diffs before applying, and have a full audit trail in git history.

Why Use It?

How It Works

The agent-charley-cli CLI (and Python SDK) communicate with the Charley API using an API key — separate from your dashboard login. On each run:
  1. Plan — fetch current server state, diff against local files, print what would change
  2. Apply — apply the diff, skipping unchanged policies
Policies are idempotent: running apply twice produces the same result as running it once.

Scope Hierarchy

Policies merge from broadest to most specific:
Only the fields you explicitly set in a narrower scope override the broader scope. Unset fields fall through.

Getting Started

Install & First Policy

Install the CLI and deploy your first policy in 5 minutes

API Keys

Create and manage API keys for the CLI and SDK

Policy Reference

Full reference for all policy types and fields

Examples

Ready-to-use templates for common setups

CI/CD Integration

The most common setup runs plan on pull requests and apply on merge to main:
Use a read_only key (ck_ro_...) for the plan step and a read_write key (ck_live_...) for the apply step.