Create or update rules
Required permissions
You'll need to be an administrator or developer user to create rules. Analyst users can view alerts but not create or modify rules.
Manage rules from the Codat portal
Create a new rule
- Sign in to the Codat portal.
- In the navigation bar, select Alerts > Alerting rules.
The Alerting Rule page is displayed. - Select Create new rule.
The New Rule dialog box is displayed. - From the Rule type list, select the event you would like to be notified of. See Rule types for more details of the events that trigger an alert and the details included the alert.
- In the Company list, select the company that you would like to monitor, or select All to apply this rule to all companies.
- By default, alerts triggered by rules are shown in the Codat portal, but you can also choose to send them by email, or post them to a webhook. To do this:
- In the Email notifiers box, enter a comma separated list of email addresses that should receive the alert.
- In the Webhook notification URL box enter the URL that you would like alert details posted to. See Webhook alerts for more details.
- Select Save changes.
Update an existing rule
You can update the company you want to monitor, or the notification methods you want to use for a rule at any time.
- Follow steps 1 and 2 in Set up a new rule.
- On the Alerting Rule page, find the rule you're interested in and select Edit next to it.
- Update the details as required.
- Select Save changes.
Manage rules from the Codat API
Rule types
Rule types must be entered exactly as shown below:
Data sync completed
New company synchronised
DataConnectionStatusChanged
Data Sync Status Changed To Error
Push Operation Status Changed()
Push Operation Timed Out
Dataset data changed
Create a new rule using the API
When you set up a new rule using the API, you can also set up email or webhook notifications to tell you when a rule condition is met.
- Open the POST /rules endpoint.
- Enter the following details:
- The companyId for the company that you want to apply the rule to. Omit this for the rule to apply to all companies.
- The type of rule that you would like to set up using the exact naming shown above.
- (Optional) email addresses that you would like any notifications sent to.
- (Optional) the URL of the webhook that you would like notifications sent to.
- Send your request to create the rule.
Example body for a company-specific rule
{
"companyId": "4444b734-91b6-4e63-8f8e-9f01e688162b",
"type": "DataConnectionStatusChanged",
"notifiers": {
"emails": [
"[email protected]"
],
"webhook": "https://test.codat.com/codat"
}
}
Example body for an all-companies rule
{
"type": "DataConnectionStatusChanged",
"notifiers": {
"emails": [
"[email protected]"
],
"webhook": "https://test.codat.com/codat"
}
}
Update an existing rule
You can update the email and notification details for a rule at any time. Before you start, you need to find the ID of the rule that you want to update.
Find the rule details
Use the GET /rules endpoint to return a full list of all rules. If you add the query parameter companyId to your request, rules that apply to all companies do not appear.
Update the rule
- Open the PUT /rules/{ruleId} endpoint.
- Replace {ruleId} with the ID of the rule you want to update.
- Enter your rule details, and update any email and webhook details as required. If you want to apply the changes to all companies, leave out the companyId parameter and value.
Example body for updating a rule
{
"id": "44445936-afe0-4625-a326-14c93354e66a",
"companyId": "4444b734-91b6-4e63-8f8e-9f01e688162b",
"type": "DataConnectionStatusChanged",
"notifiers": {
"emails": [
"[email protected]"
],
"webhook": "https://anothertest.codat.com/codat"
}
}
Updated 5 days ago