API Examples

Code examples for common Dashboard API operations

This guide provides code examples for common Dashboard API operations.

Example 1: Get AWS IAM Insights Dashboard

Retrieve a specific OOTB dashboard by its ID:

curl --location --request GET \
  'https://company.veza.com/api/preview/assessments/reports/64e4231c-ead9-4bf0-bed7-afa94511f476' \
  --header 'Authorization: Bearer YOUR_API_TOKEN' \
  --header 'Accept: application/json'

Python:

import requests

headers = {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Accept': 'application/json'
}

response = requests.get(
    'https://company.veza.com/api/preview/assessments/reports/64e4231c-ead9-4bf0-bed7-afa94511f476',
    headers=headers
)

dashboard = response.json()['value']
print(f"Dashboard: {dashboard['name']}")
print(f"Type: {dashboard['type']}")
print(f"Queries: {len(dashboard.get('queries', []))}")

JavaScript:

const response = await fetch(
  'https://company.veza.com/api/preview/assessments/reports/64e4231c-ead9-4bf0-bed7-afa94511f476',
  {
    headers: {
      'Authorization': 'Bearer YOUR_API_TOKEN',
      'Accept': 'application/json'
    }
  }
);

const data = await response.json();
console.log(`Dashboard: ${data.value.name}`);
console.log(`Type: ${data.value.type}`);

Example 2: List All Dashboards

Get all dashboards in your tenant:

curl --location --request GET \
  'https://company.veza.com/api/preview/assessments/reports' \
  --header 'Authorization: Bearer YOUR_API_TOKEN' \
  --header 'Accept: application/json'

Python:

import requests

headers = {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Accept': 'application/json'
}

response = requests.get(
    'https://company.veza.com/api/preview/assessments/reports',
    headers=headers
)

dashboards = response.json()['values']
print(f"Total dashboards: {len(dashboards)}")

for dashboard in dashboards:
    print(f"- {dashboard['name']} ({dashboard['type']})")

Example 3: Filter Dashboards by Type

Find only system-created (OOTB) dashboards:

curl --location --request GET \
  'https://company.veza.com/api/preview/assessments/reports' \
  --header 'Authorization: Bearer YOUR_API_TOKEN' \
  --header 'Accept: application/json'

Python:

import requests

headers = {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Accept': 'application/json'
}

response = requests.get(
    'https://company.veza.com/api/preview/assessments/reports',
    headers=headers
)

all_dashboards = response.json()['values']

# Filter for system-created (OOTB) dashboards
system_dashboards = [d for d in all_dashboards if d['type'] == 'system_created']
print(f"System (OOTB) dashboards: {len(system_dashboards)}")

# Filter for user-created (custom) dashboards
user_dashboards = [d for d in all_dashboards if d['type'] == 'user_created']
print(f"User (custom) dashboards: {len(user_dashboards)}")

Example 4: Get Time-Series Data

Retrieve historical query results for trend analysis:

curl --location --request GET \
  'https://company.veza.com/api/preview/assessments/reports/64e4231c-ead9-4bf0-bed7-afa94511f476/queries/timeseries?start_time=2024-01-01T00:00:00Z' \
  --header 'Authorization: Bearer YOUR_API_TOKEN' \
  --header 'Accept: application/json'

Python:

import requests
from datetime import datetime, timedelta

headers = {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Accept': 'application/json'
}

# Get last 30 days of data
start_time = datetime.utcnow() - timedelta(days=30)

params = {
    'start_time': start_time.isoformat() + 'Z'
    # Note: end_time parameter does not exist - data returned from start_time to present
}

response = requests.get(
    'https://company.veza.com/api/preview/assessments/reports/64e4231c-ead9-4bf0-bed7-afa94511f476/queries/timeseries',
    headers=headers,
    params=params
)

# Response structure: { "values": [{ "query_id": "...", "series": [...] }] }
data = response.json()['values']
for query_data in data:
    print(f"Query ID: {query_data['query_id']}")
    print(f"Data points: {len(query_data['series'])}")

    # Each data point has: evaluated_at, value, risks_count
    if query_data['series']:
        latest = query_data['series'][-1]
        print(f"  Latest value: {latest['value']} at {latest['evaluated_at']}")

Example 5: Create a Custom Dashboard

Create a new dashboard programmatically:

Python:

import requests

headers = {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Accept': 'application/json',
    'Content-Type': 'application/json'
}

data = {
    'name': 'My AWS Security Dashboard',
    'description': 'Custom dashboard tracking AWS security findings',
    'sections': [
        {
            'name': 'Critical Findings',
            'queries': [
                'query-id-1',  # Replace with actual query IDs
                'query-id-2'
            ]
        }
    ]
}

response = requests.post(
    'https://company.veza.com/api/preview/assessments/reports',
    headers=headers,
    json=data
)

new_dashboard = response.json()['value']
print(f"Created dashboard: {new_dashboard['id']}")
print(f"Dashboard URL: https://company.veza.com/app/dashboard/library/{new_dashboard['id']}")

Last updated

Was this helpful?