Get Switch and port ID When AP Down via API


Get Switch and port ID When AP Down via API

Hi Experts,


I am after for an API that can tell me which switch and port an Access Point (AP) is connected to, even when the AP is offline.

This would allow me to automatically enable or disable ports to get the AP back online in most situations. Currently, I can only get the switch and port information via API when the AP is working.(


Does anyone know of such an API, or is it possible to build one


Thank you





9 Replies 9
Kind of a big deal
Kind of a big deal

You should probably use and build yourself a little inventory. I wouldn't expect AP moving from ports to ports on your switch.


Other than that I'm not sure there is any endpoint that would do what you expect. I might be wrong.

Yes , AP won't be moved. Any documents or guide for how to build our own build yourself a little inventory

You could store the data in a plain text file ( csv ? ). Read it every x hours and if the port status has changed or no cdp/lldp info present on that port , you could validate the status of the AP. 


Those are just generic ideas.


Our friend @sungod usually has some great ideas ! ( by usually I mean't all the time 😁 )

Pretty much what @RaphaelL says.


The details depend on what will be running this, for instance in a unix/linux environment if your script to go and grab the current port-AP list writes to a text file p-ap-tmp and if the 'database' is the text file p-ap-master, both files same format, one switch-port-ap record per line, both sorted. It can be done more compactly, but this way is clearer to see...


your_lldpcdp_script |sort >p-ap-tmp

cat p-ap-tmp p-ap-master |sort -u >p-ap-new

mv p-ap-new p-ap-master


Will keep p-ap-master updated with any additions, without losing records for APs that are no longer detected.


You could extend the shellscript to spit out a list of records for any missing APs...


comm -3 p-ap-master p-ap-tmp >p-ap-missing

Kind of a big deal
Kind of a big deal

First lets take a step back.  You should not need to disable/re-enable a port to get an MR back online.  Something is fundamentally wrong if you have to do that.  You should solve that problem instead.



Back to your question - what about searching for all ports in the dashboard with an MR attached, tag those ports, and then extract all the ports based on the tag?

You could then use the below to get every switch port in your whole organisation (one API call!), and then programmatically filter by tag. 


Thanks for your help! In our Meraki network, our Level 1 team often fixes issues on during power outages by disable/enable switch port. We wanted to automate this process.

I tried the API you suggested, but it doesn't give me the AP names, just a list 

"name": "switch name",
"serial": "Serial number",
"mac": "Mac xx: xx: xx",
"network": {
"id": "network_ID_L",
"name": "Melbourne HQ"
"model": "MS410-16",
"ports": [
"portId": "1",
"name": "Level-1 Switch Stack",
"tags": [],
"enabled": true,
"poeEnabled": false,
"type": "trunk",
"vlan": 502,
"voiceVlan": null,
"allowedVlans": "all",
"rstpEnabled": true,
"stpGuard": "disabled",
"linkNegotiation": "Auto negotiate",
"accessPolicyType": "Open"

As an alternative, we could run a report and read it from an Excel file each time, but that wouldn't be very efficient for our large network.



Ideally, we'd have a fully automated system:

  1. When an AP goes down then
  2. The system automatically finds the connected switch and port.
  3. The system disables and then re-enables the port on the switch.
  4. Finally, the system checks if the AP is back online.

I might not be explaining perfectly, but hopefully you understand what we're trying to achieve. Is it possible to build an API to do this?


Thank you 

Building a reputation

Is this something you are willing to spend PS dollars on or just trying to work your way through?

just trying to work through as not authorised 

Here to help

As @Phil9 has mentioned, if you need to reboot the AP everytime you have a power outage in the network(s), you have something fundamentally wrong which perhaps you may want to solve urgently.

It's also quite a question on how you will do this.

How are you going to deploy some kind of monitoring on this? Checking if the APs replying to ping, or using API to check if APs are offline in a timely fashion, etc?


Anyway, given it's a rare case that we move around APs, to build a database on where the APs are connected to your switch, a simple way is just to download the information on the Meraki dashboard (Network -> Wireless -> Access Points) and make sure you have the "Ethernet 1 LLDP" column checked and then download it as csv.

Of course, you will then have to work on the column as it will give you "[switch name]/[port id]" by leveraging it to contain switch serial, for example, and maybe other information that you need (switch IP address, etc)

When you need to reboot your APs via API you can use based on the database that you have built.


Again, as mentioned previously, something is wrong if you have to do this everytime you have a power outage on the network.

Get notified when there are additional replies to this discussion.