> ## Documentation Index
> Fetch the complete documentation index at: https://developer.lulacommerce.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Menu Rules by ID

> Retrieve detailed configuration and status information for a specific menu rule, including its conditions, actions, execution history, and performance metrics.

This endpoint provides comprehensive details about a specific menu rule, enabling detailed analysis, troubleshooting, and optimization of individual rule configurations and their business impact.

<Info>
  Individual rule retrieval provides deep insights into rule behavior, execution patterns, and business impact, supporting data-driven optimization and troubleshooting of menu automation logic.
</Info>

### Path Parameters

<ParamField path="store_id" type="string" required>
  The unique identifier of the store containing the menu rule
</ParamField>

<ParamField path="rule_id" type="string" required>
  The unique identifier of the menu rule to retrieve
</ParamField>

### Query Parameters

<ParamField query="include_history" type="boolean" optional default="false">
  Include rule execution history and performance metrics
</ParamField>

<ParamField query="include_impact_analysis" type="boolean" optional default="false">
  Include business impact analysis and effectiveness metrics
</ParamField>

<ParamField query="date_range" type="string" optional>
  Date range for historical data (format: YYYY-MM-DD,YYYY-MM-DD)
</ParamField>

### Response

<ResponseField name="rule" type="object">
  Complete rule configuration and metadata
</ResponseField>

<ResponseField name="execution_status" type="object">
  Current rule status and next scheduled evaluation
</ResponseField>

<ResponseField name="execution_history" type="array" optional>
  Historical execution records and outcomes (if requested)
</ResponseField>

<ResponseField name="impact_analysis" type="object" optional>
  Business impact metrics and effectiveness analysis (if requested)
</ResponseField>

### Response Example

```json theme={null}
{
    "rule": {
        "rule_id": "rule_456",
        "rule_name": "Happy Hour Beverage Pricing",
        "rule_type": "pricing",
        "is_active": true,
        "priority": 10,
        "conditions": {
            "time_range": {
                "start": "15:00",
                "end": "18:00"
            },
            "days_of_week": ["monday", "tuesday", "wednesday", "thursday", "friday"],
            "date_exceptions": ["2024-12-25", "2024-01-01"]
        },
        "actions": {
            "adjust_pricing": {
                "type": "percentage",
                "value": -25,
                "round_to": 0.05
            },
            "apply_promotional_tag": "happy_hour"
        },
        "scope": {
            "apply_to_categories": ["beverages", "appetizers"],
            "exclude_items": ["premium_wine", "specialty_cocktails"],
            "affected_item_count": 23
        },
        "effective_date_range": {
            "start_date": "2024-02-01",
            "end_date": "2024-03-31"
        },
        "created_at": "2024-01-15T10:30:00Z",
        "updated_at": "2024-01-20T14:45:00Z",
        "created_by": "manager_user_123"
    },
    "execution_status": {
        "current_status": "inactive",
        "last_execution": "2024-01-19T17:00:00Z",
        "next_evaluation": "2024-01-22T15:00:00Z",
        "execution_count_today": 0,
        "total_executions": 45,
        "last_execution_result": "success"
    },
    "execution_history": [
        {
            "execution_time": "2024-01-19T17:00:00Z",
            "execution_result": "success",
            "items_affected": 23,
            "duration_ms": 125,
            "conditions_met": true,
            "actions_executed": ["adjust_pricing", "apply_promotional_tag"]
        }
    ],
    "impact_analysis": {
        "revenue_impact": {
            "total_discount_applied": 1250.75,
            "affected_orders": 89,
            "average_order_increase": 15.5
        },
        "customer_engagement": {
            "happy_hour_orders": 89,
            "repeat_customers": 34,
            "customer_satisfaction_score": 4.2
        },
        "operational_metrics": {
            "kitchen_efficiency": "improved",
            "inventory_turnover": "increased",
            "staff_feedback": "positive"
        }
    }
}
```

<Accordion title="Rule Detail Categories">
  **Configuration Details**

  * Complete rule setup including conditions and actions
  * Scope definition and affected items/categories
  * Priority and conflict resolution information
  * Effective date ranges and scheduling details

  **Execution Information**

  * Current rule status and evaluation schedule
  * Historical execution patterns and success rates
  * Performance metrics and execution timing
  * Error logs and troubleshooting information

  **Business Impact Analysis**

  * Revenue impact from rule applications
  * Customer behavior changes and engagement metrics
  * Operational efficiency improvements
  * Competitive positioning and market response

  **Performance Metrics**

  * Rule execution frequency and patterns
  * System performance impact and optimization opportunities
  * Integration effectiveness across platforms
  * Customer satisfaction and experience metrics
</Accordion>

<Note>
  **Data Availability**: Historical and impact analysis data may have retention limits. Specify appropriate date ranges to ensure you receive the data you need for analysis.
</Note>

<Tip>
  **Performance Monitoring**: Use the execution history to identify optimization opportunities and troubleshoot rule performance issues for better business outcomes.
</Tip>

### Use Cases

<Accordion title="Common Rule Analysis Scenarios">
  **Rule Performance Optimization**

  * Analyze execution patterns to optimize rule timing
  * Identify performance bottlenecks in rule evaluation
  * Optimize rule conditions for better targeting
  * Improve rule effectiveness through data-driven adjustments

  **Business Impact Assessment**

  * Measure revenue impact of pricing and promotional rules
  * Analyze customer response to availability changes
  * Evaluate operational efficiency improvements
  * Assess competitive positioning and market response

  **Troubleshooting and Debugging**

  * Investigate unexpected rule behavior or conflicts
  * Analyze execution failures and error patterns
  * Validate rule logic against business requirements
  * Identify integration issues with external systems

  **Compliance and Auditing**

  * Review rule changes and approval history
  * Validate rule compliance with business policies
  * Generate audit reports for regulatory requirements
  * Document rule effectiveness for business reviews
</Accordion>

### Execution Status Details

<Accordion title="Understanding Execution Status">
  **Current Status Values**

  * `active`: Rule is currently executing actions
  * `inactive`: Rule conditions are not met
  * `scheduled`: Rule is waiting for next evaluation time
  * `disabled`: Rule is manually disabled
  * `error`: Rule has encountered execution errors
  * `expired`: Rule has passed its effective date range

  **Execution Timing**

  * `last_execution`: When the rule was last evaluated
  * `next_evaluation`: When the rule will be evaluated next
  * `execution_count_today`: Number of executions in the current day
  * `total_executions`: Lifetime execution count for the rule

  **Performance Metrics**

  * `execution_duration`: Time taken for rule evaluation and action execution
  * `success_rate`: Percentage of successful rule executions
  * `error_frequency`: Rate of execution errors and failures
  * `system_impact`: Resource utilization during rule execution

  **Result Information**

  * `items_affected`: Number of items impacted by the rule
  * `actions_executed`: List of actions successfully completed
  * `conditions_met`: Which conditions triggered the rule execution
  * `conflict_resolution`: How conflicts with other rules were resolved
</Accordion>

### Historical Analysis

<Accordion title="Execution History Insights">
  **Execution Patterns**

  * Daily, weekly, and monthly execution frequency
  * Seasonal patterns and trends in rule activation
  * Correlation between rule execution and business events
  * Peak execution times and system load patterns

  **Success and Failure Analysis**

  * Success rates and common failure modes
  * Error patterns and system integration issues
  * Performance degradation trends over time
  * Recovery patterns after system issues

  **Business Impact Trends**

  * Revenue impact trends over time
  * Customer behavior changes and adaptation patterns
  * Operational efficiency improvements and challenges
  * Competitive response and market dynamics

  **Optimization Opportunities**

  * Timing optimization based on execution patterns
  * Condition refinement for better targeting
  * Action optimization for improved effectiveness
  * Performance improvements through better rule design
</Accordion>

### Impact Analysis Metrics

<Accordion title="Business Impact Measurement">
  **Revenue Impact**

  * `total_discount_applied`: Cumulative discount amount from pricing rules
  * `revenue_increase`: Revenue growth attributed to rule optimization
  * `average_order_value_change`: Impact on customer spending patterns
  * `profit_margin_impact`: Effect on business profitability

  **Customer Engagement**

  * `affected_orders`: Number of orders impacted by the rule
  * `repeat_customers`: Customer retention and repeat business
  * `customer_satisfaction_score`: Customer experience metrics
  * `new_customer_acquisition`: Attraction of new customers through rule benefits

  **Operational Metrics**

  * `kitchen_efficiency`: Impact on food preparation and service
  * `inventory_turnover`: Effect on inventory management and waste
  * `staff_productivity`: Impact on staff efficiency and workload
  * `delivery_performance`: Effect on delivery and fulfillment operations

  **Market Position**

  * `competitive_advantage`: Competitive positioning improvements
  * `market_share_impact`: Effect on market position and customer capture
  * `brand_perception`: Impact on brand image and customer perception
  * `pricing_competitiveness`: Positioning relative to market pricing
</Accordion>

### Error Handling

<Accordion title="Common Error Scenarios">
  **Rule Not Found**

  ```json theme={null}
  {
    "error": "Rule not found",
    "message": "The specified rule ID does not exist for this store",
    "details": {
      "store_id": "store_123",
      "rule_id": "invalid_rule_id"
    }
  }
  ```

  **Permission Denied**

  ```json theme={null}
  {
    "error": "Permission denied",
    "message": "Insufficient permissions to view detailed rule information"
  }
  ```

  **Invalid Date Range**

  ```json theme={null}
  {
    "error": "Invalid date range",
    "message": "The specified date range is invalid or exceeds maximum allowed period",
    "details": {
      "provided_range": "2024-01-01,2025-01-01",
      "maximum_days": 90
    }
  }
  ```

  **Data Not Available**

  ```json theme={null}
  {
    "error": "Data not available",
    "message": "Historical data for the requested period is not available",
    "details": {
      "requested_date_range": "2023-01-01,2023-12-31",
      "available_from": "2024-01-01"
    }
  }
  ```
</Accordion>

### Best Practices

<Accordion title="Rule Analysis Best Practices">
  **Regular Monitoring**

  * Schedule regular reviews of rule performance and impact
  * Monitor execution patterns for optimization opportunities
  * Track business impact metrics consistently
  * Identify and address performance issues promptly

  **Data-Driven Optimization**

  * Use execution history to optimize rule timing and conditions
  * Analyze impact metrics to improve rule effectiveness
  * Identify successful patterns for replication across other rules
  * Use performance data to guide rule design decisions

  **Troubleshooting Strategy**

  * Review execution history when investigating issues
  * Analyze error patterns to identify systematic problems
  * Use impact analysis to assess the severity of rule issues
  * Implement monitoring alerts for critical rule failures

  **Business Intelligence Integration**

  * Integrate rule data with broader business analytics
  * Use rule impact metrics in business performance dashboards
  * Correlate rule effectiveness with broader business outcomes
  * Support strategic decision-making with rule performance data
</Accordion>

### Analytics and Reporting

<Accordion title="Rule Performance Analytics">
  **Performance Dashboard Creation**

  * Create visualizations of rule execution patterns
  * Monitor business impact trends over time
  * Track customer satisfaction and engagement metrics
  * Display operational efficiency improvements

  **Comparative Analysis**

  * Compare rule effectiveness across different time periods
  * Analyze performance variations by day of week or season
  * Compare similar rules across different stores or locations
  * Benchmark rule performance against business objectives

  **Predictive Analytics**

  * Forecast rule impact based on historical patterns
  * Predict optimal timing for rule modifications
  * Anticipate customer response to rule changes
  * Model business impact of proposed rule modifications

  **ROI Analysis**

  * Calculate return on investment for rule automation
  * Measure cost savings from operational efficiency
  * Analyze revenue impact relative to implementation costs
  * Evaluate long-term business value of rule strategies
</Accordion>

### Integration with Business Intelligence

<Accordion title="BI Integration Strategies">
  **Data Export and Integration**

  * Export rule data for integration with BI tools
  * Create data pipelines for real-time analytics
  * Integrate with existing business intelligence platforms
  * Support custom reporting and analysis requirements

  **Real-time Monitoring**

  * Implement real-time rule performance dashboards
  * Create alerts for rule performance anomalies
  * Monitor business impact in real-time
  * Support rapid response to rule issues

  **Strategic Planning Support**

  * Use rule data to inform menu strategy decisions
  * Support competitive analysis and positioning
  * Guide investment in menu automation capabilities
  * Inform customer experience optimization strategies

  **Compliance and Governance**

  * Generate compliance reports for audit requirements
  * Track rule changes and their business justification
  * Monitor adherence to business policies and guidelines
  * Support regulatory reporting and documentation needs
</Accordion>

### Rule Optimization Workflow

<Accordion title="Continuous Improvement Process">
  **Regular Review Process**

  1. **Performance Assessment**: Analyze execution patterns and success rates
  2. **Impact Evaluation**: Measure business impact and customer response
  3. **Optimization Identification**: Identify opportunities for improvement
  4. **Testing and Validation**: Test proposed changes in controlled environments
  5. **Implementation**: Deploy optimized rules with monitoring
  6. **Monitoring and Feedback**: Track improvements and gather feedback

  **Data-Driven Decision Making**

  * Use historical execution data to guide optimization decisions
  * Leverage impact analysis to prioritize optimization efforts
  * Apply statistical analysis to identify significant patterns
  * Test hypotheses through controlled rule modifications

  **Continuous Learning**

  * Document lessons learned from rule optimization efforts
  * Share best practices across teams and locations
  * Build organizational knowledge about effective rule design
  * Develop expertise in menu automation and optimization
</Accordion>
