Device Analytics API

Device Analytics

Access comprehensive analytics about your app's device attestations, security metrics, and usage patterns.

Overview

Grantiva provides detailed analytics to help you understand your app's security posture, identify threats, and make data-driven decisions about access control. All analytics endpoints require JWT authentication.

Analytics Dashboard

GET /api/v1/analytics/dashboard

Get a comprehensive overview of your app's security metrics and attestation statistics.

Request

curl -H "Authorization: Bearer YOUR_JWT_TOKEN" \
     "https://api.grantiva.com/api/v1/analytics/dashboard?period=7d"

Query Parameters

  • period - Time period: 24h, 7d, 30d, 90d (default: 7d)
  • timezone - Timezone for date grouping (default: UTC)

Response

{
  "summary": {
    "totalDevices": 15234,
    "activeDevices": 8421,
    "newDevices": 342,
    "attestationCount": 185420,
    "averageRiskScore": 22.5,
    "highRiskDevices": 45,
    "jailbrokenDevices": 12
  },
  "riskDistribution": {
    "low": 7842,
    "medium": 4521,
    "high": 2654,
    "critical": 217
  },
  "attestationTrend": [
    {
      "date": "2024-01-15",
      "count": 24521,
      "uniqueDevices": 8234
    },
    {
      "date": "2024-01-14",
      "count": 23854,
      "uniqueDevices": 8102
    }
  ],
  "topRiskFactors": [
    {
      "factor": "jailbreak_detected",
      "count": 12,
      "percentage": 0.08
    },
    {
      "factor": "invalid_receipt",
      "count": 89,
      "percentage": 0.58
    }
  ],
  "geographicDistribution": {
    "US": 8234,
    "CA": 2341,
    "GB": 1876,
    "other": 2783
  }
}

Device Details

GET /api/v1/analytics/devices/:deviceId

Get detailed information about a specific device including attestation history and risk analysis.

Response

{
  "deviceId": "dev_abc123",
  "firstSeen": "2024-01-01T00:00:00Z",
  "lastSeen": "2024-01-15T12:34:56Z",
  "attestationCount": 156,
  "currentRiskScore": 15,
  "riskHistory": [
    {
      "date": "2024-01-15",
      "score": 15,
      "factors": []
    },
    {
      "date": "2024-01-14",
      "score": 12,
      "factors": []
    }
  ],
  "deviceIntelligence": {
    "model": "iPhone 15 Pro",
    "osVersion": "17.2.1",
    "appVersion": "2.1.0",
    "jailbreakStatus": "clean",
    "integrityStatus": "verified"
  },
  "attestationHistory": [
    {
      "timestamp": "2024-01-15T12:34:56Z",
      "result": "success",
      "riskScore": 15,
      "ipAddress": "203.0.113.42",
      "country": "US"
    }
  ],
  "permissions": ["basic", "payments", "transfers"],
  "flags": []
}

Device Search

GET /api/v1/analytics/devices/search

Search and filter devices based on various criteria.

Query Parameters

# Search high-risk devices
curl -H "Authorization: Bearer YOUR_JWT_TOKEN" \
     "https://api.grantiva.com/api/v1/analytics/devices/search?riskScore=50-100"

# Search jailbroken devices
curl -H "Authorization: Bearer YOUR_JWT_TOKEN" \
     "https://api.grantiva.com/api/v1/analytics/devices/search?jailbroken=true"

# Search by country
curl -H "Authorization: Bearer YOUR_JWT_TOKEN" \
     "https://api.grantiva.com/api/v1/analytics/devices/search?country=US&limit=50"

Available Filters

  • riskScore - Range (e.g., "50-100") or threshold (e.g., ">75")
  • jailbroken - true/false
  • country - ISO country code
  • firstSeen - Date range (ISO 8601)
  • lastSeen - Date range (ISO 8601)
  • osVersion - iOS version
  • limit - Results per page (default: 20, max: 100)
  • offset - Pagination offset

Risk Analytics

GET /api/v1/analytics/risk/trends

Analyze risk score trends and identify emerging threats.

Response

{
  "period": "7d",
  "averageRiskScore": {
    "current": 22.5,
    "previous": 19.8,
    "change": 13.6
  },
  "riskTrend": [
    {
      "date": "2024-01-15",
      "averageScore": 23.2,
      "lowRisk": 7234,
      "mediumRisk": 3421,
      "highRisk": 892,
      "criticalRisk": 45
    }
  ],
  "emergingThreats": [
    {
      "threat": "new_jailbreak_method",
      "firstDetected": "2024-01-14T08:23:45Z",
      "affectedDevices": 23,
      "growthRate": 2.3
    }
  ],
  "anomalies": [
    {
      "type": "geographic_spike",
      "description": "Unusual activity from Romania",
      "severity": "medium",
      "timestamp": "2024-01-15T10:45:00Z"
    }
  ]
}

Export Analytics

POST /api/v1/analytics/export

Export analytics data for external analysis or compliance reporting.

Request Body

{
  "type": "device_report",
  "format": "csv",
  "period": "30d",
  "filters": {
    "riskScore": ">50",
    "country": ["US", "CA"]
  },
  "fields": [
    "deviceId",
    "riskScore",
    "lastSeen",
    "attestationCount",
    "jailbroken"
  ]
}

Export Types

  • device_report - Detailed device information
  • attestation_log - Raw attestation events
  • risk_analysis - Risk score analytics
  • compliance_report - Compliance-focused metrics

Real-time Monitoring

For Professional tier and above, real-time monitoring is available via webhooks:

// Webhook payload for high-risk device detected
{
  "event": "high_risk_device_detected",
  "timestamp": "2024-01-15T12:34:56Z",
  "data": {
    "deviceId": "dev_xyz789",
    "riskScore": 85,
    "riskFactors": ["jailbreak_detected", "geographic_anomaly"],
    "recommendation": "block_access"
  }
}

Analytics Best Practices

  • Regular Monitoring: Check analytics dashboard daily for anomalies
  • Set Up Alerts: Configure webhooks for high-risk events
  • Track Trends: Monitor risk score trends over time
  • Export for Analysis: Use exports for deeper analysis in BI tools
  • Act on Insights: Adjust security policies based on analytics

Rate Limits

Endpoint Rate Limit Window
Dashboard 100 requests Per hour
Device Details 1000 requests Per hour
Export 10 requests Per day

Next Steps