Skip to main content

Prerequisites

  • A LexQ account (sign up free)
  • An API key (created in Console → Management → API Keys)

Step 1: Create a Policy Group

1

Open the Console

Navigate to console.lexq.io and sign in.
2

Create a Group

Go to Policy GroupsCreate Group.
  • Name: discount-policy
  • Priority: 0
  • Activation Mode: Allow All
3

Create a Version

Inside your new group, click Create New Draft. This creates a DRAFT version where you can add rules.

Step 2: Define a Rule

1

Add a Rule

In the Rule Edit tab, click Add Rule.
  • Name: VIP Discount
  • Priority: 0
2

Set the Condition

Add a condition:
payment_amount >= 100000
3

Add an Action

Add a DISCOUNT action:
  • Method: Percentage
  • Rate: 10 (10% discount)
  • Reference Fact: payment_amount

Step 3: Test with Dry Run

Before deploying, validate your rule with a dry run:
curl -X POST https://api.lexq.io/v1/analytics/groups/{groupId}/versions/{versionId}/dry-run \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "facts": {
      "payment_amount": 150000
    }
  }'
You should see the discount action fired in the response.

Step 4: Publish & Deploy

1

Publish

Click Publish Version. The version is now locked — no further edits allowed.
2

Deploy

Click Deploy to Live. Enter a deployment memo and confirm. Your policy is now live and processing traffic.

Step 5: Execute via API

Call the execution endpoint from your application:
curl -X POST https://api.lexq.io/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"
    }
  }'

What’s Next?