Skip to main content
POST
/
api
/
rules
curl -X POST https://api.linquid.io/api/rules \
  -H "X-API-Key: lw_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "linkId": "link_abc123",
    "name": "Mobile iOS Users in US",
    "destinationUrl": "https://apps.apple.com/app/myapp",
    "conditions": [
      {
        "field": "deviceType",
        "operator": "equals",
        "value": "mobile"
      },
      {
        "field": "os",
        "operator": "equals",
        "value": "iOS"
      },
      {
        "field": "country",
        "operator": "equals",
        "value": "US"
      }
    ],
    "conditionLogic": "AND",
    "priority": 1
  }'
{
  "success": true,
  "data": {
    "id": "rule_def456",
    "linkId": "link_abc123",
    "name": "Mobile iOS Users in US",
    "destinationUrl": "https://apps.apple.com/app/myapp",
    "conditions": [
      { "field": "deviceType", "operator": "equals", "value": "mobile" },
      { "field": "os", "operator": "equals", "value": "iOS" },
      { "field": "country", "operator": "equals", "value": "US" }
    ],
    "conditionLogic": "AND",
    "priority": 1,
    "enabled": true,
    "createdAt": "2024-01-15T10:30:00.000Z"
  }
}

Request Body

The link to attach this rule to
name
string
required
Display name for the rule
destinationUrl
string
required
URL to redirect when rule matches
conditions
array
required
Array of condition objects
conditionLogic
string
default:"AND"
How to combine conditions: AND or OR
priority
number
Evaluation order (lower = higher priority)
enabled
boolean
default:"true"
Whether the rule is active
description
string
Optional description

Condition Object

Each condition has the following structure:
FieldTypeDescription
fieldstringTargeting field to evaluate
operatorstringComparison operator
valuestring/arrayValue(s) to compare against

Available Fields

Location

country, region, city, timezone, isp, asn, latitude, longitude

Device

deviceType, os, osVersion, browser, browserVersion, deviceBrand

Network

vpn, proxy, tor, datacenter, bot, isCrawler

Traffic

referrer, referrerDomain, utmSource, utmMedium, utmCampaign, utmTerm, utmContent

Time

hour, dayOfWeek

Visitor

isNewVisitor, isReturning

Operators

OperatorDescriptionExample
equalsExact matchcountry equals "US"
not_equalsDoes not matchcountry not_equals "CN"
containsString containsreferrer contains "google"
not_containsString doesn’t containreferrer not_contains "spam"
inValue in arraycountry in ["US", "CA", "UK"]
not_inValue not in arraycountry not_in ["CN", "RU"]
greater_thanNumeric comparisonhour greater_than 17
less_thanNumeric comparisonhour less_than 9
is_trueBoolean truevpn is_true
is_falseBoolean falsebot is_false
curl -X POST https://api.linquid.io/api/rules \
  -H "X-API-Key: lw_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "linkId": "link_abc123",
    "name": "Mobile iOS Users in US",
    "destinationUrl": "https://apps.apple.com/app/myapp",
    "conditions": [
      {
        "field": "deviceType",
        "operator": "equals",
        "value": "mobile"
      },
      {
        "field": "os",
        "operator": "equals",
        "value": "iOS"
      },
      {
        "field": "country",
        "operator": "equals",
        "value": "US"
      }
    ],
    "conditionLogic": "AND",
    "priority": 1
  }'
{
  "success": true,
  "data": {
    "id": "rule_def456",
    "linkId": "link_abc123",
    "name": "Mobile iOS Users in US",
    "destinationUrl": "https://apps.apple.com/app/myapp",
    "conditions": [
      { "field": "deviceType", "operator": "equals", "value": "mobile" },
      { "field": "os", "operator": "equals", "value": "iOS" },
      { "field": "country", "operator": "equals", "value": "US" }
    ],
    "conditionLogic": "AND",
    "priority": 1,
    "enabled": true,
    "createdAt": "2024-01-15T10:30:00.000Z"
  }
}