Skip to main content

Base URL

The Execution API base URL (/api/v1/execution) is different from the Management API (/api/v1/partners). Use the correct base URL for each.

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 4 execution modes. Choose the one that fits your use case:

Single Group Execution

Evaluates all active rules in the currently deployed version of a policy group.

Request

What context does. Two things, and neither follows from the name.
  • A/B routing reads it. When a policy group has an A/B test running, context.trafficKey decides 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.
Values your rules evaluate belong in 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 context is outside that contract: it cannot be registered as a fact definition, it never appears in /requirements, and it is not returned in the response.

Response

data.traceId is the execution’s audit handle — store it alongside your own records to trace this execution later. 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. Includes per-action change keys: {targetVar}__delta carries the signed change applied by MUTATE_FACT.
This split makes audits, replays, and debugging deterministic — you always know which value originated where. The merged “final state” can be reconstructed as { ...inputFacts, ...mutatedFacts, ...generatedVariables }.

Idempotency

Include an Idempotency-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, because truncation would fold two distinct keys into one and serve one request as a replay of another. Keys are stored in plaintext on the execution ledger and kept for the retention period, so do not put personal data in them — no email addresses, phone numbers, or names.

Specific Version Execution

Executes a specific version of a policy group, bypassing traffic routing. Use it to run one version on requests you send yourself, for example a rollback target before you roll back to it, or an A/B test’s test version.
The request and response formats are the same as for Single Group Execution, and the call is billed and recorded in execution history the same way. Apart from which version runs, it differs from Single Group Execution in two ways:
  • It does not use the compiled-rule cache. Each call loads the version and compiles it again, so every response time includes compilation.
  • Performance Profiling does not measure these calls, so they never appear in the Performance tab.
To split production traffic between versions, use an A/B test instead. Calls that an A/B test routes use the compiled-rule cache and are profiled.
Only versions that have been published can run this way. To test a DRAFT version, use Dry Run.

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

Response

Results are returned in the same order as the input requests. Each item in the context is merged with sharedContext (per-request context takes priority on conflict).
Batch execution counts as 1 API call for TPS throttling, regardless of the number of items. However, billing is based on the total number of items.

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

Response

The response contains merged inputFacts, mutatedFacts, generatedVariables, executionTraces, and decisionTraces from all evaluated groups. All target groups must be in ACTIVE status. If any group is DISABLED or not found, the entire request fails.

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

The Accept-Language header controls the language of the usedBy descriptions (en or ko).

Response

Call this endpoint before your first integration to see exactly which facts you need to provide. Copy the exampleRequest as a starting template and fill in real values.

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:
The most common errors you will encounter when calling execution endpoints: For the complete code registry across all domains (auth, billing, simulation, etc.), see Error Reference.

Next Steps

Dry Run

Test rules without side effects before going live.

Fact Definitions

Register custom input variables for your rules.