---
title: "Compile Predicate Endpoint"
method: POST
path: "/core/predicates/compile"
tags: ["Predicates"]
---

# Compile Predicate Endpoint

`POST /core/predicates/compile`

## Request

- Base URL: `https://api.anyreach.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.anyreach.ai/core/predicates/compile`
- Auth: HTTP bearer

Compile a predicate from natural language, or re-describe + validate
an edited JSONLogic predicate (FR-A4). Returns {logic, description,
errors}; stateless (no metric needed, so it works while authoring).

## Headers

- `x-anyreach-org` string, nullable: Organization ID for user PATs (pat_ prefix tokens)

## Request body

- CompilePredicateRequest: Schema for POST /predicates/compile — AI predicate authoring (FR-A4 UX). Two directions: give `instruction` (natural language) to generate JSONLogic + a human-readable description, or give `logic` (e.g. after a manual JSON edit) to re-describe + validate it. `criteria`/`metrics` scope the references the generator may use ('gating'); 'deterministic' rules reference conversation fields only.
  - `mode` 'gating' | 'deterministic'
  - `instruction` string, nullable
  - `logic` object, nullable
  - `criteria` string[]
  - `metrics` object[]

## Response `200`

Successful Response

- unknown

## Other responses

- `422`: Validation Error

---

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