API Reference
Complete reference for the Vaimanasoft Analytics Platform API v4. Base URL: https://vaimanasoft.com/api/v4
Overview
The Vaimanasoft API is organized into four endpoint groups:
| Group | Auth Method | Purpose |
|---|---|---|
| SDK | X-SDK-Key header | Device registration, event tracking from mobile apps |
| Auth | None / JWT | User login, registration, token refresh |
| Dashboard | JWT Bearer | Analytics queries, device management |
| AI / Billing / Notifications | JWT Bearer | AI insights, Stripe billing, push notifications |
All requests and responses use Content-Type: application/json.
Authentication
SDK Authentication
Mobile SDK endpoints authenticate via the X-SDK-Key header. Each app has a unique SDK key found in your dashboard settings.
GET /api/v4/devices/register
X-SDK-Key: your-app-sdk-key-here
JWT Authentication
Dashboard and management endpoints require a JWT Bearer token obtained from the /auth/login endpoint.
GET /api/v4/dashboard/overview?app_id=1
Authorization: Bearer eyJhbGciOiJIUzI1NiI...
Tokens expire after 24 hours. Use /auth/refresh to get a new token before expiry.
Error Handling
Errors return appropriate HTTP status codes with a JSON body:
{
"error": "Human-readable error message"
}
| Status | Meaning |
|---|---|
400 | Bad request — missing or invalid parameters |
401 | Unauthorized — invalid or expired token |
403 | Forbidden — insufficient permissions |
404 | Not found — endpoint or resource doesn't exist |
429 | Rate limited — too many requests |
500 | Internal error — report if persistent |
Rate Limits
Rate limits are applied per client (SDK key, user ID, or IP address):
| Tier | Limit | Window | Applies To |
|---|---|---|---|
| SDK | 200 requests | 1 minute | Device registration, events, flags |
| API | 100 requests | 1 minute | Dashboard endpoints |
| Auth | 10 requests | 5 minutes | Login, register |
| Export | 5 requests | 1 hour | CSV data exports |
Rate limit headers included in every response:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 87
X-RateLimit-Reset: 1711027260
When rate limited, the server returns HTTP 429 with a Retry-After header.
Register Device
Register or update a device. Returns the device record with assigned segment.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
android_id | string | Yes | Unique Android device ID |
brand | string | No | Device manufacturer |
model | string | No | Device model name |
android_version | string | No | OS version |
app_version | string | No | App version code |
fcm_token | string | No | Firebase Cloud Messaging token |
country | string | No | ISO 3166-1 alpha-2 country code |
install_type | string | No | organic or store |
Response (200)
{
"success": true,
"device": {
"id": 42,
"android_id": "abc123",
"user_segment": "active",
"created_at": "2026-03-01 12:00:00"
}
}
Update FCM Token
Update a device's FCM push notification token.
| Field | Type | Required |
|---|---|---|
android_id | string | Yes |
fcm_token | string | Yes |
Batch Events
Submit a batch of events (up to 50 per request). Events are processed transactionally.
{
"events": [
{
"android_id": "abc123",
"event_type": "ad_watched",
"event_data": {"ad_network": "admob", "reward": 10},
"created_at": "2026-03-20 14:30:00"
},
{
"android_id": "abc123",
"event_type": "page_view",
"event_data": {"page": "settings"}
}
]
}
SDK Auto-Register
Auto-register app + device on first launch. Uses X-API-Key (org key) instead of X-SDK-Key. Returns sdk_key for all future SDK calls. If app already exists, returns existing key.
Auth: X-API-Key: {org_api_key}
| Field | Type | Required | Description |
|---|---|---|---|
| package_name | string | Yes | Android package name |
| app_name | string | No | App label from AndroidManifest |
| android_id | string | Yes | Settings.Secure.ANDROID_ID |
| brand | string | No | Build.BRAND |
| android_ver | string | No | "Android API 34" |
| app_ver | string | No | "v 24.2.8H" |
| fcm_token | string | No | Firebase push token |
Response:
{
"success": true,
"sdk_key": "sk_b8695b97f896766c",
"app_id": 9,
"device_id": 5010881,
"app_action": "existing",
"device_action": "registered"
}SDK Profile + Segment
Full user profile with segment, ad strategy (33 fields), country, ad watches, purchase history. Replaces v3 UserSegmentationRepo.
Auth: X-SDK-Key
{
"success": true,
"profile": {
"device_id": 203,
"segment": "ACTIVE_USER",
"country": "IN",
"total_ad_watches": 47,
"days_since_first_install": 102,
"ad_strategy": {
"ads_enabled": true,
"interstitial_enabled": true,
"ad_cooldown_sec": 90,
"interstitial_cap": 3,
"interstitial_daily_cap": 8,
"rewarded_cap": 15,
"app_open_cooldown_sec": 2400,
"app_open_daily_cap": 3,
"pre_show_delay_ms": 1500,
"config_version": 2
}
}
}SDK Update Profile
Update user action and recalculate segment. Actions: ad_watched, purchase_made, update_country, app_update, session_start.
Auth: X-SDK-Key
// Request
{ "android_id": "9fd960b07a8c4327", "action": "ad_watched" }
// Response
{ "segment": "POWER_USER", "ad_strategy": { ... } }SDK Revenue Tracking
Track ad revenue events with network, type, geo tier, and estimated revenue.
Auth: X-SDK-Key
{
"android_id": "9fd960b07a8c4327",
"ad_type": "rewarded",
"ad_network": "admob",
"revenue": 0.0035,
"ecpm": 3.50,
"geo_tier": "tier3",
"country": "IN"
}Play Store: List Tracked Apps
List all tracked Play Store apps for the organization. Auth: JWT.
Play Store: Scrape App
Scrape app metadata from Google Play Store. Body: { "package_name": "com.example.app" }. Auth: JWT.
Play Store: Compare Apps
Compare multiple apps side by side. Body: { "packages": ["com.app1", "com.app2"] }. Auth: JWT.
Cross-Promo: Campaigns
List cross-promotion campaigns. CRUD: GET (list), POST (create), PUT /:id (update), DELETE /:id. Auth: JWT.
Cross-Promo: Stats
Campaign performance: impressions, clicks, installs, CTR. Auth: JWT.
Cross-Promo: AI Suggestions
AI-powered campaign recommendations based on app performance and user segments. Auth: JWT.
Automation: Rules
CRUD for automation rules. Triggers: rating_drop, download_spike, negative_review_spike, new_version_detected, competitor_update. Actions: telegram, webhook, email. Auth: JWT.
Automation: Log
Automation execution history. Auth: JWT.
Automation: Agent Bridge
Inter-agent message queue. Used by OpenClaw (.209) and Claude Channels (.211) to communicate with the platform. Auth: JWT.
AI Assistant: Chat
Multi-turn AI chat powered by Claude. Supports conversation history. Body: { "message": "How are my apps doing?", "conversation_id": 1 }. Auth: JWT.
AI Assistant: Cross-Analysis
Correlate Play Store metrics with internal analytics data. Auth: JWT.
AI Assistant: ASO Suggestions
App Store Optimization recommendations based on competitor analysis. Auth: JWT.
AI Assistant: Reports
Generate AI reports. Types: daily_summary, weekly, competitor, revenue, review. Auth: JWT.
AI Assistant: Sentiment Analysis
Analyze review sentiment using Claude Haiku. Auth: JWT.
CodeAgent: Status
CodeClaw agent status: open issues, fixed issues, job history. Auth: JWT.
CodeAgent: Lint
Run PHP lint on all project files. Returns error count and details. Auth: JWT.
CodeAgent: Security Scan
Run security scan: SQL injection, XSS, hardcoded credentials, insecure headers. Auth: JWT.
DevOps: System Status
Full system status: git branch, DB latency, table counts, agent status, API stats, disk/memory usage. Auth: JWT or X-Admin-Token.
DevOps: Deploy
Trigger deployment to dev or production. Auth: X-Admin-Token.
Blog: List Posts
List published blog posts with title, slug, excerpt, date. Auth: JWT.
Blog: AI Generate
AI-generate a blog article draft. Body: { "topic": "...", "keywords": [...] }. Auth: JWT.
Webhooks: List
List all webhooks. Returns name, URL, subscribed events, active status. Auth: JWT.
Webhooks: Create
Create webhook. Body: { "url": "https://...", "events": ["device.registered", "event.batch"], "name": "My Hook" }. Returns webhook secret for HMAC verification. Auth: JWT.
Webhooks: Test
Send test payload to webhook URL. Returns status code and response time. Auth: JWT.
Settings: Theme
Get/update theme settings (primary color, mode, sidebar style). GET to read, PUT to update. Auth: JWT.
Settings: Activity Log
Activity log with user actions, timestamps, IP addresses. Filterable by action type. Auth: JWT.
Register Account
Create a new organization and owner user account. Returns a JWT token.
| Field | Type | Required |
|---|---|---|
name | string | Yes |
email | string | Yes |
password | string | Yes (min 8 chars) |
org_name | string | Yes |
// Response
{
"token": "eyJhbGciOiJIUzI1NiI...",
"user": { "id": 5, "org_id": 3, "role": "owner" }
}
Login
Authenticate with email and password. Returns a JWT token valid for 24 hours.
// Request
{ "email": "user@example.com", "password": "your-password" }
// Response
{
"token": "eyJhbGciOiJIUzI1NiI...",
"user": { "id": 1, "org_id": 1, "role": "owner" }
}
Refresh Token
Exchange a valid (non-expired) JWT for a fresh token.
List Apps
List all apps belonging to the authenticated user's organization.
{
"apps": [
{ "id": 1, "name": "My App", "package_name": "com.example.myapp", "sdk_key": "sk_..." }
]
}
Dashboard Overview
Key metrics for an app: total devices, active users (30d), new users (7d), events today, ad watches, purchases.
User Segments
Returns device counts grouped by user segment (e.g., power_user, active, casual, dormant, churned).
List Devices
Paginated device list with filtering.
| Param | Type | Default | Description |
|---|---|---|---|
page | int | 1 | Page number |
limit | int | 50 | Results per page (max 100) |
search | string | Search by android_id, brand, model | |
segment | string | Filter by user_segment | |
country | string | Filter by country code |
Trends
Daily time-series data for the specified period. Returns active_devices, new_devices, total_events per day.
Countries
Device counts grouped by country code, sorted descending.
Natural Language Query
Ask questions in plain English. Claude AI translates your question to SQL, executes it safely, and returns results with a narrative explanation.
// Request
{ "query": "How many users from India watched more than 50 ads this month?" }
// Response
{
"answer": "There are 142 users from India who watched more than 50 ads...",
"sql": "SELECT COUNT(*) FROM devices WHERE ...",
"data": [{"count": 142}]
}
Get AI Insights
Returns cached AI-generated insights (daily summaries, anomaly alerts, weekly reports).
Churn Risk Analysis
Identifies devices at risk of churning with AI-generated risk scores and recommended actions.
Subscription Status
Returns the current subscription plan, status, and period end date for the authenticated organization.
{
"plan": "pro",
"status": "active",
"current_period_end": "2026-04-20T00:00:00Z",
"limits": { "apps": 10, "devices": 100000, "events_per_month": 10000000 }
}
Create Checkout Session
Creates a Stripe Checkout session for upgrading to a paid plan.
// Request
{ "plan": "pro" } // "starter", "pro", or "enterprise"
// Response
{ "checkout_url": "https://checkout.stripe.com/c/pay/cs_..." }
Customer Portal
Creates a Stripe Customer Portal session for managing payment methods, invoices, and subscription changes.
{ "portal_url": "https://billing.stripe.com/p/session/..." }
Cancel Subscription
Cancels the current subscription at the end of the billing period. Access continues until period end.
Send Push Notification
Send a push notification to a device, segment, or all users.
// Send to segment
{
"app_id": 1,
"target": "segment",
"segment": "dormant",
"title": "We miss you!",
"body": "Come back and check out new features.",
"data": {"screen": "home"}
}
// Send to single device
{ "app_id": 1, "target": "device", "device_id": 42, "title": "...", "body": "..." }
// Broadcast to all
{ "app_id": 1, "target": "all", "title": "...", "body": "..." }
Notification History
Returns the last 50 notifications sent or scheduled for the app, newest first.
{
"notifications": [
{
"id": 12,
"title": "Flash Sale!",
"body": "50% off premium today only.",
"target": "all",
"segment": null,
"sent": 3219,
"failed": 12,
"status": "delivered",
"sent_at": "2026-03-21 10:30:00",
"created_at": "2026-03-21 10:30:00"
}
]
}
List Experiments
Returns all A/B experiments for the app with variant assignments count.
Create Experiment
Create a new A/B test experiment.
{
"app_id": 1,
"name": "CTA Button Color",
"description": "Test green vs orange CTA buttons",
"variants": [
{"key": "control", "name": "Green", "weight": 50},
{"key": "variant_a", "name": "Orange", "weight": 50}
],
"target_metric": "purchase"
}
Update Experiment Status
Change experiment status: draft → running → paused / completed.
{ "app_id": 1, "status": "running" }
List Feature Flags
Returns all feature flags for the app with their current status and rollout percentage.
Create Feature Flag
Create a new feature flag. Supports boolean and multivariate types.
// Boolean flag
{
"app_id": 1,
"flag_key": "new_onboarding",
"name": "New Onboarding Flow",
"flag_type": "boolean",
"is_enabled": true,
"rollout_pct": 25
}
// Multivariate flag
{
"app_id": 1,
"flag_key": "cta_color",
"name": "CTA Button Color",
"flag_type": "multivariate",
"is_enabled": true,
"rollout_pct": 100,
"variants": [
{"key": "green", "value": "#22C55E", "weight": 50},
{"key": "orange", "value": "#F59E0B", "weight": 50}
]
}
Update Feature Flag
Update a flag's enabled state, rollout percentage, or variants. All fields are optional.
{ "app_id": 1, "is_enabled": true, "rollout_pct": 50 }
SDK Feature Flags Endpoint
Returns evaluated feature flags for a specific device. Uses CRC32-based deterministic assignment so the same device always gets the same variant.
{
"flags": {
"new_onboarding": { "enabled": true, "type": "boolean" },
"cta_color": {
"enabled": true,
"type": "multivariate",
"variant": "green",
"value": "#22C55E"
}
}
}
Cache-Control header. The Android SDK caches flags locally with a 60s TTL.
Export Devices (CSV)
Streams all devices as a CSV file. Rate limited to 5 requests per hour.
Export Events (CSV)
Streams the last 30 days of events as a CSV file. Rate limited to 5 requests per hour.
Android SDK Setup (Kotlin)
Add the Vaimanasoft SDK to your Android project. Available in both Kotlin and Java.
1. Add the SDK file
Copy Vaimanasoft.kt (or Vaimanasoft.java) into your project's source directory. No Gradle dependencies required.
2. Initialize in Application class
// Kotlin
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
Vaimanasoft.init(this, "sk_your_sdk_key")
}
}
3. Add required permissions
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Tracking Events
// Generic event with properties
Vaimanasoft.track("button_clicked", bundleOf("button" to "subscribe"))
// Convenience methods
Vaimanasoft.trackPurchase("premium_monthly", amount = 9.99)
Vaimanasoft.trackAdWatched()
Vaimanasoft.trackFeatureUsed("dark_mode")
Vaimanasoft.trackPageView("settings")
// Session lifecycle
Vaimanasoft.trackSessionStart()
Vaimanasoft.trackSessionEnd()
// Manually flush pending events
Vaimanasoft.flush()
// Graceful shutdown
Vaimanasoft.shutdown()
Feature Flags in SDK
Feature flags are fetched on init and cached locally for 60 seconds.
// Boolean flag check
if (Vaimanasoft.isEnabled("new_onboarding")) {
showNewOnboarding()
}
// Multivariate flag
val ctaColor = Vaimanasoft.getVariant("cta_color") // "green", "orange", etc.
val headline = Vaimanasoft.getValue("promo_headline", defaultValue = "Welcome!")
// Force refresh from server
Vaimanasoft.refreshFlags()
Push Notifications (FCM)
Pass FCM tokens to Vaimanasoft to enable server-side push notifications.
class MyFirebaseService : FirebaseMessagingService() {
override fun onNewToken(token: String) {
super.onNewToken(token)
Vaimanasoft.updateFcmToken(token)
}
}
// Also fetch token on app start
FirebaseMessaging.getInstance().token.addOnSuccessListener { token ->
Vaimanasoft.updateFcmToken(token)
}
Webhooks
Webhooks deliver real-time HTTP callbacks when events occur in your app. Configure endpoints to receive event data as JSON payloads signed with HMAC-SHA256.
List all webhooks for an app. Returns name, URL, subscribed events, active status, and failure count.
Create a new webhook (max 10 per app). Returns a signing secret — store it securely.
{
"app_id": 1,
"name": "Analytics Hook",
"url": "https://example.com/webhook",
"events": ["session_start", "purchase", "*"]
}
Supported events: session_start, session_end, purchase, ad_watched, page_view, feature_used, notification_clicked, * (all).
Update webhook name, URL, events, or active status. Send only fields to update.
Permanently delete a webhook and all its delivery history.
Send a test payload to verify your endpoint. Returns the HTTP response code and body.
Get the last 25 delivery attempts for a webhook. Includes response code, duration, and status.
Signature Verification
All webhook deliveries include an X-Vaimanasoft-Signature header. Verify it with HMAC-SHA256:
// Node.js
const crypto = require('crypto');
const expected = 'sha256=' + crypto.createHmac('sha256', webhookSecret)
.update(rawBody).digest('hex');
const valid = crypto.timingSafeEqual(
Buffer.from(signature), Buffer.from(expected)
);
Custom Segments
Define rule-based segments to group users by behavior, device attributes, or engagement metrics. Segments are recalculated nightly or on demand.
List all custom segments for an app, including rules, cached device count, and last calculation time.
Create a custom segment with rules (max 20 per app).
{
"app_id": 1,
"name": "Power Users India",
"description": "High-engagement users from India",
"logic": "AND",
"color": "#22c55e",
"rules": [
{ "field": "country", "operator": "eq", "value": "IN" },
{ "field": "session_count_30d", "operator": "gte", "value": "50" }
]
}
| Rule Field | Type | Description |
|---|---|---|
days_since_install | number | Days since first install |
days_inactive | number | Days since last activity |
event_count_30d | number | Total events in last 30 days |
session_count_30d | number | Sessions in last 30 days |
ad_watches_30d | number | Ad views in last 30 days |
purchase_count | number | All-time purchases |
country | text | ISO country code |
app_version | text | App version string |
brand | text | Device manufacturer |
install_type | text | Install source |
Operators: eq, neq, gt, gte, lt, lte, contains
Update segment name, rules, logic, color, or active status.
Recalculate segment membership on demand. Returns the updated device count.
// Response
{ "device_count": 1204, "segment_id": 5 }
Alerts
Configure metric-based alerts that notify you via email, webhook, or dashboard when conditions are met.
List all alert rules and recent alert history for an app.
{
"app_id": 1,
"name": "DAU Drop Alert",
"metric": "dau",
"condition": "drops_by",
"threshold": 20,
"compare_window": "week",
"channel": "email"
}
Metrics: dau, new_users, events, ad_watches, purchases, crash_rate, churn_rate
Conditions: drops_by, increases_by, below, above
Channels: email, webhook, dashboard
Delete an alert rule.
Funnels
Analyze conversion funnel for a sequence of events. Pass ordered event types to calculate drop-off at each step.
{
"app_id": 1,
"steps": ["session_start", "page_view", "ad_watched", "purchase"],
"from": "2026-03-01",
"to": "2026-03-21"
}
Retention Cohorts
Get cohort retention data. Returns weekly cohorts with day-1, day-7, day-14, day-30 retention rates.
User Path Analysis
Analyze most common user event sequences. Returns top N paths with their frequency and conversion data.
{ "app_id": 1, "start_event": "session_start", "depth": 5, "limit": 20 }
Custom Dashboards
List all custom dashboards for an app. Each dashboard contains an array of widget configurations.
{
"app_id": 1,
"name": "Growth Overview",
"widgets": [
{ "type": "kpi", "metric": "active_devices", "label": "DAU" },
{ "type": "line_chart", "metric": "new_devices", "label": "New Users" }
]
}
Widget types: kpi, line_chart, bar_chart, pie_chart
Update dashboard name or widgets array.
Team Management
List all team members in the organization with their role (owner, admin, viewer).
{ "email": "newmember@example.com", "role": "admin" }
Roles: owner (full access), admin (manage apps, view billing), viewer (read-only).
Update a team member's role. Requires admin or owner access.
Remove a team member from the organization. Cannot remove the owner.
System Health
Health check endpoint (no auth required). Returns status of all services.
// Response
{
"status": "ok",
"database": { "status": "ok", "latency_ms": 2 },
"redis": { "status": "ok" },
"storage": { "writable": true, "free_gb": 45.2 },
"queue": { "status": "ok", "pending_jobs": 3 },
"php_version": "8.2.15",
"uptime_seconds": 86400,
"version": "4.0.0"
}
Queue statistics — job counts by status and queue name. Includes recent failures. Requires admin role.
Real-Time Event Stream (SSE)
Server-Sent Events stream for real-time event monitoring. Pass JWT as query parameter. Uses Redis pub/sub when available, falls back to database polling.
// JavaScript
const es = new EventSource(`/api/v4/stream?app_id=1&token=${jwt}`);
es.onmessage = (e) => {
const events = JSON.parse(e.data);
console.log('New events:', events);
};
EventSource. Heartbeats are sent every 15 seconds.Rate Limits by Plan
Rate limits are enforced per API key or JWT. Limits scale with your subscription plan.
| Endpoint Tier | Free | Starter | Pro | Enterprise |
|---|---|---|---|---|
| SDK (ingestion) | 200/min | 500/min | 2,000/min | 10,000/min |
| Dashboard API | 100/min | 300/min | 1,000/min | 5,000/min |
| Auth | 10 per 5 minutes (all plans) | |||
| Data Export | 5/hr | 20/hr | 60/hr | 200/hr |
Rate limit headers are included in every response: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset.
Vaimanasoft Analytics Platform v4.0 — vaimanasoft.com