Skip to content

Lab 2 - Generating an API Key

Just like our lab application automates on-demand lab deployments—by creating temporary Dashboard organizations, setting up networks, claiming devices, applying licenses, and more—you can harness the power of the Meraki Dashboard API to do more with less and scale your operations efficiently.

Imagine, in this new hybrid work era, deploying a full-stack Meraki branch—with secure wireless, VPN connectivity, and pre-configured Layer 3/7 firewall rules—ready for production in just a few minutes, if not seconds.

Let's take the first step.

Steps

  1. Once again, make sure you're working within the designated lab environment—especially if your account has access to multiple organizations.

Lab organization selection

!!! danger "Important" If you're unsure, navigate to Organization > Administrators in the Dashboard. If you see an admin named ENLS with the email launchpad-labs-ops@cisco.com, that's the lab organization you should be working in.

  1. Click on the person icon in the top-right corner of the Dashboard, then select My profile from the dropdown menu.

Profile menu

  1. Under the API access section, if you already have an API key generated, you can use your existing key. If you don't have one yet, click Generate new API key and be sure to copy and store your key in a safe place, as you won't be able to view it again. Confirm that you have stored the new API key and close the pop-up window by clicking Done.

API key generation

!!! info "Information" Dashboard API access is granted on a per-user basis. Just like your Dashboard login can manage multiple organizations, your API key inherits the same permissions and access across associated organizations and networks.

  1. Use the search function (Ctrl+F or Cmd+F) to look for "organization ID" on the page. Copy and save the corresponding numeric ID string for later use. In the following example, the ID is "3665367146726163610", which should also appear as part of your lab organization name.

Organization ID on profile page

  1. Visit the Meraki Dashboard API documentation and review the following topics in the overview of Dashboard API.

  2. Resources

  3. Services
  4. Resource URLs
  5. Base URI

  6. In the documentation page, navigate to API Index in the left-hand menu and search for the operation getOrganizationNetworks.

API Index and getOrganizationNetworks

!!! info "Information" Meraki offers interactive REST API documentation for the Meraki Dashboard APIs, based on the Open API Specification. From the API Index page, you can download the full Dashboard API index as a CSV file or access the same information through the Dashboard API OpenAPI Specification on Github.

  1. Click on corresponding operation List the networks that the user has privileges on in an organization endpoint (see the above screenshot) on the page which will take you to the operation details.

  2. This page provides details about the selected operation, including its description, endpoint path, example result, and code snippets. Select Code Snippets and then select Curl.

Code snippets and Curl option

  1. On some operating systems, you can copy and paste the command directly from the documentation. For convenience, based on your OS type, copy the following curl command and replace the string after keyword Bearer with your API key.

macOS:

curl -L --request GET \
  --url https://api.meraki.com/api/v1/organizations/==[YourLabOrgID]==/networks \
  --header 'Authorization: Bearer ==[YourAPIKey]==' \
  --header 'Accept: application/json'

Windows (a single line command with double quotes):

curl -L --request GET --url https://api.meraki.com/api/v1/organizations/==[YourLabOrgID]==/networks --header "Authorization: Bearer ==[YourAPIKey]==" --header "Accept: application/json"

!!! tip "Hint" Use single quotes (') on macOS and double quotes (") on Windows when formatting command-line arguments. On Windows, you also need to put the entire cURL command on a single line. Do NOT include the square brackets in your command.

!!! info "Information" Meraki Dashboard API supports the following verbs: - GET returns the value of a resource - POST adds a new resource - PUT updates a resource - DELETE removes a resource

  1. Run the command on your local computer using Terminal on macOS or Command Prompt (CMD) on a Windows PC.

    Example curl on macOS Example on macOS

    Example curl on Windows Example on Windows

    Congratulations! If so, you've just made your first Meraki Dashboard API call successfully retrieving the network information from the lab organization.

    Hint

    In this lab, the API call should successfully return a list of two networks from the target lab organization: API-Branch and API-Campus.

  2. Name your user agent for easier identification. Repeat the same API operation from Step 9, but this time add the User-Agent header attribute at the end of the cURL command.

    macOS:

    curl -L --request GET \
      --url https://api.meraki.com/api/v1/organizations/[YourLabOrgID]/networks \
      --header 'Authorization: Bearer [YourAPIKey]' \
      --header 'Accept: application/json' \
      --header 'User-Agent: Jumpstart/1.0 curl'
    

    Windows (a single line command with double quotes):

    curl -L --request GET --url https://api.meraki.com/api/v1/organizations/[YourLabOrgID]/networks --header "Authorization: Bearer [YourAPIKey]" --header "Accept: application/json" --header "User-Agent: Jumpstart/1.0 curl"
    

    Hint

    When you invoke dashboard API, it's best practice to provide a custom user agent string with each API request. This helps your customers and Meraki administrators monitor API interactions with their environments and helps build their trust. There are some Dos and Don'ts with user agent strings. Please refer to the User Agent Guide for more details.

  3. Navigate to Organization > API & Webhooks, instead of seeing generic strings like "curl/x.x.x", you'll now be able to easily identify your API interactions with the Dashboard—especially helpful when the same API key is used across different applications or use cases.

    User-Agent in API analytics

Congratulations on completing lab 2!

In this lab, you have successfully generated an API key for your Dashboard account and made a REST request using cURL to retrieve networks from an organization. Additionally, you've learned how to use the User-Agent header in the REST requests to help identify your applications in API usage analytics.