Product Selector

Fusion 5.12
    Fusion 5.12

    Create Custom Rule Actions with the API

    Custom rule actions allow you to define a unique action to take when certain conditions are met. They involve three primary components: a query pipeline, a custom rule type, and a rule that is triggered by conditions defined by the user.

    This article describes the general workflow for creating a custom rule action. The example assumes the following components are used:

    Component Name

    Query pipeline


    Custom rule type




    1. Create a query pipeline, custom-rule-pipeline, that is used to complete the rule action.

    2. Create a custom rule type, custom-rule-type, that uses your query pipeline. Here are some important parameters to include in your POST request:

      Required Parameter Description Example


      A unique ID for the custom rule type. The id value must be unique across all apps in Fusion (global namespace).



      The ID of the pipeline that is invoked during rule processing.



      A user-friendly name for the custom rule type.

      My Custom Rule

      Rule properties, included as part of the schema, define the values required from the user to create a rule that uses the custom rule type.


      The ID of the rule’s parameter. This field is used in the API but is not visible in the Rules Editor.



      The type of user-input.



      A user-friendly name for the parameter.



      A user-friendly description of what the field is used for. The description value is shown in the field’s tooltip in the Rules Editor.

      The manufacturer of the product this rule action applies to.

      For example:

    curl -u USERNAME:PASSWORD -XPOST -H "Content-type:application/json" \
    https://FUSION_HOST:6764/api/apps/{app-name}/custom-rule-types -d '{
      "display_type":"My Custom Rule",
      "schema": {
        "type" : "object",
        "properties" : {
          "custom_param1" : {
            "type" : "string",
            "title" : "Manufacturer",
            "description" : "The manufacturer of the product this rule action applies to."
          "custom_param2" : {
            "type": "string",
            "title": "Type",
            "description": "The type of product this rule action applies to."
    1. Verify the custom rule type was created by visiting https://FUSION_HOST:6764/api/apps/myFusionApp/custom-rule-types. Custom rule types are also available in the Rules Editor:

      Custom Rule Type in the Rules Editor

    2. Create a rule, custom-rule-action, that uses your custom rule, custom-rule-type. If you are creating the rule using the Query Rewrite API, the following image depicts which parameters are shared between the custom rule type and the rule:

      Custom rule type and rule parameters

      Note that the custom rule type id value is used for the rule’s type and custom_type fields. Remember to assign values to the custom rule properties, custom_param1 and custom_param2.

      curl -u USERNAME:PASSWORD -XPOST -H "Content-type:application/json" \
      http://localhost:6764/api/apps/myFusionApp/query-rewrite/instances -d '{
        "name":"My Rule",
        "description":"A rule that uses my custom rule, custom-rule-type.",
        "search_terms":["upcoming sale"],
        "display_type":"My Custom Rule"
    3. Verify your rule was created by checking the rule ID, 123456, with the Query Rewrite API: http://localhost:6764/api/apps/myFusionApp/query-rewrite/instances/123456

    4. Test your custom rule using your normal rule development process.