SegOps AIDocs

Analytics API

Six read-only endpoints for platform analytics. All require JWT or API-key authentication.

Base path: /api/analytics/


Overview#

http
GET /api/analytics/overview/
Authorization: Bearer <token>

Response

json
{
  "segment_count": 12,
  "total_members": 48320,
  "events_30d": 1842000,
  "ai_credits_used": 34,
  "ai_credits_limit": 100
}

ai_credits_limit: -1 means unlimited (Enterprise plan).


Segment Analytics#

http
GET /api/analytics/segments/
Authorization: Bearer <token>

Returns all active segments with a 30-day daily membership trend from ClickHouse.

Response

json
[
  {
    "id": 7,
    "name": "High LTV Buyers",
    "member_count": 3482,
    "last_computed_at": "2026-05-02T14:32:00Z",
    "trend": [
      { "day": "2026-04-03", "count": 3201 },
      { "day": "2026-04-04", "count": 3318 }
    ]
  }
]

trend is empty if the segment has never been computed or was computed fewer than 2 days ago.


Segment Overlap#

http
GET /api/analytics/overlap/
Authorization: Bearer <token>

Top-20 segment pairs by shared member count. Computed from a ClickHouse self-JOIN on segment_memberships FINAL.

Response

json
[
  {
    "seg_a_id": 7,
    "seg_a_name": "High LTV Buyers",
    "seg_b_id": 12,
    "seg_b_name": "Email Subscribers",
    "overlap": 1204,
    "overlap_pct": 34.6
  }
]

overlap_pct = overlap / min(seg_a_member_count, seg_b_member_count) * 100.

Returns [] if fewer than 2 segments exist or no cross-segment members are found.


Activation Analytics#

http
GET /api/analytics/activations/
Authorization: Bearer <token>

Per-connector breakdown including recent sync history.

Response

json
[
  {
    "id": 3,
    "segment_id": 7,
    "segment_name": "High LTV Buyers",
    "connector_type": "klaviyo",
    "status": "active",
    "last_synced_at": "2026-05-02T14:32:00Z",
    "last_error": "",
    "member_count": 3482,
    "success_rate": 95,
    "sync_logs": [
      {
        "status": "success",
        "user_count": 3482,
        "error_message": "",
        "synced_at": "2026-05-02T14:32:00Z"
      }
    ]
  }
]

success_rate is computed over the last 30 ActivationSyncLog records. null if no logs exist.
sync_logs contains the 5 most recent records.


Copilot Analytics#

http
GET /api/analytics/copilot/
Authorization: Bearer <token>

Response

json
{
  "total": 142,
  "daily": [
    { "day": "2026-04-03", "success": 8, "error": 1 },
    { "day": "2026-04-04", "success": 11, "error": 0 }
  ]
}

daily covers the last 30 days. Days with zero activity are omitted.


Usage#

http
GET /api/analytics/usage/
Authorization: Bearer <token>

Current billing period usage vs plan limits.

Response

json
{
  "plan_name": "Starter",
  "plan_tier": "starter",
  "period_start": "2026-05-01",
  "period_end": "2026-05-31",
  "events": { "used": 48200, "limit": 100000 },
  "users": { "used": 12400, "limit": 20000 },
  "segments": { "used": 8, "limit": 10 },
  "ai_credits": { "used": 34, "limit": 100 }
}

limit: -1 means unlimited. Returns 404 if no subscription is found.