Execute Scoring Rules

Scoring rules for a module can be executed by the scoring rule ids or using the layout id. All scoring rules must correspond to the same module when using the scoring rule ids. All active rules for the specified layout will be executed if executed by layout id. If there is no request body, all active rules for the specified module will be scheduled for execution. The rules will be applied to records that were created or had their most recent activity time within the last 6 months.

Purpose

To execute scoring rules for a module in the organization.

Request Details

Request URL

{api-domain}/crm/{version}/{module_api_name}/actions/run_scoring_rules

Supported modules

Leads, Accounts, Contacts, Deals and Custom

Header

Authorization: Zoho-oauthtoken d92d4xxxxxxxxxxxxx15f52

Scope

scope=ZohoCRM.settings.scoring_rules.ALL
(or)
scope=ZohoCRM.settings.scoring_rules.{operation_type}

Possible operation types

ALL - Full access to scoring rules
Update - Execute scoring rules

Sample Request

Copiedcurl "https://www.zohoapis.com/crm/v7/Leads/actions/run_scoring_rules"
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
-X PUT
-d @executerules.json

Scoring Rule execution using Rule IDs

Scoring rules can be scheduled to be executed, using the scoring rule IDs. In this case, all the scoring rules must belong to the same module. Upto five active rules can be executed using this method.

Input JSON Keys

  • scoring_rulesJSON array, mandatory

    Represents the unique IDs of the scoring rules to be executed.

Sample Input

Copied{
    "scoring_rules" : [
        "4876876000000965604",
        "4876876000000945002"
    ]
}

Scoring Rule execution using Layout ID

If you want to execute all active scoring rules for a specific layout of a module, you can do so by specifying the layout ID in the input body.

Input JSON Keys

  • layoutJSON object, mandatory

    Represents the unique ID of the of the layout for which the scoring rules are to be executed.

Sample Input

Copied{
    "layout" : {
            "id" :"4876876000000091055"   
    }
}

Possible Errors

  • INVALID_URL_PATTERNHTTP 404

    Please check if the URL trying to access is a correct one
    Resolution: The request URL specified is incorrect. Specify a valid request URL. Refer to request URL section above.

  • OAUTH_SCOPE_MISMATCHHTTP 401

    Unauthorized
    Resolution: Client does not have the required scope. Create a new client with valid scope. Refer to scope section above for more details.

  • NO_PERMISSIONHTTP 403

    Permission denied to execute
    Resolution: The user does not have permission to execute scoring rules. Contact your system administrator.

  • INTERNAL_ERRORHTTP 500

    Internal Server Error
    Resolution: Unexpected and unhandled exception in Server. Contact support team.

  • INVALID_REQUEST_METHODHTTP 400

    The http request method type is not a valid one
    Resolution: You have specified an invalid HTTP method to access the API URL. Specify a valid request method. Refer to endpoints section above.

  • AMBIGUITY_DURING_PROCESSINGHTTP 400

    You have specified both Layout ID and Scoring Rule ID in the input body.
    Resolution: Specify either the layout ID or Scoring Rule IDs to be executed.

  • INVALID_DATAHTTP 400

    Scoring Rule Id or Layout Id seems to be invalid
    Resolution: Please specify valid rule id or layout id for execution.

  • INVALID_DATAHTTP 400

    Module name seems to be invalid
    Resolution: Please specify a valid and supported module name in the request URL.

  • INVALID_DATAHTTP 400

    Given ID does not belong the specified module
    Resolution: Specify Scoring Rules corresponding to the specified module.

  • INVALID_DATAHTTP 400

    More than 5 active scoring rules are given for execution
    Resolution: Limit the number of rules to be executed to 5 when executing by Rule Ids.

  • CANNOT_PERFORM_ACTIONHTTP 400

    The specified module has no Scoring Rules for any layout
    Resolution: Please create Scoring Rules or specify another valid module.

Sample Response

CopiedExecution by Layout ID:
{
    "code": "SCHEDULED",
    "details": {
        "job_id": "4876876000000984011"
    },
    "message": "The scoring rules of the specified layout successfully scheduled to run",
    "status": "success"
}

Execution by Scoring Rule ids:
{
    "scoring_rules": [
        {
            "code": "SCHEDULED",
            "details": {
                "job_id": "4876876000000984013"
            },
            "message": "scoring rules successfully scheduled to run",
            "status": "success"
        },
        {
            "code": "SCHEDULED",
            "details": {
                "job_id": "4876876000000984013"
            },
            "message": "scoring rules successfully scheduled to run",
            "status": "success"
        }
    ]
}