---
title: "Compile Ai Config Rule"
method: POST
path: "/api/agents/{agent_id}/ai-config/rules/compile"
tags: ["agents"]
---

# Compile Ai Config Rule

`POST /api/agents/{agent_id}/ai-config/rules/compile`

## Request

- Base URL: `https://app.thinqos.com` (the document declares no server; this is the origin it was published from)
- URL: `https://app.thinqos.com/api/agents/{agent_id}/ai-config/rules/compile`
- Auth: none declared

Compile a plain-English rule description into structured conditions
(TOS-1287 Phase 3), for the caller to confirm before staging it.

Owner-gated the same as every other AI-config write surface, even though
this endpoint writes nothing - it spends a real, funded AI call
(``rule_compile``, tracked via ``TrackedAIClient``) against this
identity's configuration on every invocation. The compiled predicates
still have to pass through ``PUT .../ai-config/rules`` (full
``routing_policy`` + model-binding validation) to actually be saved -
this endpoint's own validation (same ``routing_policy`` predicate rules,
applied via ``rule_authoring.compile_rule_text``) exists so a bad compile
is rejected here, at the point it was authored, not silently accepted and
only caught later at save time.

## Path parameters

- `agent_id` string, uuid, required

## Headers

- `x-impersonate-identity-id` string, nullable

## Request body

- RuleCompileBody: TOS-1287 Phase 3: one plain-English rule description to compile.
  - `text` string, required

## Response `200`

Successful Response

- RuleCompileResponse: TOS-1287 Phase 3: a compiled-but-not-yet-targeted rule, for the Mind tab's rules editor to show back for explicit confirmation before staging it. Never persisted by this endpoint - the owner still picks a target model (the same two-tier picker any rule uses) and Save commits it through ``PUT .../ai-config/rules`` like every other rule edit.
  - `predicates` RulePredicateResponse[], required
    - `predicate` string, required
    - `op` string, required
    - `value` unknown, required
  - `description` string, nullable, required
  - `judged_question` string, nullable, required

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/thinqos/apis/thinqos-api.md) · [All operations](https://skmtc.dev/thinqos/apis/thinqos-api/llms.txt) · [OpenAPI document](https://skmtc.dev/thinqos/apis/thinqos-api/revisions/ce2c2ce318b1?raw)
