- 31 Oct 2022
- 3 Minutes to read
- Print
- DarkLight
- PDF
Import/Export Dashboards and Queries via API
- Updated on 31 Oct 2022
- 3 Minutes to read
- Print
- DarkLight
- PDF
Dashboards and queries can be imported and exported using the Axonius REST API. You can use Postman to execute the API commands.
It is also possible to import using the User Interface.
Pre Settings
You can download and use Postman to send import and export API requests.
To use Postman
- In the relevant Axonius machine, navigate to My Account, click on the API Key tab and copy the values for the api-key and api-secret.
- In Postman, navigate to the Headers tab and add the api-key and api-secret headers and paste the appropriate values into the corresponding fields.
- In the empty Key and Value fields under api-secret, enter the following:
- In the Key field enter Content-Type.
- In the Value field enter application/vnd.api+json.
Available Endpoints
- /api/dashboard/export - Export dashboard space(s)
- /api/dashboard/import - Import dashboard space(s)
- /api/dashboard/charts/export - Export specific chart(s)
- /api/dashboard/charts/import - Import specific chart(s)
- /api/devices/views/export - Export devices queries
- /api/devices/views/import - Import devices queries
- /api/users/views/export - Export users queries
- /api/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.
- 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.
- 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 ‘{}’
- 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.
- 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 ‘{}’.
- Export Queries
{
"meta": null,
"data": {
"type": "export_views_schema",
"attributes": {
"queries": ["Test A"],
"export_all": false
}
}
}
Attributes:
views - List of queries to export, comma separated.
export_all (optional) - Exports all visible queries in the system.
- 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."
}
]
}