Update Alert
Update the configuration of the specified alert.
REQUEST URI
https://<ZohoAnalytics_Server_URI>/restapi/v2/workspaces/<workspace-id>/alerts/<alert-id>
Put
oauthscope: ZohoAnalytics.modeling.update
QUERY PARAMETERS
| Description |
|---|---|
| CONFIG* | JSONObject Config parameter specifications are available in the below section. |
FIELDS FOR CONFIG JSON
| Description |
|---|---|
| Alert details | |
| alertName* | String The name of the alert. Must be unique within the view. Maximum length - 100 characters. The complete configuration replaces the existing configuration, so the name must be specified even if it is not changed. Sample: {"alertName":"Sales Drop Alert"} |
| summaryType | String The slice of the report data against which the rules are evaluated. Supported values: "data", "subTotal", "grandTotal" Maximum length - 50 characters. Default value - data. This attribute is mandatory when the view is a pivot table. Check the table summaryType Values for more details. Sample: {"summaryType":"subTotal"} |
| rowAxis | String The viewColumnIndex of the row axis column of a pivot or summary view, sent as a string.This attribute is mandatory when summaryType is subTotal on a pivot or summary view.Sample: {"rowAxis":"1"} |
| columnAxis | String The viewColumnIndex of the column axis column of a pivot or summary view, sent as a string.Sample: {"columnAxis":"5"} |
| conditionExpression | String The expression that combines the rules using their position in rules, starting from 1.Supported tokens: rule numbers, AND, OR, ( and ).Maximum length - 1000 characters. Default value - (1). This attribute is mandatory when rules has more than one rule.Sample: {"conditionExpression":"(1 AND 2) OR 3"} |
| notifyOnChange | Boolean Controls whether a notification is sent only when the alert condition changes from unmet to met, instead of on every evaluation in which the condition is met. Supported values: "true", "false" Default value - false. If not specified, the value is reset to false. Sample: {"notifyOnChange":true} |
| isAnomaly | Boolean Indicates whether the rules of the alert are anomaly rules. This attribute is accepted but ignored. The value is derived from rules.Sample: {"isAnomaly":false} |
| Schedule | |
| scheduleDetails* | JSONObject The schedule on which the alert is evaluated. Maximum length - 5000 characters. The complete schedule must be specified. It replaces the existing schedule. Check the table scheduleDetails Fields for more details. Sample: {"scheduleDetails":{"calendarFrequency":"daily","hour":9,"minute":0}} |
| Notification channels | |
| JSONObject The email notification settings of the alert. Maximum length - 10000 characters. If not specified, the existing email channel is removed. Check the table email Fields for more details. Sample: {"email":{"notifyAdmins":true,"subject":"Sales dropped below threshold","message":"Please review the report."}} | |
| notification | JSONObject The in-app notification settings of the alert. Maximum length - 10000 characters. If not specified, the existing in-app notification channel is removed. Check the table notification Fields for more details. Sample: {"notification":{"notifyAdmins":true,"notifySharedUsers":false,"subject":"Sales spike detected","message":"An anomaly was detected on Sales."}} |
| slack | JSONObject The Slack incoming webhook settings of the alert. Maximum length - 50000 characters. If not specified, the existing Slack channel is removed. Check the table slack and msteams Fields for more details. Sample: {"slack":{"url":"https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXX","messageType":"STANDARD","subject":"New East/West orders","message":"Orders from the East and West regions were detected."}} |
| msteams | JSONObject The Microsoft Teams incoming webhook settings of the alert. Uses the same structure as slack.Maximum length - 50000 characters. If not specified, the existing Microsoft Teams channel is removed. Check the table slack and msteams Fields for more details. Sample: {"msteams":{"url":"https://example.webhook.office.com/webhookb2/00000000-0000-0000-0000-000000000000","messageType":"CUSTOM","payload":"{\"text\":\"New East/West orders detected\"}"}} |
| webhook | JSONObject The webhook settings of the alert. Maximum length - 100000 characters. If not specified, the existing webhook channel is removed. Check the table webhook Fields for more details. Sample: {"webhook":{"url":"https://example.com/zoho-analytics/audit-hook","method":"POST","body":"{\"event\":\"biennialAudit\"}"}} |
| Zoho Flow mappings | |
| workflows | JSONArray The Zoho Flow workflows that are already mapped to the alert. Only existing mappings can be retained. New mappings cannot be created using this API. Maximum length - 10000 characters. If not specified, the existing workflow mappings are removed. Check the table workflows Fields for more details. Sample: {"workflows":[{"id":"137687000012564035"},{"id":"137687000012564054"}]} |
| actionsByFlow | JSONArray The Zoho Flow actions that are already mapped to the alert. Only existing mappings can be retained. New mappings cannot be created using this API. Maximum length - 100000 characters. If not specified, the existing action mappings are removed. Check the table actionsByFlow Fields for more details. Sample: {"actionsByFlow":[{"actionConfigName":"Notify sales channel","actionConfigId":"137687000012564035","connectionId":"137687000012564041"}]} |
| Rules | |
| rules* | JSONArray The rules against which the report data is evaluated. Supported range - 1 to 10 rules. Maximum length - 100000 characters. The complete list of rules must be specified. It replaces the existing rules. Check the table rules Fields for more details. Sample: {"rules":[{"operator":"lt","viewColumnIndex":"2","type":"constant","values":["1000"]}]} |
| Validation | |
| validateSystemTags | Boolean Controls whether the Data Warning system tags of the view are validated when the alert attaches the report to an email. When true and the view has a restricted Data Warning tag, the alert is not updated. Set it to false to skip the validation. This attribute has no effect when the report is not attached. Supported values: "true", "false" Default value - true. Sample: {"validateSystemTags":false} |
Note: The specified configuration replaces the existing configuration of the alert, and attributes that are not specified are not retained. Get the current configuration using the Get Alert Configuration API, edit it, and send the complete configuration.
Note: At least one notification channel (email, notification, slack, msteams or webhook) must be specified. A channel without a recipient is not saved, and the alert is not updated if no other channel is available.
Note: The Zoho Cliq channel is not supported in this API.
summaryType Values
| Description |
|---|---|
| data | Evaluates the rules against the data rows of the report. Default value for chart and summary views. |
| subTotal | Evaluates the rules against the sub total rows. Supported only for pivot and summary views. rowAxis is mandatory for this value. |
| grandTotal | Evaluates the rules against the grand total row. Supported only for pivot and summary views. |
scheduleDetails Fields
| Description |
|---|---|
| Frequency and time zone | |
| calendarFrequency* | String How often the alert is evaluated. Supported values: "hourly", "daily", "weekly", "monthly", "yearly" The value is case-insensitive. Check the table calendarFrequency Values for more details. Sample: {"calendarFrequency":"daily"} |
| interval | Integer The number of calendarFrequency units between two evaluations.Supported values: hourly - 1, 2, 3, 4, 6 or 12. daily - 1 to 7. weekly - 1 to 4. monthly - 1 to 12. yearly - 1 to 5. Default value - 1. This attribute is mandatory for hourly frequency.Sample: {"interval":3} |
| timeZone | String The IANA time zone ID used to evaluate the schedule. For example, Asia/Kolkata, America/New_York, Europe/London or UTC.Default value - The time zone of the user profile. If it is not available, GMT is used. Sample: {"timeZone":"Asia/Kolkata"} |
| Time of day | |
| hour | Integer The hour of the day at which the alert is evaluated. Supported range - 0 to 23. This attribute is mandatory for all frequencies except hourly, and must not be specified for hourly.Sample: {"hour":9} |
| minute | Integer The minute of the hour at which the alert is evaluated. Supported values: multiples of 5 from 0 to 55. This attribute is mandatory for all frequencies except hourly, and must not be specified for hourly.Sample: {"minute":30} |
| Day selection | |
| skipWeekends | Boolean Controls whether the evaluations that fall on weekend days are skipped. The weekend days are based on the locale of the schedule time zone. For example, Sunday for Asia/Kolkata, and Saturday and Sunday for America/New_York.Supported values: "true", "false" Default value - false. Applicable only to hourly and daily frequencies.Sample: {"skipWeekends":true} |
| weekDays | JSONArray The days of the week on which the alert is evaluated. Multiple days can be specified. Supported values: 1 (Sunday) to 7 (Saturday). This attribute is mandatory for weekly frequency, and must not be specified for other frequencies.Sample: {"weekDays":[2,4]} |
| monthDays | JSONArray The dates of the month on which the alert is evaluated. Supported values: 1 to 31, or 99 for the last day of the month. 99 cannot be combined with other dates. For monthly frequency, multiple dates can be specified. For yearly frequency, exactly one date must be specified.Applicable only to monthly and yearly frequencies. For these frequencies, either monthDays, or weekOfMonth along with dayOfWeek, must be specified.Sample: {"monthDays":[1,15]} |
| weekOfMonth | Integer The occurrence of dayOfWeek within the month.Supported values: 1 (first) to 4 (fourth), 5 (last). Must be specified along with dayOfWeek. Applicable only to monthly and yearly frequencies.Sample: {"weekOfMonth":5} |
| dayOfWeek | Integer The day of the week used along with weekOfMonth. For example, weekOfMonth 2 with dayOfWeek 3 means the second Tuesday of the month.Supported values: 1 (Sunday) to 7 (Saturday). Must be specified along with weekOfMonth. Applicable only to monthly and yearly frequencies.Sample: {"dayOfWeek":6} |
| months | JSONArray The months in which the alert is evaluated. Multiple months can be specified. Supported values: 1 (January) to 12 (December). This attribute is mandatory for yearly frequency, and must not be specified for other frequencies.Sample: {"months":[1,7]} |
Note: A field specified for a frequency that it does not apply to is not accepted.
Note: For monthly and yearly frequencies, specify either monthDays, or weekOfMonth along with dayOfWeek. Specifying both or neither is not supported.
Note: Sample schedules for each frequency:
Hourly: {"calendarFrequency": "hourly", "interval": 6, "skipWeekends": true}
Daily: {"calendarFrequency": "daily", "interval": 3, "hour": 9, "minute": 30, "skipWeekends": true}
Weekly: {"calendarFrequency": "weekly", "interval": 2, "hour": 9, "minute": 30, "weekDays": [2, 4]}
Monthly, by date: {"calendarFrequency": "monthly", "hour": 9, "minute": 30, "monthDays": [1, 15]}
Monthly, by weekday: {"calendarFrequency": "monthly", "interval": 3, "hour": 9, "minute": 30, "weekOfMonth": 5, "dayOfWeek": 6}
Yearly, by date: {"calendarFrequency": "yearly", "hour": 9, "minute": 30, "months": [1, 7], "monthDays": [15]}
Yearly, by weekday: {"calendarFrequency": "yearly", "interval": 2, "hour": 6, "minute": 0, "months": [4], "weekOfMonth": 1, "dayOfWeek": 2}
calendarFrequency Values
| Description |
|---|---|
| hourly | Evaluates the alert every N hours.hour and minute are not used. interval is mandatory and supports 1, 2, 3, 4, 6 or 12. |
| daily | Evaluates the alert every N days at a fixed time.interval supports 1 to 7. |
| weekly | Evaluates the alert every N weeks on the selected weekDays.interval supports 1 to 4. weekDays is mandatory. |
| monthly | Evaluates the alert every N months on a date or on the Nth weekday.interval supports 1 to 12. Exactly one day selection must be specified. |
| yearly | Evaluates the alert every N years in the selected months.interval supports 1 to 5. months is mandatory, exactly one day selection must be specified, and monthDays supports only one date. |
email Fields
| Description |
|---|---|
| Content | |
| subject* | String The subject of the email. Maximum length - 500 characters. Sample: {"subject":"Sales dropped below threshold"} |
| message* | String The body of the email. HTML content is supported. When systemMailId is true, all HTML is removed.Maximum length - 5000 characters. Sample: {"message":"Please review the report."} |
| Recipients | |
| notifyAdmins | Boolean Controls whether the workspace admins are added to the recipients. Supported values: "true", "false" Default value - false. Sample: {"notifyAdmins":true} |
| emailIds | JSONArray The email addresses of the recipients. Maximum - 25 email addresses. Sample: {"emailIds":["jane.doe@example.com","manager@example.com"]} |
| groupIds | JSONArray The IDs of the workspace groups whose members receive the email, sent as strings. Supported range - 1 to 1000 groups. Sample: {"groupIds":["137687000002108009"]} |
| Attachments | |
| includeReport | Boolean Controls whether the report is included in the email. Supported values: "true", "false" Default value - false. Sample: {"includeReport":true} |
| attachmentType | String How the report is included in the email. Supported values: "inline", "attachment" This attribute is mandatory when includeReport is true.Check the table attachmentType Values for more details. Sample: {"attachmentType":"inline"} |
| attachFilteredDataset | Boolean Controls whether the data of the rows that matched the alert rules is attached. This can be set independently of includeReport.Supported values: "true", "false" Default value - false. Sample: {"attachFilteredDataset":true} |
| Sender | |
| systemMailId | Boolean Controls whether the email is sent from the Zoho Analytics system mail ID instead of the email address of the alert creator. The display email settings of the organization can override this setting. Supported values: "true", "false" Default value - false. Sample: {"systemMailId":false} |
Note: The email channel must have at least one recipient. If notifyAdmins is false and both emailIds and groupIds are empty, the channel is not saved.
Note: Up to 25 email addresses can be specified in emailIds. To notify a larger audience, use groupIds or notifyAdmins.
attachmentType Values
| Description |
|---|---|
| inline | Displays the report within the email body. |
| attachment | Sends the report as a file attachment. |
notification Fields
| Description |
|---|---|
| notifyAdmins* | Boolean Controls whether the workspace admins are notified. Supported values: "true", "false" Sample: {"notifyAdmins":true} |
| notifySharedUsers* | Boolean Controls whether all the users with whom the view is shared are notified. Supported values: "true", "false" Sample: {"notifySharedUsers":false} |
| subject* | String The title of the notification. Maximum length - 500 characters. Sample: {"subject":"Sales spike detected"} |
| message* | String The body of the notification. HTML content is supported. Maximum length - 5000 characters. Sample: {"message":"An anomaly was detected on Sales."} |
Note: At least one of notifyAdmins and notifySharedUsers must be true. Otherwise, the channel is not saved.
slack and msteams Fields
| Description |
|---|---|
| url* | String The incoming webhook URL of the channel. The URL must start with https://.Maximum length - 5000 characters. Sample: {"url":"https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXX"} |
| messageType* | String How the message is composed. Supported values: "STANDARD", "CUSTOM" The value is case-insensitive. Check the table messageType Values for more details. Sample: {"messageType":"STANDARD"} |
| subject | String The subject of the message. Maximum length - 500 characters. This attribute is mandatory when messageType is STANDARD.Sample: {"subject":"New East/West orders"} |
| message | String The body of the message. Used only when messageType is STANDARD.Maximum length - 5000 characters. Default value - empty string. Sample: {"message":"Orders from the East and West regions were detected."} |
| payload | String The custom message posted to the webhook, specified as a JSON object or array serialized into a string. Used only when messageType is CUSTOM.Maximum length - 50000 characters. This attribute is mandatory when messageType is CUSTOM.Sample: {"payload":"{\"text\":\"New East/West orders detected\"}"} |
Note: The slack and msteams objects use the same structure.
messageType Values
| Description |
|---|---|
| STANDARD | Zoho Analytics composes the message using subject and message.subject is mandatory. payload is ignored. |
| CUSTOM | Posts the specified payload as is, so that formats such as Slack Block Kit or Microsoft Teams message cards can be used.payload is mandatory and must be valid JSON. subject and message are ignored. |
webhook Fields
| Description |
|---|---|
| url* | String The target URL of the webhook. The URL must start with https://.Maximum length - 5000 characters. Sample: {"url":"https://example.com/zoho-analytics/alert-hook"} |
| method | String The HTTP method used to invoke the webhook. Supported values: "GET", "POST", "PUT", "PATCH", "DELETE" Maximum length - 10 characters. Default value - POST. Check the table method Values for more details. Sample: {"method":"POST"} |
| body | String The raw request body sent to the webhook. The content is not validated. Maximum length - 50000 characters. Default value - empty string. Sample: {"body":"{\"event\":\"newOrders\",\"severity\":\"info\"}"} |
| params | JSONArray The query or form parameters added to the request. Supported range - 0 to 10 parameters. Maximum length - 50000 characters. Check the table params and headers Fields for more details. Sample: {"params":[{"name":"source","value":"analytics"}]} |
| headers | JSONArray The additional HTTP headers sent with the request. Supported range - 0 to 10 headers. Maximum length - 10000 characters. Check the table params and headers Fields for more details. Sample: {"headers":[{"name":"X-Source","value":"ZohoAnalytics"}]} |
method Values
| Description |
|---|---|
| GET | Invokes the webhook with an HTTP GET request. |
| POST | Invokes the webhook with an HTTP POST request. This is the default method. |
| PUT | Invokes the webhook with an HTTP PUT request. |
| PATCH | Invokes the webhook with an HTTP PATCH request. |
| DELETE | Invokes the webhook with an HTTP DELETE request. |
params and headers Fields
| Description |
|---|---|
| name* | String The name of the parameter or header. Supported length - 1 to 255 characters. Sample: {"name":"X-Source"} |
| value* | String The value of the parameter or header. Maximum length - 5000 characters. Sample: {"value":"ZohoAnalytics"} |
Note: The params and headers arrays use the same structure. The values are stored encrypted, and are returned decrypted by the Get Alert Configuration API.
workflows Fields
| Description |
|---|---|
| id* | String The ID of a workflow that is already mapped to this alert, as returned by the Get Alert Configuration API. Supports only digits. Maximum length - 20 characters. Sample: {"id":"137687000012564035"} |
Note:name and enabled are not part of this structure. If specified, they are ignored, so the workflows returned by the Get Alert Configuration API can be sent without changes.
actionsByFlow Fields
| Description |
|---|---|
| actionConfigId* | String The ID of a Zoho Flow action configuration that is already mapped to this alert. The value must be sent as a string. Sample: {"actionConfigId":"137687000012564035"} |
| actionConfigName | String The name of the Zoho Flow action. Used when the mapping has to be re-created. Maximum length - 50 characters. Sample: {"actionConfigName":"Notify sales channel"} |
| connectionId | String The ID of the connection used by the action. Used when the mapping has to be re-created. The value must be sent as a string. Sample: {"connectionId":"137687000012564041"} |
Note: The Get Alert Configuration API returns actionConfigId and connectionId as numbers. Convert both values to strings before sending them in this API.
rules Fields
| Description |
|---|---|
| operator* | String The comparison operator of the rule. It must be one of the allowedOperators of the column, returned by the Get View Metadata For Alert API.Supported values: Comparison - is, isnot, gt, lt, gte, lte, btw, notbtw.Null check - isn, notisn.Relative date - curYear, prevYear, nextYear, curQuarter, prevQuarter, nextQuarter, curMonth, prevMonth, nextMonth, curWeek, prevWeek, nextWeek, today, yest, tom.N period date - prevNYears, lastNYears, nextNYears, prevNQuarters, lastNQuarters, nextNQuarters, prevNMonths, lastNMonths, nextNMonths, prevNWeeks, lastNWeeks, nextNWeeks, prevNDays, lastNDays, nextNDays.Anomaly - sinceLastAlert. For anomaly rules, the operator must be one of the allowedAnomalyOperators of the view.Maximum length - 50 characters. Sample: {"operator":"lt"} |
| viewColumnIndex | String The position of the column that the rule tests, as returned by the Get View Metadata For Alert API. The value must be sent as a string. This attribute is mandatory for rules without anomaly, and must not be specified for anomaly rules.Sample: {"viewColumnIndex":"2"} |
| type | String What the column is compared with. It must be one of the allowedRuleTypes of the column.Supported values: "constant", "column", "threshold" Default value - constant. Check the table type Values for more details. Sample: {"type":"constant"} |
| values | JSONArray The values to compare with, sent as strings. Supported range - 1 to 300 values. Maximum length - 5000 characters. The number of values required depends on the operator and the column. Must not be specified for operators that take no value, such as isn, notisn and sinceLastAlert.Sample: {"values":["10000","50000"]} |
| anomaly | JSONObject Makes the rule an anomaly rule. If one rule has anomaly, all the rules must have it. Supported only on chart views.Maximum length - 10000 characters. Check the table anomaly Fields for more details. Sample: {"anomaly":{"name":"Sales Spike","value":"","comboType":"top","comboTypeValue":"5"}} |
Note: The number of entries in values depends on the operator and the column:
When type is column: one entry, the viewColumnIndex of another NUMBER column in the same view.
When type is threshold: one entry, a threshold name from the thresholds of the column, for example "T1".btw and notbtw: two entries, the lower bound followed by the upper bound.is and isnot on a categorical or date bucket column: one or more entries.is and isnot on a NUMBER, DATE or TIMESTAMP column: exactly one entry.gt, lt, gte and lte: exactly one entry.
N period date operators, such as prevNMonths: one entry, the value of N as a numeric string.isn, notisn, sinceLastAlert and the relative date operators, such as curYear and today: values must not be specified.
Note: For DATE and TIMESTAMP columns, the values used with is, isnot, gt, lt, gte, lte, btw and notbtw must be in the yyyy-MM-dd HH:mm:ss or yyyy-MM-dd format. When only the date is specified, the time defaults to 00:00:00.
Note:viewColumnIndex is based on the position of the column, and changes when the report is edited. Get the latest values using the Get View Metadata For Alert API before you create or update an alert.
type Values
| Description |
|---|---|
| constant | Compares the column with a constant value. Always available. Used by default when type is not specified. |
| column | Compares the column with another NUMBER column of the same view. Available only when the view has at least two NUMBER columns. Supported only on chart views. |
| threshold | Compares the column with a chart threshold, such as T1 or T2.Available only when the column has at least one threshold. Supported only on chart views. |
anomaly Fields
| Description |
|---|---|
| name* | String The name of an anomaly configured on the view, as returned in anomalies by the Get View Metadata For Alert API. The name must match exactly.Maximum length - 100 characters. Sample: {"name":"Sales Spike"} |
| value | String The argument of the anomaly operator, when the operator takes one. For example, the N of lastNMonths.Maximum length - 1000 characters. Default value - empty string. Sample: {"value":""} |
| comboType | String How the detected anomalies are considered. Supported values: "top", "all" Maximum length - 5 characters. Default value - empty string. Check the table comboType Values for more details. Sample: {"comboType":"top"} |
| comboTypeValue | String The number of top anomalies to consider, sent as a numeric string. It must be a positive integer. Maximum length - 10 characters. Default value - empty string. This attribute is mandatory when comboType is top.Sample: {"comboTypeValue":"5"} |
comboType Values
| Description |
|---|---|
| top | Considers only the N most significant anomalies.comboTypeValue must be a positive integer. |
| all | Considers all the detected anomalies.comboTypeValue is ignored. |
Sample Request:
Copiedcurl "https://analyticsapi.zoho.com/restapi/v2/workspaces/35130000001055707/alerts/35130000001056611" -X 'PUT' -H 'ZANALYTICS-ORGID: <org-id>' -H 'Authorization: Zoho-oauthtoken <access_token>' --data-urlencode 'CONFIG={"alertName":"Sales Drop Alert (weekly)","scheduleDetails":{"calendarFrequency":"weekly","hour":9,"minute":30,"weekDays":[6],"timeZone":"Asia/Kolkata"},"email":{"notifyAdmins":true,"emailIds":["finance@example.com"],"subject":"Weekly sales monitor","message":"Weekly alert summary."},"rules":[{"operator":"lt","viewColumnIndex":"2","type":"constant","values":["1000"]}]}'Copiedusing System;
using System.Collections.Generic;
using System.Text.Json;
using ZohoAnalytics;
namespace ZohoAnalyticsTest
{
class Program
{
long orgId = 55522777;
long workspaceId = 35130000001055707;
public void UpdateAlert(IAnalyticsClient ac)
{
long alertId = 35130000001056611L;
string alertName = "Sales Drop Alert (weekly)";
Dictionary<string, object> scheduleDetails = JsonSerializer.Deserialize<Dictionary<string, object>>("{\"calendarFrequency\":\"weekly\",\"hour\":9,\"minute\":30,\"weekDays\":[6],\"timeZone\":\"Asia/Kolkata\"}");
List<Dictionary<string, object>> rules = JsonSerializer.Deserialize<List<Dictionary<string, object>>>("[{\"operator\":\"lt\",\"viewColumnIndex\":\"2\",\"type\":\"constant\",\"values\":[\"1000\"]}]");
Dictionary<string, object> config = JsonSerializer.Deserialize<Dictionary<string, object>>("{\"email\":{\"notifyAdmins\":true,\"emailIds\":[\"finance@example.com\"],\"subject\":\"Weekly sales monitor\",\"message\":\"Weekly alert summary.\"}}");
IWorkspaceAPI workspace = ac.GetWorkspaceInstance(orgId, workspaceId);
workspace.UpdateAlert(alertId, alertName, scheduleDetails, rules, config);
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.UpdateAlert(ac);
}
}
}Copiedpackage main
import (
"fmt"
ZAnalytics "zoho/pkg/analyticsclient"
)
var (
clientId = "1000.xxxxxxx"
clientSecret = "xxxxxxx"
refreshToken = "1000.xxxxxxx.xxxxxxx"
orgId = "55522777"
workspaceId = "35130000001055707"
)
func UpdateAlert(ac ZAnalytics.Client) {
alertid := "35130000001056611"
alertname := "Sales Drop Alert (weekly)"
scheduledetails := map[string]interface{}{
"calendarFrequency": "weekly",
"hour": 9,
"minute": 30,
"weekDays": []int{6},
"timeZone": "Asia/Kolkata",
}
rules := []interface{}{
map[string]interface{}{
"operator": "lt",
"viewColumnIndex": "2",
"type": "constant",
"values": []string{"1000"},
},
}
config := map[string]interface{}{
"email": map[string]interface{}{
"notifyAdmins": true,
"emailIds": []string{"finance@example.com"},
"subject": "Weekly sales monitor",
"message": "Weekly alert summary.",
},
}
workspace := ZAnalytics.GetWorkspaceInstance(&ac, orgId, workspaceId)
exception := workspace.UpdateAlert(alertid, alertname, scheduledetails, rules, config)
if exception != nil {
fmt.Println(exception.ErrorMessage)
return
}
fmt.Println("success")
}
func main() {
ac := ZAnalytics.GetAnalyticsClient(clientId, clientSecret, refreshToken)
UpdateAlert(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.updateAlert(ac);
} catch (Exception ex) {
ex.printStackTrace();
}
}
public void updateAlert(AnalyticsClient ac) throws Exception {
long alertId = 35130000001056611l;
String alertName = "Sales Drop Alert (weekly)";
JSONObject scheduleDetails = new JSONObject("{\"calendarFrequency\":\"weekly\",\"hour\":9,\"minute\":30,\"weekDays\":[6],\"timeZone\":\"Asia/Kolkata\"}");
JSONArray rules = new JSONArray("[{\"operator\":\"lt\",\"viewColumnIndex\":\"2\",\"type\":\"constant\",\"values\":[\"1000\"]}]");
JSONObject config = new JSONObject("{\"email\":{\"notifyAdmins\":true,\"emailIds\":[\"finance@example.com\"],\"subject\":\"Weekly sales monitor\",\"message\":\"Weekly alert summary.\"}}");
WorkspaceAPI workspace = ac.getWorkspaceInstance(orgId, workspaceId);
workspace.updateAlert(alertId, alertName, scheduleDetails, rules, config);
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 updateAlert() {
$alert_id = "35130000001056611";
$alert_name = "Sales Drop Alert (weekly)";
$schedule_details = array(
"calendarFrequency" => "weekly",
"hour" => 9,
"minute" => 30,
"weekDays" => array(6),
"timeZone" => "Asia/Kolkata"
);
$rules = array(
array(
"operator" => "lt",
"viewColumnIndex" => "2",
"type" => "constant",
"values" => array("1000")
)
);
$config = array(
"email" => array(
"notifyAdmins" => true,
"emailIds" => array("finance@example.com"),
"subject" => "Weekly sales monitor",
"message" => "Weekly alert summary."
)
);
$workspace = $this->ac->getWorkspaceInstance($this->org_id, $this->workspace_id);
$workspace->updateAlert($alert_id, $alert_name, $schedule_details, $rules, $config);
echo "success";
}
}
$obj = new Test();
$obj->updateAlert();
?>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 update_alert(self, ac):
alert_id = "35130000001056611"
alert_name = "Sales Drop Alert (weekly)"
schedule_details = {
"calendarFrequency": "weekly",
"hour": 9,
"minute": 30,
"weekDays": [6],
"timeZone": "Asia/Kolkata"
}
rules = [
{
"operator": "lt",
"viewColumnIndex": "2",
"type": "constant",
"values": ["1000"]
}
]
config = {
"email": {
"notifyAdmins": True,
"emailIds": ["finance@example.com"],
"subject": "Weekly sales monitor",
"message": "Weekly alert summary."
}
}
workspace = ac.get_workspace_instance(Config.ORGID, Config.WORKSPACEID)
workspace.update_alert(alert_id, alert_name, schedule_details, rules, config)
print("success")
obj = Sample()
obj.update_alert(obj.ac)Copiedvar analyticsClient = require('./AnalyticsClient');
var ac = new analyticsClient('1000.xxxxxxx', 'xxxxxxx', '1000.xxxxxxx.xxxxxxx');
var orgId = '55522777';
var workspaceId = '35130000001055707';
var alertId = "35130000001056611";
var alertName = "Sales Drop Alert (weekly)";
var scheduleDetails = {
"calendarFrequency": "weekly",
"hour": 9,
"minute": 30,
"weekDays": [6],
"timeZone": "Asia/Kolkata"
};
var rules = [
{
"operator": "lt",
"viewColumnIndex": "2",
"type": "constant",
"values": ["1000"]
}
];
var config = {
"email": {
"notifyAdmins": true,
"emailIds": ["finance@example.com"],
"subject": "Weekly sales monitor",
"message": "Weekly alert summary."
}
};
var workspace = ac.getWorkspaceInstance(orgId, workspaceId);
workspace.updateAlert(alertId, alertName, scheduleDetails, rules, config).then(() => { console.log("success"); }).catch((error) => { console.log(error); });CopiedorgId = "55522777";
workspaceId = "35130000001055707";
alertId = "35130000001056611";
headersMap = Map();
headersMap.put("ZANALYTICS-ORGID", orgId);
config = {"alertName": "Sales Drop Alert (weekly)", "scheduleDetails": {"calendarFrequency": "weekly", "hour": 9, "minute": 30, "weekDays": [6], "timeZone": "Asia/Kolkata"}, "email": {"notifyAdmins": true, "emailIds": ["finance@example.com"], "subject": "Weekly sales monitor", "message": "Weekly alert summary."}, "rules": [{"operator": "lt", "viewColumnIndex": "2", "type": "constant", "values": ["1000"]}]};
response = invokeurl
parameters = "CONFIG=" + zoho.encryption.urlEncode(config.toString());
[
url :"https://analyticsapi.zoho.com/restapi/v2/workspaces/" + workspaceId + "/alerts/" + alertId
type :PUT
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 update_alert
alert_id = "35130000001056611"
alert_name = "Sales Drop Alert (weekly)"
schedule_details = {
"calendarFrequency" => "weekly",
"hour" => 9,
"minute" => 30,
"weekDays" => [6],
"timeZone" => "Asia/Kolkata"
}
rules = [
{
"operator" => "lt",
"viewColumnIndex" => "2",
"type" => "constant",
"values" => ["1000"]
}
]
config = {
"email" => {
"notifyAdmins" => true,
"emailIds" => ["finance@example.com"],
"subject" => "Weekly sales monitor",
"message" => "Weekly alert summary."
}
}
workspace = @ac.get_workspace_instance(Config::ORGID, Config::WORKSPACEID)
workspace.update_alert(alert_id, alert_name, schedule_details, rules, config)
puts "success"
end
end
obj = Sample.new
obj.update_alertDownload client libraries: C# | GO | JAVA | PHP | PYTHON | NodeJS | Ruby
Sample value for CONFIG parameter:
Copied{
"alertName": "Sales Drop Alert (weekly)",
"scheduleDetails": {
"calendarFrequency": "weekly",
"hour": 9,
"minute": 30,
"weekDays": [
6
],
"timeZone": "Asia/Kolkata"
},
"email": {
"notifyAdmins": true,
"emailIds": [
"finance@example.com"
],
"subject": "Weekly sales monitor",
"message": "Weekly alert summary."
},
"rules": [
{
"operator": "lt",
"viewColumnIndex": "2",
"type": "constant",
"values": [
"1000"
]
}
]
}Sample Response:
CopiedHTTP/1.1 204 No Content