Complete Budget Governance System API
PURPOSE:
This specification defines a complete, interoperable budget governance system
with three integrated pillars:
-
TENANT & BUDGET MANAGEMENT (Configuration Plane)
- Tenant lifecycle: registration, hierarchy, metadata
- Budget lifecycle: creation, allocation, funding, expiry
- Policy configuration: caps, limits, quotas
- API key provisioning and management
-
AUTHENTICATION & AUTHORIZATION (Identity Plane)
- API key validation and tenant resolution
- Permission and scope enforcement
- Key lifecycle: creation, rotation, revocation
- Audit logging and access tracking
-
RUNTIME ENFORCEMENT (Reservation Plane)
- Budget reservations and commits (from Cycles Protocol v0.1.23)
- Real-time enforcement with overdraft support
- Balance queries and monitoring
DESIGN PRINCIPLES:
- Interoperability: Standard schemas enable tool ecosystem
- Security-first: Explicit trust boundaries and validation
- Operational clarity: All workflows have defined endpoints
- Backward compatibility: Extends Cycles v0.1.23 without breaking changes
DEPLOYMENT MODELS:
- Single-service: All three pillars in one deployment
- Split-plane: Separate admin/auth services from runtime enforcement
- Federated: Multiple runtime enforcement instances, shared admin plane
License
Apache 2.0Servers
List all tenants
Returns paginated list of all tenants. Useful for admin dashboards and tenant discovery.
Authorizations
Administrative API key with full system access
Parameters
Query Parameters
"ACTIVE""SUSPENDED""CLOSED"110050Responses
Tenant list
Create a new tenant
Registers a new tenant in the system. This is typically the first operation in onboarding a new organization.
AUTHORIZATION: - Requires admin key (X-Admin-API-Key)
IDEMPOTENCY: - Safe to retry with same tenant_id. Returns existing tenant if already created.
Authorizations
Administrative API key with full system access
Request Body
Responses
Tenant already exists (idempotent)
Get tenant details
Authorizations
Administrative API key with full system access
Parameters
Path Parameters
Responses
Tenant details
Update tenant properties
Modify tenant metadata, status, or hierarchy.
STATUS TRANSITIONS: - ACTIVE → SUSPENDED: Blocks new reservations, existing active reservations can still commit/release - SUSPENDED → ACTIVE: Resume normal operations - * → CLOSED: Irreversible, archives tenant
Authorizations
Administrative API key with full system access
Parameters
Path Parameters
Request Body
Responses
Tenant updated
List budget ledgers
Query budget ledgers by tenant, scope pattern, or status. Returns all units for matching scopes.
AUTHORIZATION: - Tenant can list their own budgets only (scoped by ApiKeyAuth)
Authorizations
Tenant-scoped API key for runtime operations (consistent with Cycles Protocol)
Parameters
Query Parameters
Filter by scope prefix, e.g., "tenant:acme-corp/workspace:eng"
"USD_MICROCENTS""TOKENS""CREDITS""RISK_POINTS""ACTIVE""FROZEN""CLOSED"50Responses
Budget list
Create a budget ledger for a scope
Initializes a new budget ledger for a (scope, unit) pair. This must be done before any reservations can be made against the scope.
AUTHORIZATION: - Tenant can create budgets for their own scopes only - Uses ApiKeyAuth (X-Cycles-API-Key) - tenant manages own budgets
SCOPE VALIDATION: - Scope must match pattern: tenant:* or tenant:/workspace: etc. - Tenant must exist and be ACTIVE - Cannot create duplicate (scope, unit) ledgers
INITIAL STATE: - allocated = requested amount - remaining = allocated - reserved = spent = debt = 0
Authorizations
Tenant-scoped API key for runtime operations (consistent with Cycles Protocol)
Request Body
Responses
Budget created
Credit, debit, or adjust budget allocation
Modifies budget allocation and remaining balance outside the reservation flow. Common operations:
AUTHORIZATION: - Tenant can fund their own budgets only
CREDIT (top-up): - allocated += amount - remaining += amount - Use for: monthly allocations, bonus credits
DEBIT (drain): - allocated -= amount - remaining -= amount (fails if would go negative) - Use for: downgrades, refunds, policy enforcement
RESET (reallocate): - allocated = amount - remaining = amount - reserved - spent - debt - Use for: period rollovers, plan changes
REPAY_DEBT: - debt -= amount (use remaining if debt < amount) - Use for: manual debt reconciliation
IDEMPOTENCY: - Required idempotency_key prevents double-funding - Replayed requests return original response
Authorizations
Tenant-scoped API key for runtime operations (consistent with Cycles Protocol)
Parameters
Path Parameters
"USD_MICROCENTS""TOKENS""CREDITS""RISK_POINTS"Request Body
Responses
Funding operation completed
List policies
AUTHORIZATION: - Tenant can list their own policies only
Authorizations
Tenant-scoped API key for runtime operations (consistent with Cycles Protocol)
Parameters
Query Parameters
"ACTIVE""DISABLED"50Responses
Policy list
Create a policy with caps and limits
Defines caps (soft-landing constraints) and rate limits for scopes. Policies are evaluated during reservation requests.
AUTHORIZATION: - Tenant can create policies for their own scopes only
SCOPE PATTERNS: - "tenant:acme-corp" (exact match) - "tenant:acme-corp/" (all descendants) - "agent:" (all agents system-wide) - "*/agent:summarizer" (agent across all tenants)
PRIORITY: - Higher priority policies override lower priority - If multiple policies match, highest priority wins
EFFECTIVE DATES: - Optional time-bounded policies - Useful for temporary restrictions or trials
Authorizations
Tenant-scoped API key for runtime operations (consistent with Cycles Protocol)
Request Body
Responses
Policy created
List API keys
Returns keys for a tenant. Full key secrets are never returned, only prefixes and metadata.
Authorizations
Administrative API key with full system access
Parameters
Query Parameters
"ACTIVE""REVOKED""EXPIRED"50Responses
API key list
Create an API key for a tenant
Provisions a new API key bound to a tenant. This is the only time the full key secret is returned. Store it securely.
KEY FORMAT: - Prefix: cyc_live_{random} or cyc_test_{random} - Random part: 32 characters, cryptographically random - Stored as: bcrypt hash of full key
PERMISSIONS: - Default for tenant keys: [reservations:, balances:read] - Admin keys: [admin:, reservations:, balances:] - Can be restricted to specific scopes via scope_filter
EXPIRY: - Recommended: 90 days for security - Can be set indefinitely but not recommended - Expired keys auto-fail validation
Authorizations
Administrative API key with full system access
Request Body
Responses
API key created
Revoke an API key
Immediately revokes a key. The key will fail validation from this point forward. Active reservations using this key can still be committed/released, but no new operations are permitted.
REVOCATION IS PERMANENT: - Cannot be undone - Revoked keys remain in database for audit trail - Status transitions: ACTIVE → REVOKED
Authorizations
Administrative API key with full system access
Parameters
Path Parameters
Query Parameters
512Responses
Key revoked
Validate an API key and resolve tenant
Internal endpoint used by runtime enforcement layer to validate keys and derive effective tenant.
VALIDATION CHECKS: 1. Key exists in database 2. Key hash matches 3. Status is ACTIVE (not REVOKED or EXPIRED) 4. Current time < expires_at 5. Tenant is ACTIVE (not SUSPENDED or CLOSED)
RESPONSE: - If valid: returns tenant_id, permissions, scope_filter - If invalid: returns valid=false with reason
CACHING: - Results should be cached with short TTL (60s) - Invalidate cache on key revocation
Authorizations
Administrative API key with full system access
Request Body
Responses
Validation result
Query audit logs
Returns audit trail of all authenticated operations. Essential for compliance (SOC2, GDPR, etc.).
RETENTION: - Recommended: 90 days hot, 1 year cold storage - Critical for security incident investigation
FILTERING: - By tenant, key, time range, operation, status - Supports complex queries for forensics
Authorizations
Administrative API key with full system access
Parameters
Query Parameters
"date-time""date-time"50Responses
Audit log entries
Create budget reservation (Cycles v0.1.23)
See Cycles Protocol v0.1.23 specification.
GOVERNANCE INTEGRATION: 1. Validates X-Cycles-API-Key via /v1/auth/validate 2. Derives effective tenant from key 3. Validates Subject.tenant matches effective tenant (403 if mismatch) 4. Checks tenant status (blocks if SUSPENDED or CLOSED) 5. Checks budget ledger exists for scope 6. Applies matching policies (caps, rate limits) 7. Executes Cycles reservation logic (reserve.lua) 8. Logs operation to audit trail
Authorizations
Tenant-scoped API key for runtime operations (consistent with Cycles Protocol)
Responses
Reservation created (see Cycles v0.1.23)
Commit actual spend (Cycles v0.1.23)
See Cycles Protocol v0.1.23 specification.
GOVERNANCE INTEGRATION: - Validates key and tenant as in reservation - Supports ALLOW_WITH_OVERDRAFT policy - Creates debt if overdraft_limit configured - Logs commit to audit trail
Authorizations
Tenant-scoped API key for runtime operations (consistent with Cycles Protocol)
Responses
Commit succeeded (see Cycles v0.1.23)
Query budget balances (Cycles v0.1.23)
See Cycles Protocol v0.1.23 specification.
GOVERNANCE INTEGRATION: - Returns full ledger state including debt, overdraft_limit, is_over_limit - Scoped to effective tenant - Supports scope filtering via query params
Authorizations
Tenant-scoped API key for runtime operations (consistent with Cycles Protocol)
Responses
Balance data (see Cycles v0.1.23)
