Skip to main content
Routing rules let you change a node’s behavior without modifying the node itself. Each node can have multiple rules evaluated top-to-bottom by priority. The first matching rule wins. If no rule matches, the node’s base payload is used as a fallback.

Rule Types

Route based on time of day and day of week. Perfect for office hours vs. after-hours destinations.
{
  "rule_type": "time_based",
  "conditions": {
    "timezone": "Europe/Zurich",
    "windows": [
      {
        "days": [1, 2, 3, 4, 5],
        "start_time": "08:00",
        "end_time": "18:00"
      }
    ]
  },
  "function_type": "redirect",
  "payload": { "url": "https://acme.com/open" }
}
Use case: A restaurant QR code routes to the lunch menu from 11:00–14:00 and the dinner menu from 18:00–22:00.

Priority & Evaluation

Rules are evaluated in ascending priority order (lower number = higher priority).
Priority 0: Time-based → Office hours redirect
Priority 1: Geo → DACH region redirect
Priority 2: Device → Mobile app redirect
Priority 3: Default → Base payload (fallback)
The first rule that matches is used. Remaining rules are skipped.

Creating Rules via API

curl -X POST https://nearnode.io/api/v1/nodes/k9m2xp4q/rules \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "label": "Office Hours",
    "priority": 0,
    "rule_type": "time_based",
    "conditions": {
      "timezone": "Europe/Zurich",
      "windows": [{ "days": [1,2,3,4,5], "start_time": "08:00", "end_time": "18:00" }]
    },
    "function_type": "redirect",
    "payload": { "url": "https://acme.com/welcome" }
  }'