> ## 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.

# 빠른 시작

> 5분 안에 첫 번째 정책을 실행합니다.

## 사전 준비

* LexQ 계정 ([무료 가입](https://console.lexq.io))
* API 키 (콘솔 → 관리 → API 키에서 생성)

## 1단계: 정책 그룹 생성

<Steps>
  <Step title="콘솔 열기">
    [console.lexq.io](https://console.lexq.io)로 이동하여 로그인합니다.
  </Step>

  <Step title="그룹 생성">
    **정책 그룹** → **그룹 생성**을 클릭합니다.

    * **이름**: `discount-policy`
    * **우선순위**: `0`
    * **실행 제어 방식**: 제한 없음 (`NONE`)
  </Step>

  <Step title="버전 생성">
    새 그룹에서 **새 초안 생성**을 클릭합니다.
    규칙을 추가할 수 있는 `DRAFT` 버전이 생성됩니다.
  </Step>
</Steps>

## 2단계: 규칙 정의

<Steps>
  <Step title="규칙 추가">
    규칙 편집 탭에서 **규칙 추가**를 클릭합니다.

    * **이름**: `고액 결제 할인`
    * **우선순위**: `0`
  </Step>

  <Step title="조건 설정">
    `payment_amount` 팩트를 사용하여 조건을 추가합니다:

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

  <Step title="액션 추가">
    **MUTATE\_FACT** 액션을 추가합니다:

    * **기준 팩트** (`refVar`): `payment_amount`
    * **연산자** (`operator`): `SUB` (refVar에서 차감)
    * **방식**: 비율 (Percentage)
    * **비율**: `10` (refVar를 10% 감소)
  </Step>
</Steps>

<Info>
  `user_id`, `user_tags`는 **시스템 팩트**로 이미 등록되어 있어 바로 사용할 수 있습니다. `payment_amount`나 `customer_tier`처럼 도메인별 팩트는 사용자가 정의합니다 — [팩트 정의](/ko/guides/fact-definitions)를 참조하세요.
</Info>

## 3단계: 드라이런으로 테스트

배포 전에 드라이런으로 규칙을 검증합니다:

<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>

응답에서 변경된 `payment_amount: 135000`과 `generatedVariables`의 `payment_amount__delta: -15000`(룰이 적용한 부호 포함 변화량)이 출력되면 성공입니다.

## 4단계: 발행 및 배포

<Steps>
  <Step title="발행">
    **버전 발행**을 클릭합니다. 버전이 DRAFT에서 ACTIVE로 전환되며 잠깁니다 — 더 이상 편집할 수 없습니다.
  </Step>

  <Step title="배포">
    **라이브 배포**를 클릭합니다. 배포 메모를 입력하고 확인합니다.
    정책이 이제 라이브 상태이며 트래픽을 처리합니다.
  </Step>
</Steps>

## 5단계: API로 실행

애플리케이션에서 실행 엔드포인트를 호출합니다:

<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>

## 다음 단계

<CardGroup cols={2}>
  <Card title="팩트 정의" icon="table-columns" href="/ko/guides/fact-definitions">
    `customer_tier`, `order_region` 같은 커스텀 변수를 추가합니다.
  </Card>

  <Card title="변경 영향 시뮬레이션" icon="flask-vial" href="/ko/guides/simulation">
    배포 전에 대량 데이터로 정책을 테스트합니다.
  </Card>

  <Card title="정책 실행" icon="bolt" href="/ko/api/execution">
    4가지 실행 모드(단일, 버전, 배치, 복합)를 알아봅니다.
  </Card>

  <Card title="CLI & MCP" icon="terminal" href="/ko/cli/introduction">
    터미널 또는 AI 에이전트로 정책을 관리합니다.
  </Card>
</CardGroup>
