Capture Client – Getting CC API token via MSW API key

Description

This document outlines how to generate Capture Client API token via MySonicWall API key to  run CC API queries and Integrations.

Requirements

Capture Client Advanced and Premier License

MSW API Key Feature Enabled

High Level Process

  1. Get an API Key from SonicWall Unified Management
  2. Connect to MSW APIs
    1. Get Tenant Information
    2. Get Capture Client Access Code
  3. Connect to Capture Client APIs
    1. Get CC API Token
    2. Use Token for CC APIs

Resolution

Get API Key from SonicWall Unified Management (UM)

Generate the API key from the SonicWall Unified Management console.

  1. Login to SonicWall Unified Management.
  2. Navigate to Admin Settings | Users Access Management > User Groups / Monthly User Groups > User List.
  3. Click Generate My API Key at the top of the table.
  4. Enter a Description and, optionally, a Source IP Address for the API key. Validity defaults to 1 year; you can set it to 1 or 6 months instead if required.
  5. Click Confirm.
  6. Click the Copy to clipboard icon to copy the API key.
  7. Click Close.

Example: the Generate API Key dialog in SonicWall Unified Management.

NOTE: You cannot view or copy the API key once you close the Generate API Key pop-up window, so make sure it is copied and saved before closing.

The account admin can view the API keys generated for users and revoke a key if needed. API access is determined by the access levels defined in Unified Management. See Generating API Key for the full UM reference.

Connect to MSW APIs using Postman

  1. Get CC Tenant Information
    1. Open postman and add a new collection enter URL (https://api.mysonicwall.com/api/hgms/get-cloud-tenants) in the input field using ‘GET’ method
    2. Click on ‘Headers’ tab and add below keys and then click ‘Send’.
      Content-Type: application/json
      X-api-key: Enter the MSW API key received in step above “Get MSW API Key from MySonicWall”. 


      Example: setting the Content-Type and X-api-key headers to request tenant information.
    3. Below response show up under ‘Body’ section. Click on copy icon to copy the response as that will be used next to generate the CC token.

      Example: response body returned for the Get Tenant Information request, containing the productGroupID.
    4. Click on copy icon to copy the response and save the output to text file.
    5. Now search for the Tenant name in the output (Text file) and find the associated "productGroupID" and keep it aside to be used in next step.
  2. Get an access code for your CC tenant using the MSW API Token and the tenantId (ProductGroupID).
    1. Add another collection, and enter URL (https://api.mysonicwall.com/api/generate-cscaccesscode ) in the input field using ‘POST’ method on Postman.
    2. Enter the x-api-key in headers as above steps
    3. Click on ‘Body’ section and select ‘raw’ and type / enter below text.
      {"tenantId" : "InsertprodcutGroupID","tileName":"ISNSMSAFEENABLED"}

      Example: request body used to generate a Capture Client access code.
    4. Now click on ‘Send’ and it will return ‘accessCode’ under Body.

      Example: response body containing the generated accessCode.
    5. Copy the ‘accessCode’ as that need to use in next step to Generate CC API Token.
      NOTE : The generated access code is valid only for 5 minutes.
    6. Alternatively, here is the sample Curl-based examplecurl https://api.mysonicwall.com/api/generate-cscaccesscode -X POST -d "{\"tenantId\":\"YOURTENANTID\",\"tileName\":\"ISNSMSAFEENABLED\"}" -H "Content-Type: application/json" -H "X-API-KEY: YOURAPIKEY"
      Replace the tenantid with ProductGroupID you received in step 1 and replace YOURAPIKEY with APIKEY generated.

Connect to Capture Client using Postman

Get Capture Client (CC) API Token:

  1. Add another collection enter URL (https://captureclient-36.sonicwall.com/api/auth/getApiToken) in the input field using ‘POST’ method.
    1. Enter the x-api-key in headers as above steps
  2. Click below on ‘Body’ section and select ‘raw’ and type / enter below text as per syntax. Code: From above step 2.d.
    Syntax:{ "code":"InsertaccessCode"}
  3. Alternatively, her is the Sample API callPOST https://captureclient-36.sonicwall.com/api/auth/getApiToken?cscaccesscode=NF80MDYzMTE4Ml5DNTYzQzk2QTFFQkE0RjA1ODk2MjU4RjJDQzA5Njk1OQ=

    Example: sample API call used to generate the Capture Client API token from the access code.
  4. Click ‘Send’ and will below response will show up under ‘Body’.

    Example: response body containing the Capture Client API token and MSW account email.
  5. You will get your MSW account email and CC API token in response body. CC API token info will be shown in ‘token’. Same token needs to be used for authentication when running CC API queries.

          NOTE : The Capture Client  API Token you generated is valid for 7 days.

           

          Using Token for Capture Client APIs.

          Below example is to get Endpoint list for Capture Client Tenant. Use the Capture Client API Token for Capture Client API calls for that specific tenant.

          1. Add a new collection and enter API URL (https://captureclient-36.sonicwall.com/api/endpoints/list) in the input field using the ‘GET’ method.
          2. Go to ‘Headers’ tab and select/enter ‘Authorization’ and then insert the CC API Token value (from step 4 above) in ‘token’ field.

           

          Example: setting the Authorization header with the Capture Client API token.

          1. For more information about CC API queries, refer to Capture Client API docs - captureclient-36.sonicwall.com/api/docs/.

          NOTE : Your Capture Client region is the domain for the SonicWall Capture Client portal you log into. The available regions are:

          Token Scope

          The CC API token has the following scope:

          • The CC API token is user-specific and is not tied to a specific tenant scope.
          • If the token’s user is an account admin, the generated token can access all tenants under that account.
          • In CC API calls, to access a specific tenant or account, set the tenantId or accountId header, respectively.

            Example: setting the tenantId header to scope a request to a specific tenant.

            Example: setting the accountId header to scope a request to a specific account.

          Finding Your Account ID

          You can find your CMC account ID in either of the following ways:

          • Call GET https://captureclient-36.sonicwall.com/user/current without passing a tenantId or accountId header. If you are an account admin, the response returns your accountId.
          • Or copy the Account ID from Capture Client (Unified Management) under Management > Account Settings, scoped to All MSP/Tenants.

            Example: calling /user/current to retrieve the accountId for an account admin.

            Example: viewing the Account ID in Capture Client (Unified Management) Account Settings.

           

           

          Related Articles

          • Integrating with 3rd Party Syslog and Threat Detection Platforms
            Read More
          • How to Generate a Capture Client (SentinelOne) API Key Using a Service User
            Read More
          • Integrating SonicWall Capture Client with SonicWall Firewalls
            Read More
          not finding your answers?