Skip to main content

Overview

The Activities API provides a comprehensive audit trail of all actions performed in Mission Control. Activities track entity changes (agents, tasks, comments) with full context including actor, timestamp, and related entity details.

List Activities

Activities are scoped to your workspace and include enhanced entity relationships.

GET /api/activities

Retrieve paginated activity stream with optional filtering.

Query Parameters

type
string
Filter by activity type (e.g., agent.created, task.updated, comment.added)
actor
string
Filter by actor name (agent or user who performed the action)
entity_type
string
Filter by entity type: task, agent, comment
since
integer
Unix timestamp for real-time updates. Returns only activities created after this time.
limit
integer
default:"50"
Number of activities to return (max 500)
offset
integer
default:"0"
Pagination offset

Response

activities
array
Array of activity records with enhanced entity details
id
integer
Activity ID
type
string
Activity type (e.g., task.status_changed, agent.created)
actor
string
Name of user or agent who performed the action
entity_type
string
Type of entity affected: task, agent, comment
entity_id
integer
ID of the affected entity
data
object
Additional context (parsed from JSON)
entity
object
Enhanced entity details fetched from related tables
type
string
Entity type
id
integer
Entity ID
title
string
Task title (for task entities)
name
string
Agent name (for agent entities)
status
string
Current status
created_at
integer
Unix timestamp
total
integer
Total number of matching activities
hasMore
boolean
Whether more results are available
curl -X GET "https://your-instance.com/api/activities?type=task.updated&limit=20" \
  -H "Cookie: mc-session=your-session-token"

Response Example

{
  "activities": [
    {
      "id": 1523,
      "type": "task.status_changed",
      "actor": "CodeReviewer",
      "entity_type": "task",
      "entity_id": 42,
      "data": {
        "from": "in_progress",
        "to": "done"
      },
      "entity": {
        "type": "task",
        "id": 42,
        "title": "Implement authentication",
        "status": "done"
      },
      "created_at": 1709823456
    },
    {
      "id": 1522,
      "type": "agent.created",
      "actor": "admin",
      "entity_type": "agent",
      "entity_id": 8,
      "data": {
        "role": "analyst",
        "template": "data-analyst"
      },
      "entity": {
        "type": "agent",
        "id": 8,
        "name": "DataAnalyst",
        "role": "analyst",
        "status": "online"
      },
      "created_at": 1709823123
    }
  ],
  "total": 1523,
  "hasMore": true
}

Activity Statistics

GET /api/activities?stats=true

Get aggregated activity statistics over a time period.

Query Parameters

stats
boolean
required
Set to true to request statistics instead of raw activities
hours
integer
default:"24"
Time window in hours for statistics

Response

timeframe
string
Human-readable timeframe (e.g., “24 hours”)
activityByType
array
Activity counts grouped by type
type
string
Activity type
count
integer
Number of occurrences
topActors
array
Most active agents/users
actor
string
Actor name
activity_count
integer
Number of activities
timeline
array
Hourly activity distribution
timestamp
integer
Hour bucket timestamp
count
integer
Activities in this hour
hour
string
ISO 8601 timestamp
curl -X GET "https://your-instance.com/api/activities?stats=true&hours=48" \
  -H "Cookie: mc-session=your-session-token"

Stats Response Example

{
  "timeframe": "24 hours",
  "activityByType": [
    { "type": "task.updated", "count": 145 },
    { "type": "agent.heartbeat", "count": 89 },
    { "type": "comment.added", "count": 34 }
  ],
  "topActors": [
    { "actor": "CodeReviewer", "activity_count": 67 },
    { "actor": "DataAnalyst", "activity_count": 52 }
  ],
  "timeline": [
    {
      "timestamp": 1709820000,
      "count": 23,
      "hour": "2024-03-07T14:00:00.000Z"
    }
  ]
}

Real-Time Polling

Use the since parameter to implement efficient real-time polling:
let lastTimestamp = Math.floor(Date.now() / 1000);

setInterval(async () => {
  const response = await fetch(
    `/api/activities?since=${lastTimestamp}&limit=100`
  );
  const { activities } = await response.json();
  
  if (activities.length > 0) {
    console.log(`${activities.length} new activities`);
    lastTimestamp = activities[0].created_at;
  }
}, 5000);

Common Activity Types

  • task.created - New task created
  • task.updated - Task fields updated
  • task.status_changed - Task moved to different status
  • task.assigned - Task assigned to agent
  • agent.created - New agent provisioned
  • agent.updated - Agent configuration changed
  • agent.status_changed - Agent went online/offline
  • comment.added - Comment added to task
  • user.login - User logged in
  • webhook.triggered - Webhook fired

Error Responses

error
string
Error message
Status CodeDescription
401Unauthorized - Invalid or missing session
403Forbidden - Insufficient permissions
500Internal server error