Delete Alerts

Delete the specified alerts from the workspace.

REQUEST URI

https://<ZohoAnalytics_Server_URI>/restapi/v2/workspaces/<workspace-id>/alerts

Delete

oauthscope: ZohoAnalytics.modeling.delete

QUERY PARAMETERS

 

Parameter Name
Description
CONFIG*JSONObject
Config parameter specifications are available in the below section.

FIELDS FOR CONFIG JSON

 

Key
Description
alertIds*JSONArray
The IDs of the alerts to delete, sent as strings.
Supported range - 0 to 1000 IDs. An empty array deletes no alert.
All the alerts must belong to the specified workspace.

Sample: {"alertIds":["137687000010815003","137687000010815005"]}

Note: The alerts are deleted only if every ID in the list is valid. If any ID is invalid, no alert is deleted.

Note: Deleted alerts cannot be restored. To stop an alert temporarily, use the Change Alert Status API.

Sample Request:

Copiedcurl "https://analyticsapi.zoho.com/restapi/v2/workspaces/35130000001055707/alerts" -X 'DELETE' -H 'ZANALYTICS-ORGID: <org-id>' -H 'Authorization: Zoho-oauthtoken <access_token>' --data-urlencode 'CONFIG={"alertIds":["137687000010815003","137687000010815005"]}'
Copiedusing System;
using System.Collections.Generic;
using System.Text.Json;
using ZohoAnalytics;

namespace ZohoAnalyticsTest
{
    class Program
    {
        long orgId = 55522777;
        long workspaceId = 35130000001055707;

        public void DeleteAlerts(IAnalyticsClient ac)
        {
            List<long> alertIds = new List<long>();
            alertIds.Add(137687000010815003L);
            alertIds.Add(137687000010815005L);
            IWorkspaceAPI workspace = ac.GetWorkspaceInstance(orgId, workspaceId);
            workspace.DeleteAlerts(alertIds, null);
            Console.WriteLine("success");
        }

        static void Main(string[] args)
        {
            string clientId = "1000.xxxxxxx";
            string clientSecret = "xxxxxxx";
            string refreshToken = "1000.xxxxxxx.xxxxxxx";
            IAnalyticsClient ac = new AnalyticsClient(clientId, clientSecret, refreshToken);
            Program obj = new Program();
            obj.DeleteAlerts(ac);
        }
    }
}
Copiedpackage main

import (
    "fmt"
    ZAnalytics "zoho/pkg/analyticsclient"
)

var (
    clientId = "1000.xxxxxxx"
    clientSecret = "xxxxxxx"
    refreshToken = "1000.xxxxxxx.xxxxxxx"
    orgId = "55522777"
    workspaceId = "35130000001055707"
)

func DeleteAlerts(ac ZAnalytics.Client) {
    alertids := []string{"137687000010815003", "137687000010815005"}
    workspace := ZAnalytics.GetWorkspaceInstance(&ac, orgId, workspaceId)
    exception := workspace.DeleteAlerts(alertids, nil)
    if exception != nil {
        fmt.Println(exception.ErrorMessage)
        return
    }
    fmt.Println("success")
}

func main() {
    ac := ZAnalytics.GetAnalyticsClient(clientId, clientSecret, refreshToken)
    DeleteAlerts(ac)
}
Copiedimport com.zoho.analytics.client.*;
import org.json.*;

public class Test {
    private long orgId = 55522777l;
    private long workspaceId = 35130000001055707l;

    public static void main(String args[]) {
        String clientId = "1000.xxxxxxx";
        String clientSecret = "xxxxxxx";
        String refreshToken = "1000.xxxxxxx.xxxxxxx";
        Test tObj = new Test();
        AnalyticsClient ac = new AnalyticsClient(clientId, clientSecret, refreshToken);
        try {
            tObj.deleteAlerts(ac);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public void deleteAlerts(AnalyticsClient ac) throws Exception {
        JSONArray alertIds = new JSONArray();
        alertIds.put("137687000010815003");
        alertIds.put("137687000010815005");
        WorkspaceAPI workspace = ac.getWorkspaceInstance(orgId, workspaceId);
        workspace.deleteAlerts(alertIds, null);
        System.out.println("success");
    }
}
Copied<?php
require 'AnalyticsClient.php';

class Test {
    public $ac;
    public $org_id = "55522777";
    public $workspace_id = "35130000001055707";

    function __construct() {
        $this->ac = new AnalyticsClient("1000.xxxxxxx", "xxxxxxx", "1000.xxxxxxx.xxxxxxx");
    }

    function deleteAlerts() {
        $alert_ids = array("137687000010815003", "137687000010815005");
        $workspace = $this->ac->getWorkspaceInstance($this->org_id, $this->workspace_id);
        $workspace->deleteAlerts($alert_ids);
        echo "success";
    }
}

$obj = new Test();
$obj->deleteAlerts();
?>
Copiedfrom AnalyticsClient import AnalyticsClient

class Config:
    CLIENTID = "1000.xxxxxxx"
    CLIENTSECRET = "xxxxxxx"
    REFRESHTOKEN = "1000.xxxxxxx.xxxxxxx"
    ORGID = "55522777"
    WORKSPACEID = "35130000001055707"

class Sample:
    ac = AnalyticsClient(Config.CLIENTID, Config.CLIENTSECRET, Config.REFRESHTOKEN)

    def delete_alerts(self, ac):
        alert_ids = ["137687000010815003", "137687000010815005"]
        workspace = ac.get_workspace_instance(Config.ORGID, Config.WORKSPACEID)
        workspace.delete_alerts(alert_ids)
        print("success")

obj = Sample()
obj.delete_alerts(obj.ac)
Copiedvar analyticsClient = require('./AnalyticsClient');
var ac = new analyticsClient('1000.xxxxxxx', 'xxxxxxx', '1000.xxxxxxx.xxxxxxx');
var orgId = '55522777';
var workspaceId = '35130000001055707';

var alertIds = ["137687000010815003", "137687000010815005"];
var workspace = ac.getWorkspaceInstance(orgId, workspaceId);
workspace.deleteAlerts(alertIds).then(() => { console.log("success"); }).catch((error) => { console.log(error); });
CopiedorgId = "55522777";
workspaceId = "35130000001055707";
headersMap = Map();
headersMap.put("ZANALYTICS-ORGID", orgId);
config = {"alertIds": ["137687000010815003", "137687000010815005"]};
response = invokeurl
parameters = "CONFIG=" + zoho.encryption.urlEncode(config.toString());
[
  url :"https://analyticsapi.zoho.com/restapi/v2/workspaces/" + workspaceId + "/alerts"
  type :DELETE
  parameters:parameters
  headers:headersMap
  connection:"analytics_oauth_connection"
];
info response;
Copiedrequire 'zoho_analytics_client'

class Config
  ORGID = "55522777"
  WORKSPACEID = "35130000001055707"
end

class Sample
  def initialize
    @ac = AnalyticsClient.new.with_data_center("US").with_oauth({
      "clientId" => "1000.xxxxxxx",
      "clientSecret" => "xxxxxxx",
      "refreshToken" => "1000.xxxxxxx.xxxxxxx"
    }).build
  end

  def delete_alerts
    alert_ids = ["137687000010815003", "137687000010815005"]
    workspace = @ac.get_workspace_instance(Config::ORGID, Config::WORKSPACEID)
    workspace.delete_alerts(alert_ids)
    puts "success"
  end
end

obj = Sample.new
obj.delete_alerts

Download client libraries:  C# | GO | JAVA | PHP | PYTHON | NodeJS | Ruby

Sample value for CONFIG parameter:

Copied{
  "alertIds": [
    "137687000010815003",
    "137687000010815005"
  ]
}

Sample Response:

CopiedHTTP/1.1 204 No Content