User agents
When invoking dashboard API, it's best practice to provide a custom user agent string with each API request. This helps your customers and Meraki admins monitor API interactions with their environments and helps build their trust. In brief, here are some Dos and Don'ts with user agent strings!
Dos
- Provide the user agent string in the "User-Agent" header of every API request.
- Follow the prescribed format below, which differs minimally from standard practices.
- Include only the requested information in your user agent string.
- Only use slashes ("/") when optionally providing application version information.
Don'ts
- Provide inconsistent or incorrect user agent strings across your application.
- Leave out the user agent string from any of your requests.
- Add unnecessary information or special characters to your user agent string.
- Mix up slashes (e.g. "/") and backslashes (e.g. "\").
Formatting
Please format your user agent strings accordingly:
ApplicationName VendorName
If you want to include version information, do so as follows:
ApplicationName/1.0 VendorName
Regardless of your branding guidelines, your application name and vendor name must omit all spaces, hypens, and special characters. When providing a custom user agent string in API calls, keep in mind that the information is typically exclusively valuable to Meraki dashboard admins, so it's not necessary to include sometimes arcane information, as is common practice amongst web browsers.
Examples
Example 1
If your vendor name is Lunar Commander, and your application name is Planet Craft Lite, then use:
PlanetCraftLite LunarCommander
or, if you want to include a version string:
PlanetCraftLite/0.8b LunarCommander
Example 2: Hyphenated names
If your vendor name is Happy-Rabbit Productions, and your application name is Burrow Finder, then use:
BurrowFinder HappyRabbitProductions
or, if you want to include a version string:
BurrowFinder/2.5 HappyRabbitProductions
In practice
It's usually trivial to add user agent headers to your API requests. All HTTP requests libraries offer some means of appending the User-Agent header to your requests.
Python library
If using the Meraki Python library, then simply pass the kwarg caller
in your session definition.
import meraki
dashboard = meraki.DashboardAPI(caller='PlanetCraftLite/0.8b LunarCommander')
Alternatively, you can modify the library's config.py file to set this globally. Consult the docs for more information.
PowerShell
If using the Invoke-WebRequest
method, then provide the -UserAgent
flag in each of your requests:
$userAgent = 'ApplicationName VendorName'
$apiCallExample = Invoke-WebRequest -URI $uri -Headers $headers -UserAgent $userAgent
Java
If using the HttpURLConnection
module, then use setRequestProperty
to send the user agent:
import java.net.HttpURLConnection;
String userAgent = "ApplicationName VendorName"
HttpURLConnection connectionExample = null;
urlExample = new URL(exampleStringUrl); // appropriate operation URL here
connection = (HttpURLConnection) urlExample.openConnection();
// other setRequestProperties here, e.g. Bearer Auth, etc.
connection.setRequestProperty("User-Agent", userAgent);