Getting Started with Druva MSP API

Instructions and samples to get started using the Druva MSP API

Authentication

Druva MSP supports OAuth 2.0 based authentication for API requests. Every use of Druva APIs requires authentication so that Druva can ensure that only authorized users can interact with Druva products.

All the requests to Druva APIs are authenticated using OAuth2 access token which you receive in exchange for every authorization grant request you make.

Access Token
To use Druva MSP APIs, you must send the request with the OAuth access token in the Authorization Header with each API request. Only a valid access token can return a successful API response.

API URLs
Use appropriate URLs in the requests.
For Druva MSP: Use https://apis.druva.com

Sample Requests and Responses

Before you begin, you must have the API Credentials, which is a combination of Client ID and Secret Key, for the application or tool which you intend to integrate with the Druva products. API Credentials can be created from the Druva MSC Customer Portal.

Sample API Credentials:

ncbpxxxxhQk2xxxxT5drxxxx5aIWxxxxDwmhxxxxL2c=
KjHexxxxeuPpxxxxjr2Zxxxxo8HVxxxxBaHzxxxxcQP=

To generate the Access Token and integrate with Druva MSP APIs:

Step 1: Encode the API Credentials to Base64. To encode the API Credentials to Base64, input the Client ID and Secret Key string separated by a Colon (:) in any Base64 encoding tool.

ncbpxxxxhQk2xxxxT5drxxxx5aIWxxxxDwmhxxxxL2c=:KjHexxxxeuPpxxxxjr2Zxxxxo8HVxxxxBaHzxxxxcQP=
bmNicHh4eHhoUWsyeHh4eFQ1ZHJ4eHh4NWFJV3h4eHhEd21oeHh4eEwyYz06S2pIZXh4eHhldVBweHh4eGpyMlp4eHh4bzhIVnh4eHhCYUh6eHh4eGNRUD0=

Step 2: Obtain the endpoint Access Token using the Base64 encoded API Credentials in the Authorization Header.

MSP Authentication URL: https://apis.druva.com/msp/auth/v1/token

curl -X POST -H 'authorization: Basic 
bmNicHh4eHhoUWsyeHh4eFQ1ZHJ4eHh4NWFJV3h4eHhEd21oeHh4eEwyYz06S2pIZXh4eHhldVBweHh4eGpyMlp4eHh4bzhIVnh4eHhCYUh6eHh4eGNRUD0=' -d 'grant_type=client_credentials' 
https://apis.druva.com/msp/auth/v1/token
from oauthlib.oauth2 import BackendApplicationClient
from requests.auth import HTTPBasicAuth
from requests_oauthlib import OAuth2Session


def getToken(clientId,secret):
 auth = HTTPBasicAuth(clientId, secret)
 client = BackendApplicationClient(client_id=clientId)
 oauth = OAuth2Session(client=client)
 token = oauth.fetch_token(token_url='https://apis.druva.com/msp/auth/v1/token', auth=auth)
 return token
{'access_token':'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbG91ZElkIjoieHh4eHh4eHgiLCJleHAiOjAsImlkIjoieHh4eHh4eHgiLCJyIjoieHh4eHh4eHgiLCJzZXNzaW9uSWQiOiJ4eHh4eHh4eCIsInVzZXJJZCI6Inh4eHh4eHh4In0.06d7rCObIkNoQWDaxp1lw8kOys5czybADXr6b5A5rEI', 'token_type': 'bearer', 'expires_in': 900}

Step 3: Make API request using the Access Token:
The example below is a GET request type made for MSP API.

curl -X GET -H 'Authorization: Bearer <Access Token>' https://apis.druva.com/msp/mspservice/v1/customers

Create API Access Token for your Customer

You can utilize the access token generated from MSP admin API credentials to generate customer-specific access token and leverage the customer APIs without generating separate credentials for every customer.

This enables you to automate tasks related to each customer and keep track of their activities.

To generate access token for a customer
You must have the MSP API Credentials, a combination of Client ID and Secret Key, for the application or tool you intend to integrate with the Druva products.

Procedure

  1. Create MSP API credentials from Druva Managed Services Center (MSC). Authenticate the third-party application using the Client ID and Secret Key through OAuth 2.0 with Grant Type set to Client Credentials. For more information, see Authentication.
  2. Get the customer global ID (GCID) using the List all customersAPI.
  3. Use the Generate API Access Token for a Customer to generate an access token for the respective customer. Use this access token to use the respective customer APIs.