> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lexq.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Get your first policy running in under 5 minutes.

## Prerequisites

* A LexQ account ([sign up free](https://console.lexq.io))
* An API key (created in Console → Management → API Keys)

## Step 1: Create a Policy Group

<Steps>
  <Step title="Open the Console">
    Navigate to [console.lexq.io](https://console.lexq.io) and sign in.
  </Step>

  <Step title="Create a Group">
    Go to **Policy Groups** → **Create Group**.

    * **Name**: `discount-policy`
    * **Priority**: `0`
    * **Execution Mode**: Allow All (`NONE`)
  </Step>

  <Step title="Create a Version">
    Inside your new group, click **Create New Draft**.
    This creates a `DRAFT` version where you can add rules.
  </Step>
</Steps>

## Step 2: Define a Rule

<Steps>
  <Step title="Add a Rule">
    In the Rule Edit tab, click **Add Rule**.

    * **Name**: `High-Value Discount`
    * **Priority**: `0`
  </Step>

  <Step title="Set the Condition">
    Add a condition using the `payment_amount` fact:

    ```
    payment_amount >= 100000
    ```
  </Step>

  <Step title="Add an Action">
    Add a **MUTATE\_FACT** action:

    * **Reference Fact** (`refVar`): `payment_amount`
    * **Operator** (`operator`): `SUB` (subtract from refVar)
    * **Method**: Percentage
    * **Rate**: `10` (reduces refVar by 10%)
  </Step>
</Steps>

<Info>
  `user_id`, `user_tags` are **system facts** — pre-registered and ready to use. Domain-specific facts like `payment_amount` or `customer_tier` are user-defined — see [Fact Definitions](/guides/fact-definitions).
</Info>

## Step 3: Test with Dry Run

Before deploying, validate your rule with a Dry Run:

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.lexq.io/api/v1/partners/analytics/dry-run/versions/{versionId} \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
      "facts": {
          "payment_amount": 150000,
          "user_id": "user-001"
      },
      "includeDebugInfo": true,
      "mockExternalCalls": true
  }'
  ```
</CodeGroup>

You should see the mutated `payment_amount: 135000` in the response, and `payment_amount__delta: -15000` in `generatedVariables` (the signed change applied by the rule).

## Step 4: Publish and Deploy

<Steps>
  <Step title="Publish">
    Click **Publish Version**. The version transitions from DRAFT to ACTIVE and is now locked — no further edits allowed.
  </Step>

  <Step title="Deploy">
    Click **Deploy to Live**. Enter a deployment memo and confirm.
    Your policy is now live and processing traffic.
  </Step>
</Steps>

## Step 5: Execute via API

Call the execution endpoint from your application:

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.lexq.io/api/v1/execution/groups/{groupId} \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
      "facts": {
          "payment_amount": 150000,
          "user_id": "user-001"
      }
  }'
  ```

  ```java Java theme={null}
  HttpRequest request = HttpRequest.newBuilder()
  .uri(URI.create("https://api.lexq.io/api/v1/execution/groups/" + groupId))
  .header("x-api-key", apiKey)
  .header("Content-Type", "application/json")
  .POST(HttpRequest.BodyPublishers.ofString("""
  {
      "facts": {
          "payment_amount": 150000,
          "user_id": "user-001"
      }
  }
  """))
  .build();
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
  `https://api.lexq.io/api/v1/execution/groups/${groupId}`,
  {
      method: "POST",
      headers: {
          "x-api-key": apiKey,
          "Content-Type": "application/json",
      },
      body: JSON.stringify({
          facts: {
              payment_amount: 150000,
              user_id: "user-001",
          },
      }),
  }
  );
  ```
</CodeGroup>

## What's Next?

<CardGroup cols={2}>
  <Card title="Fact Definitions" icon="table-columns" href="/guides/fact-definitions">
    Add custom variables like `customer_tier` or `order_region`.
  </Card>

  <Card title="Impact Simulation" icon="flask-vial" href="/guides/simulation">
    Test policies against bulk data before deploying.
  </Card>

  <Card title="Policy Execution" icon="bolt" href="/api/execution">
    Learn about all 4 execution modes (single, version, batch, composite).
  </Card>

  <Card title="CLI & MCP" icon="terminal" href="/cli/introduction">
    Manage policies from the terminal or via AI agents.
  </Card>
</CardGroup>
