Base URL
Authentication
Any API key reaches this API, including one created with the default Execute only scope. Include it in every request:Execution Modes
LexQ provides 3 execution modes. Choose the one that fits your use case:
To try a version before it serves traffic, use Dry Run: it is not billed and is not recorded in execution history. To send part of production traffic to a version, use an A/B test.
Request Body Limit
The request body of an execution call can be up to 1 MB, in every mode. A larger body fails with413 (C-011): nothing runs and the call is not billed. Split a large batch into several calls, and send only the facts your rules read (Requirements lists them).
Objects and arrays in the body can nest up to 32 levels deep. The outermost braces of the body are level 1. facts is level 2 in a single-group or composite call, and level 4 in each item of a batch call. A deeper body fails with 400 (C-012). Nothing runs and the call is not billed.
Value Limits
These limits apply to every value infacts and contexts, including values nested inside a list or an object:
Digits are counted with the number written in full, without an exponent, and trailing zeros count. For example,
1.50 has 2 digits after the decimal point, and 1.5e-34 has 35.
A request with a value over a limit fails with 400 (P-064), and the message gives the value’s path, such as facts.items[3]. Nothing runs and the call is not billed. In a batch call, a value over a limit in any item fails the whole call.
When a fact value arrives as text and MUTATE_FACT reads it as a number, the number limit applies to that number too. If the number is over the limit, the call fails with 400 (P-064) and is billed. In an organization that uses Fail-open, that action is skipped instead, and the call continues.
The same limits apply to dry runs, MANUAL and UPLOADED simulation datasets, and values you write in rules.
MUTATE_FACT — With Rounding explains how a number that a rule calculates is rounded to fit these limits, and when the call fails with 400 (ACT-034) instead.
Single Group Execution
Evaluates all active rules in the currently deployed version of a policy group.Request
What
contexts does. Two things, and neither follows from the name.
- A/B routing reads it. When a policy group has an A/B test running,
contexts.trafficKeydecides which version serves the request. Omit it and the test version receives 0% of traffic. See Traffic Identity Key. - It is recorded. The whole object is stored on the execution ledger alongside the request, so it surfaces in execution history and audit views. Keep personal data out of it.
facts, not here. facts is the one input that fact definitions, the /requirements response, and the execution response all agree on. A value sent in contexts is outside that contract: it cannot be registered as a fact definition and it never appears in /requirements. The response returns it in inputContexts, separate from inputFacts.
The request takes only facts and contexts. Any other top-level field fails with 400 (C-001) and nothing runs, even when its value is {} or null. That includes context, the old name of contexts. Send the same object as contexts.
Response
data.traceId is the execution’s audit handle — store it alongside your own records to trace this execution later. data.executedAt is when the execution ran, and data.totalProcessingTimeMs is how long it took in milliseconds. Execution history shows the same two values for the call. data.inputContexts is the contexts you sent, or {} if you sent none.
Each entry of executionTraces describes one evaluated rule. The input facts and the time appear once at the top of data, not in each entry.
The data object exposes three layers of state explicitly:
inputFacts— facts as received from the request, normalized.mutatedFacts— only the facts whose values were changed by rule actions.generatedVariables— variables created by rule actions that did not exist in the input. A fact thatMUTATE_FACTchanges also gets{targetVar}__delta: the signed net change from the request value, including anySET_FACTchange to the same fact (How a request runs).
{ ...inputFacts, ...mutatedFacts, ...generatedVariables }.
Idempotency
Include anIdempotency-Key header to prevent duplicate executions. If a request with the same key has already been processed, the original response is returned without re-executing the policy.
The replay is a normal 200 — not an error. It carries the same traceId and the same executedAt as the first call, which is how you can tell a replay from a fresh execution. I-001 below is a different situation: the key is spent and this request could not be served from it.
Key format. Up to 255 characters. How you generate keys is up to you; we suggest a V4 UUID or another random string with enough entropy to avoid collisions. A longer key is rejected with I-003 rather than truncated.
Keys are kept for the retention period, so do not put personal data in them — no email addresses, phone numbers, or names.
Batch Execution
Executes multiple fact sets against the same policy group in a single call. All requests in the batch are evaluated against the same version for consistency.Request
A batch holds up to 100 items. A larger batch fails with
400 (C-001), so split it into several calls.
A batch takes only requests and contexts at the top level, and each item takes only facts. Any other field fails with 400 (C-001), even when it is empty. That includes sharedContext and context at the top level and context or contexts inside an item. Send the call’s context once, as the top-level contexts.
Response
traceId, executedAt, totalProcessingTimeMs, inputContexts) appear once, before results. Results are returned in the same order as the input requests. Each holds the five evaluation fields of a single-group response: inputFacts, mutatedFacts, generatedVariables, executionTraces, and decisionTraces. Results carry no traceId of their own; the call’s traceId covers the whole batch. The whole batch runs on one version; during an A/B test, contexts.trafficKey chooses it.
Execution history keeps a batch call as one record, and that record does not keep the items’ input facts.
Each item is billed and counts toward your plan’s monthly execution limit. On Free, a batch with more items than are left in the month fails with
403 (B-008), and none of its items run.Composite Execution
Evaluates the same facts against multiple policy groups in a single call. Useful when a transaction must pass through multiple policy checks simultaneously (e.g., product discount + cart coupon + shipping fee + membership points).Request
targetGroupIds takes up to 20 group IDs. A longer list fails with 400 (C-001).
The request takes only these three fields. Any other field fails with 400 (C-001), even when it is empty. That includes the old name context.
Response
mutatedFacts, generatedVariables, executionTraces, and decisionTraces include the results of every target group’s rules. Trace entries follow the order of the decision: by group priority, then by rule priority within each group.
In the example, the discount group and the coupon group both change paymentAmount: 10% off 250,000 is 225,000, and 5,000 off that is 220,000. paymentAmount__delta is the net change across both groups. shippingFee was not in the request, so the value the shipping group set is in generatedVariables. Each trace’s policyGroupId shows which group it came from.
The whole request fails if any target group cannot run. A group that is not found fails it with 404 (P-001), a DISABLED or deleted group with 403 (P-009), and a group with no deployed version with 400 (P-019). A request that fails this way is not evaluated or billed.
Each group is billed and counts toward your plan’s monthly execution limit. On Free, a call with more groups than are left in the month fails with 403 (B-008).
Requirements
Check which input facts a deployed version requires before calling the execution endpoint. Returns required keys, types, and an auto-generated sample request body.Request
Accept-Language header controls the language of the usedBy descriptions (en or ko).
Response
Pre-registered Facts
Every tenant gets these pre-registered facts immediately after account creation. You do not need to create them manually:isBlocked and blockReason are system facts that only BLOCK writes (see Fact Definitions). When a BLOCK action runs, they come back in generatedVariables. If your request sent them, they come back in mutatedFacts only when the value changes. To use a previous call’s block in a condition, send it under another key such as previouslyBlocked.
Whether each fact is required for a particular execution depends on which rules in the deployed version reference it. Call GET /groups/{groupId}/requirements to see exactly which facts the engine expects.
All other facts (e.g., paymentAmount, customerTier, orderRegion) are user-defined and must be registered via Fact Definitions before use.
Error Handling
All errors follow the same envelope shape:
For the complete code registry across all domains (auth, billing, simulation, etc.), see Error Reference.
When LexQ Is Slow or Unavailable
Give every call a timeout, and decide before you go live what your application does when a call fails or times out. LexQ can’t decide this for you, because the safe choice depends on the decision: a checkout can go ahead without an AI discount, but a transfer should wait. Each domain template says in its policy group description when to call it and what to do if the call fails:- E-Commerce: Checkout Pricing: Sample policy for member discounts, a first-order code, free shipping, member rewards, and caps on AI-proposed discounts. Call it once the subtotal is final. If the call fails or times out, apply no AI discount. Adjust rates and thresholds to your store.
- Fintech: Transfer Approval: Sample policy that approves, steps up, holds, or declines each outgoing transfer. The most severe matching rule wins. Call it right before sending and send automatically only on APPROVE. If the call fails or times out, hold the transfer.
- SaaS: Plan Limits: Sample policy that blocks requests beyond the plan, calculates TEAM overage, and caps AI-proposed credits. Call it before a request that can hit a limit and before granting a credit. If the call fails or times out, allow the request but grant no credit.
- Insurance: Claim Triage: Sample policy that routes each new auto claim to fast-track, adjuster review, or special investigation. Call it once the AI estimate is in and pay automatically only on FAST_TRACK. If the call fails or times out, send the claim to an adjuster.
- AI Agent: Action Approval: Sample policy that decides ALLOW, NEEDS_APPROVAL, or DENY for each action an AI agent proposes, and caps goodwill credits. Call it before the agent’s tool runs and run the tool automatically only on ALLOW. If the call fails or times out, do not run it.
Retrying a Failed Call
A retry with the same
Idempotency-Key gets one of these:
- If the first request succeeded, the original response. The retry is not billed.
- If the first request is still running or failed,
409(I-002) for up to a minute. After that, the retry runs the decision again and is billed again.
Idempotency-Key, so a retried batch runs and bills every item again.
Next Steps
Dry Run
Test rules without side effects before going live.
Fact Definitions
Register custom input variables for your rules.

