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
The ID of the redirect to add the rule to
Request body
Human-readable name for the rule
Optional description explaining the rule’s purpose
Rule type: force, percentage, or ab_experiment
Array of conditions to evaluate. At least one condition is required.Show RuleCondition properties
The user attribute to evaluate (e.g., country, device_type, browser_name)
Comparison operator (e.g., equals, contains, in, greater_than)
value
string | number | string[] | number[] | [number, number]
Value to compare against. Type depends on operator:
- Single value for
equals, contains, etc.
- Array for
in, not_in
- Range tuple for
between
- Omit for
exists, not_exists
Required when attribute is query_param. Specifies which query parameter to check.
How to combine multiple conditions: AND (all must match) or OR (any must match)
Action to perform when rule matchesShow RedirectAction (for type: force)
Destination URL for redirect
Show PercentageRedirectAction (for type: percentage)
Must be percentage_redirect
Destination URL for redirected percentage
Percentage of traffic to redirect (0-100)
Show ABTestAction (for type: ab_experiment)
Array of test variants. Percentages must sum to 100.Traffic percentage for this variant (0-100)
Destination URL for variant
ISO 8601 date when rule becomes active
ISO 8601 date when rule expires
metadata
Record<string, string | number | boolean>
Optional metadata key-value pairs
Response
The created rule object
Evaluation priority (lower = higher priority)
Current status: active, inactive, or draft
Condition combination logic
Number of times rule has matched
User who created the rule
metadata
Record<string, string | number | boolean>
Custom metadata
Creation timestamp (ISO 8601)
Last update timestamp (ISO 8601)
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);