Skip to main content
NetApp Backup and Recovery

Automate NetApp Backup and Recovery with REST APIs

Contributors netapp-mwallis

Use the NetApp Backup and Recovery REST API to automate the backup and restore tasks available in the web UI.

NetApp Backup and Recovery defines ten endpoint categories:

  • backup - manages backup operations for cloud and on-premises resources and retrieves backup data details

  • catalog - manages indexed catalog searches for files based on a query (Search & Restore)

  • cloud - retrieves information about various cloud provider resources from the NetApp Console

  • job - manages job detail entries in the NetApp Console database

  • license - retrieves system license status from NetApp Console

  • ransomware scan - initiates a ransomware scan on a specific backup file

  • restore - enables you to perform volume, file, and folder-level restore operations

  • sfr - retrieves files from a backup file for single file-level restore operations (Browse & Restore)

  • storagegrid - retrieves details about a StorageGRID server and enables you to discover a StorageGRID server

  • system - manages backup policies and configures the destination object store associated with a system

API reference

Documentation for each NetApp Backup and Recovery API is available from NetApp Console automation for NetApp Backup and Recovery.

Getting started

To get started with the NetApp Backup and Recovery APIs, obtain a user token, your NetApp Console account ID, and the Console agent ID.

When you make API calls, include the user token in the Authorization header and the Console agent ID in the x-agent-id header. Include the NetApp Console account ID in API requests.

Note If you use a service account, use the service access token instead of a user token. The value for client_id (Mu0V1ywgYteI6w1MbD15fKfVIUrNXGWC) is fixed and cannot be changed. In this case, follow the instructions here: Create a service access token.
Steps
  1. Obtain a user token from the NetApp Console website.

    Generate the refresh token from the following link: https://services.cloud.netapp.com/refresh-token/. The refresh token is an alphanumeric string that you use to generate a user token.

    curl --location --request POST 'https://netapp-cloud-account.auth0.com/oauth/token?=' \
    --header 'Content-Type: application/json' \
    -d '{
        "grant_type": "refresh_token",
        "refresh_token": "JxaVHn9cGkX92aPVCkhat3zxxxxxwsC9qMl_pLHkZtsVA",
        "client_id": "Mu0V1ywgYteI6w1MbD15fKfVIUrNXGWC"
    }'
    Note The user token from the NetApp Console website expires. The API response includes an expires_in field that indicates when the token expires. To refresh the token, call this API again.
  2. Obtain your NetApp Console account ID.

    GET 'https://api.bluexp.netapp.com/tenancy/account' -H 'authority: api.bluexp.netapp.com'
    Header:
    -H 'accept: application/json'
    -H 'accept-language: en-GB,en;q=0.9'
    -H 'authorization: Bearer eyJhbGciOiJSUzI1NiIsInR

    This API returns a response like the following. Retrieve the account ID from [0].[accountPublicId].

    {
      "accountPublicId": "account-i6vJXvZW",
      "accountName": "rashidn",
      "isSaas": true,
      "isGov": false,
      "isPrivatePreviewEnabled": false,
      "is3rdPartyServicesEnabled": false,
      "accountSerial": "96064469711530003565",
      "userRole": "Role-1"
    }
  3. Obtain the x-agent-id header value, which contains the Console agent ID.

    GET 'https://api.services.cloud.netapp.com/occm/list-occms/account-OOnAR4ZS?excludeStandalone=true&source=saas' \
    Header:
      -H 'authority: api.services.cloud.netapp.com' \
      -H 'accept: application/json' \
      -H 'accept-language: en-GB,en;q=0.9' \
      -H 'authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5…………

    Retrieve the agent ID from the response by parsing occm.[0].[agent].[agentId].

Example using the APIs

The following example shows an API call that activates NetApp Backup and Recovery on a system with a new policy. The policy has daily, hourly, and weekly labels and archives after 180 days in the East US 2 Azure region. This request enables backup on the system, but it does not back up any volumes.

API Request

You'll see that we use the NetApp Console account ID account-DpTFcxN3, Console agent ID iZwFFeVCZjWnzGlw8RgD0QQNANZvpP7Iclients, and user token Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik5rSXlPVFUzUWpZek1E…y6nyhBjwkeMwHc4ValobjUmju2x0xUH48g in this command.

curl --location --request POST 'https://api.bluexp.netapp.com/account/account-DpTFcxN3/providers/cloudmanager_cbs/api/v3/backup/working-environment/VsaWorkingEnvironment-99hPYEgk' \
--header 'x-agent-id: iZwFFeVCZjWnzGlw8RgD0QQNANZvpP7Iclients' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik5rSXlPVFUzUWpZek1E…y6nyhBjwkeMwHc4ValobjUmju2x0xUH48g' \
--data-raw '{
    "provider":"AZURE",
    "backup-policy": {
      "archive-after-days": 180,
      "rule": [
        {
          "label": "hourly",
          "retention": "2"
        },
        {
          "label": "daily",
          "retention": "30"
        },
        {
          "label": "weekly",
          "retention": "52"
        }
      ]
    },
    "ip-space": "Default",
    "region": "eastus2",
    "azure": {
      "resource-group": "rn-test-backup-rg",
      "subscription": "3beb4dd0-25d4-464f-9bb0-303d7cf5c0c2"
    }
  }
Response includes a job ID that you can monitor:
{
 "job-id": "1b34b6f6-8f43-40fb-9a52-485b0dfe893a"
}
Monitor the job status:
curl --location --request GET 'https://api.bluexp.netapp.com/account/account-DpTFcxN3/providers/cloudmanager_cbs/api/v1/job/1b34b6f6-8f43-40fb-9a52-485b0dfe893a' \
--header 'x-agent-id: iZwFFeVCZjWnzGlw8RgD0QQNANZvpP7Iclients' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik5rSXlPVFUzUWpZek1E…hE9ss2NubK6wZRHUdSaORI7JvcOorUhJ8srqdiUiW6MvuGIFAQIh668of2M3dLbhVDBe8BBMtsa939UGnJx7Qz6Eg'
Response:
{
  "job": [
    {
      "id": "1b34b6f6-8f43-40fb-9a52-485b0dfe893a",
      "type": "backup-working-environment",
      "status": "PENDING",
      "error": "",
      "time": 1651852160000
    }
  ]
}
Monitor until status is COMPLETED:
{
  "job": [
    {
      "id": "1b34b6f6-8f43-40fb-9a52-485b0dfe893a",
      "type": "backup-working-environment",
      "status": "COMPLETED",
      "error": "",
      "time": 1651852160000
    }
  ]
}