How to generate a User API Token

First you will need to generate a User API Token. You can do it here and this will carry your permissions.  This is from the Mist API docs

NOTE – There also exists an Org Token which has some features that might be more useful depending on your use case.

  • User Token
    • Token persists under the user accountToken is bound to the specific user, meaning the access directly depends upon the user’s access to the org
    • Token can be used for any MSP/Org that the user has access to
    • Supports N tokens, which all have the same privilege as the user account
    • Rate limiting is tied to the account. So if UserToken1 consumes 5000 API calls and hits the rate limit, UserToken2 AND account log in to the GUI is impacted
  • Org Token
    • Token persists under the org
    • Token is not bound to any specific user, meaning the access does not depend upon the user’s access to the org
    • Token can only be used for that specific org
    • Supports N org tokens, which can have different privileges
    • Rate limiting is done by the individual token. So if OrgToken1 consumes 5000 API calls and hits the rate limit, OrgToken2 is not impacted

Generating a User API Token

Just press POST  (Note the URL, I’m already logged into the UI and created a new tab) the browser has my credentials.

NOTE – Please note the API endpoint varies by cloud environment.  Please refer to the cloud endpoint URLs document.

There is a tool call Postman that can be used to interact with the API without getting into coding. It is a really good place to start. You can download it here.

 

 

Now in the new Postman screen  you will have to populate the Authorization and Content-type. Note Authorization should be the API token you have saved on your notepad.

Now your ready to make some Mist API calls!

Here is my UI with my SSID created called TestWlan

We used a GET with the proper site ID for the API call

GET  https://api.mist.com/api/v1/sites/:site_id/wlans/:wlan_id

Now we can setup Postman to make a change – choose the correct Body Text (JSON)

Now we can use the PUT call to just change the key-pair we want. Lets change the SSID name. But we need to also get the WLAN ID as the API call is

https://api.mist.com/api/v1/sites/:site_id/wlans/:wlan_id

And look at that.  You can make all kinds of changes using the API.

And Postman has a link on the right called “CODE” which lets you turn this API call into Python or other languages so you can add it to a script your already using or the basis of a new one.

And you can choose your format, we are using Python