Skip to main content

Endpoint

POST /rules/redirect/:redirectId
Creates a new rule for the specified redirect. The rule will be created with the lowest priority (highest number) by default.

Path parameters

redirectId
string
required
The ID of the redirect to add the rule to

Request body

name
string
required
Human-readable name for the rule
description
string
Optional description explaining the rule’s purpose
type
RuleType
required
Rule type: force, percentage, or ab_experiment
conditions
RuleCondition[]
required
Array of conditions to evaluate. At least one condition is required.
conditionLogic
ConditionLogic
required
How to combine multiple conditions: AND (all must match) or OR (any must match)
action
RuleAction
required
Action to perform when rule matches
startDate
string
ISO 8601 date when rule becomes active
endDate
string
ISO 8601 date when rule expires
metadata
Record<string, string | number | boolean>
Optional metadata key-value pairs

Response

message
string
Success message
rule
Rule
The created rule object

Examples

import { createRule } from '@quickleap/sdk';

const response = await createRule('redirect_123', {
  name: 'Mobile users to app',
  description: 'Redirect mobile traffic to mobile app',
  type: 'force',
  conditions: [
    {
      attribute: 'device_type',
      operator: 'equals',
      value: 'mobile'
    }
  ],
  conditionLogic: 'AND',
  action: {
    type: 'redirect',
    url: 'https://app.example.com'
  }
});

console.log(response.data.rule);
New rules are created with status draft by default. Use the toggle status endpoint to activate them.