Import/Export Dashboards and Queries via API
  • 10 Apr 2022
  • 3 Minutes to read
  • Dark
    Light
  • PDF

Import/Export Dashboards and Queries via API

  • Dark
    Light
  • PDF

Dashboards and queries can be imported and exported using the Axonius REST API. You can use Postman to execute the API commands.

Pre Settings

You can download and use Postman to send import and export API requests.

To use Postman

  1. In Postman, navigate to the Headers tab and add the api-key and api-secret headers.
  2. In the relevant machine, navigate to My Account and click on the API Key tab.
  3. Copy the values for the api-key and api-secret and paste them into the corresponding headers in Postman.

Available Endpoints

  • dashboard/export - Export dashboard space(s)
  • dashboard/import - Import dashboard space(s)
  • dashboard/charts/export - Export specific chart(s)
  • dashboard/charts/import - Import specific chart(s)
  • devices/views/export - Export devices queries
  • devices/views/import - Import devices queries
  • users/views/export - Export users queries
  • users/views/import - Import users queries

Request Format

The full request URL should consist of: https://<machine URL>/api/<endpoint>

Example: 'https://10.20.0.111/api/dashboard/export'

where:

  • machine URL is 10.20.0.111
  • endpoint is /dashboard/export

Request Methods

The following request methods can be used:

  • POST executes both the import and export actions.

Available Requests

The following requests are available.

  1. Export Dashboards
{
   "meta": null,
   "data": {
       "type": "export_spaces_schema",
       "attributes": {
           "spaces": ["Test Space 123"]
       }
   }
}

Attributes:

  • spaces - A comma separated list of spaces (dashboards) to export.
  1. Import Spaces
{
   "meta": null,
   "data": {
       "type": "import_spaces_schema",
       "attributes": {
           "replace": true,
           "data": {}
       }
   }
}

Attributes:

  • replace:

    • true - If exists, replace existing content with the imported content.

    • false - If exists, add new content with a date suffix.

  • data (row 7) - The export results should be pasted instead of the ‘{}’

  1. Export Charts
{
   "meta": null,
   "data": {
       "type": "export_charts_schema",
       "attributes": {
           "charts": ["Test gcp or tests assets"],
           "space": "Test Space",
           "export_all": false
       }
   }
}

Attributes:

  • charts - List of charts to export, comma separated.

  • space - The dashboard in which the charts are stored.

  • export_all (optional) - Exports all charts under the dashboard.

  1. Import Charts
{
   "meta": null,
   "data": {
       "type": "import_charts_schema",
       "attributes": {
           "replace": true,
           "space": "Test Space 123",
           "create_space": true,
           "data": {}
       }
   }
}

Attributes:

  • replace:

    • true - If exists, replace existing content with the imported content.

    • false - If exists, add new content with a date suffix.

  • space: under which space name to add the imported charts. If not provided, chart will imported into the space listed in the exported file.

  • create_space:

    • true - Create the space with the provided space name if it does not exist.

    • false - Don’t create the space with the provided space name if it does not exist.

  • data (row 9) - The export results should be pasted instead of the ‘{}’.

  1. Export Queries
{
   "meta": null,
   "data": {
       "type": "export_views_schema",
       "attributes": {
           "views": ["Test A"],
           "export_all": false
       }
   }
}

Attributes:

  • views - List of queries to export, comma separated.

  • export_all (optional) - Exports all visible queries in the system.

  1. Import Queries
{
   "meta": null,
   "data": {
       "type": "import_views_schema",
       "attributes": {
           "replace": true,
           "data": {}
       }
   }
}

Attributes:

  • replace - A comma separated list of queries to export.

    • true - If exists, replace existing content with the imported content.

    • false - If exists, add new content with a date suffix.

  • data (row 7) - The export results should be pasted instead of the ‘{}’.

Known Error Messages

General Errors

No Permissions

{
    "errors": [
        {
            "additional_data": null,
            "detail": "You do not have all permissions required for this request”
        }
    ]
}

Wrong API key / User doesn’t exist

{
    "errors": [
        {
            "additional_data": null,
            "detail": "Not logged in"
        }
    ]
}

Syntax Error

{"status": "error", "type": "JSONDecodeError", "message": "An error occurred. Please contact Axonius support. AX-ID:
9d4584b1-49f9-4def-8163-43f67432d1fa"}

Dashboard Errors

Exported dashboard does not exist

{
    "errors": [
        {
            "additional_data": null,
            "detail": "Could not find matching spaces."
        }
    ]
}

Exported dashboard name is not specified

{
    "errors": [
        {
            "additional_data": null,
            "detail": "Space names are required for  export."
        }
    ]
}

Trying to export a personal dashboard

{
    "errors": [
        {
            "additional_data": null,
            "detail": "Could not export Default/Personal dashboards."
        }
    ]
}

Imported dashboard data is not specified

{
    "errors": [
        {
            "additional_data": null,
            "detail": "Could not find spaces to import."
        }
    ]
}

What's Next
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.