0 people focusing right now

POST /api/session/cancel

Cancel an active session and track partial completion

Cancel an active session and track partial completion for POF algorithm with Slack notifications.

Point-of-No-Return: Once this API is called, the session is 100% cancelled immediately. Optional details can be added afterward.
Endpoint URL
POST https://game.regardingwork.com/api/session/cancel
Authentication
JWT Bearer token required

📤 Request

Headers
Content-Type: application/json
Authorization: Bearer <your_jwt_token>
Request Body
{
  "session_id": "39440f6c-26cb-434d-a024-14caef17f3e0",  // Required: UUID of session being cancelled
  "planned_duration": 25,                               // Required: Original planned duration in minutes
  "elapsed_minutes": 8.5,                              // Required: Actual time completed before cancellation
  "reason": "interruption",                            // Optional: Cancellation category (see below)
  "cancel_reason_note": "Emergency call from client",  // Optional: Detailed user explanation
  "category": "Programming",                           // Optional: Work category from original session
  "project_id": 47,                                   // Optional: Personal project ID
  "team_project_id": 12,                              // Optional: Team project ID (use one or the other)
  "source": "mac_app"                                 // Required: Source app identifier
}
Cancellation Reason Types
  • user_cancelled - User chose to stop session
  • interruption - External interruption (calls, meetings, etc.)
  • emergency - Unexpected urgent situation
  • technical - Technical issue with app/system
  • distraction - Lost focus or got distracted
  • completed_early - Finished work before timer ended
  • other - Other reason (use cancel_reason_note for details)

🎯 Partial POF Scoring

  • Base Score: 50% of regular POF score for cancelled sessions
  • Completion Multiplier: Based on elapsed_minutes / planned_duration
  • Source Reliability: Same multipliers as regular sessions
  • Maximum Cap: 50 points (50% of regular maximum)

✅ Response (201 Created)

{
  "success": true,
  "cancellation_id": "147",
  "message": "Session cancelled and recorded successfully",
  "cancellation": {
    "id": 147,
    "session_id": "39440f6c-26cb-434d-a024-14caef17f3e0",
    "planned_duration": 25,
    "actual_duration": 8,
    "completion_percentage": 32.0,
    "partial_pof_score": 16,
    "reason": "interruption",
    "cancel_reason_note": "Emergency call from client",
    "source": "mac_app",
    "cancelled_at": "2025-08-24T15:30:45Z"
  },
  "notifications": {
    "slack_sent": true,
    "channels_notified": ["#marketing-team", "#website-redesign"]
  }
}

❌ Error Responses

400 Bad Request
{
  "error": "Missing required fields: session_id, planned_duration, elapsed_minutes"
}
404 Not Found
{
  "error": "Session not found or not owned by user"
}

💻 Code Examples

JavaScript (Fetch)
const token = localStorage.getItem('jwt_token');

const response = await fetch('https://game.regardingwork.com/api/session/cancel', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${token}`
  },
  body: JSON.stringify({
    session_id: "39440f6c-26cb-434d-a024-14caef17f3e0",
    planned_duration: 25,
    elapsed_minutes: 8.5,
    reason: "interruption",
    cancel_reason_note: "Emergency call from client",
    source: "mac_app"
  })
});

const result = await response.json();
if (result.success) {
  console.log(`Session cancelled! Partial POF: ${result.cancellation.partial_pof_score}`);
}

🔗 Related Endpoints

Session Flow