cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
228
Views
0
Helpful
1
Replies

Setting Client Filter for Meraki Update Network Alert Settings API

Brian B
Cisco Employee
Cisco Employee

Hello. I am trying to use the Meraki Dashboard API Update Network Alert Settings (https://developer.cisco.com/meraki/api-v1/update-network-alerts-settings/) to change the clients selected for the 'clientConnectivity' type alert. In the documentation it says the filters are "A hash of specific configuration data for the alert. Only filters specific to the alert will be updated." I have tried a variety of different combinations of dictionaries and lists and cannot figure out how to add a client to the clientConnectivity filter. Please help.

1 Reply 1

suppy
Level 1
Level 1
To update the clientConnectivity alert settings using the Meraki Dashboard API, you need to send a PUT request to the /networks/{networkId}/alertSettings endpoint. Specifically, you'll be updating the filters field with the new filter settings for the clientConnectivity type alert.

Here's an example of how you can update the clientConnectivity alert settings to include specific clients. You'll need to provide the networkId of your Meraki network and the list of clients you want to include in the filter.

First, you'll need to install the requests library if you haven't already:


pip install requests
Next, you can use the following Python script to update the clientConnectivity alert settings:


import requests
import json

# Your Meraki API key
API_KEY = 'your_api_key'

# Your Meraki network ID
network_id = 'your_network_id'

# List of clients to include in the filter
clients = [
    {
        "type": "client",
        "mac": "00:11:22:33:44:55"
    },
    {
        "type": "client",
        "mac": "66:77:88:99:AA:BB"
    }
]

# Endpoint URL for updating alert settings
url = f"https://api.meraki.com/api/v1/networks/{network_id}/alertSettings"

# Create the payload for the request
payload = {
    "alerts": [
        {
            "type": "clientConnectivity",
            "enabled": True,
            "filters": clients
        }
    ]
}

headers = {
    "Content-Type": "application/json",
    "X-Cisco-Meraki-API-Key": API_KEY
}

# Send the PUT request to update the alert settings
response = requests.put(url, headers=headers, data=json.dumps(payload))

# Check the response
if response.status_code == 200:
    print("Alert settings updated successfully.")
else:
    print(f"Failed to update alert settings. Status Code: {response.status_code}")
    print(response.text)
In this script:

Replace 'your_api_key' with your actual Meraki API key.
Replace 'your_network_id' with the ID of your Meraki network.
Replace the clients list with the MAC addresses of the clients you want to include in the clientConnectivity alert filter.