Skip to main content

Endpoint

DELETE /api/interview/sessions/{sessionId}
Permanently deletes an interview session and all associated data including questions, answers, evaluation results, and generated reports. This operation is irreversible.
This action is permanent and cannot be undone. Make sure to export any reports or data you need before deleting the session.

Path Parameters

sessionId
string
required
The unique session identifier for the interview session to delete.

Response

code
integer
Response status code. 200 indicates successful deletion.
message
string
Response message. Returns "success" on successful deletion.
data
null
Always null for delete operations.

Example Request

curl -X DELETE https://api.example.com/api/interview/sessions/a1b2c3d4-e5f6-4789-g0h1-i2j3k4l5m6n7

Example Response

{
  "code": 200,
  "message": "success",
  "data": null
}

What Gets Deleted

Deleting a session removes all associated data:
1

Session Metadata

Session ID, creation timestamp, status, and configuration (question count, resume ID reference).
2

All Questions

Original questions, follow-up questions, question types, and categories.
3

All Answers

User’s submitted answers for each question.
4

Evaluation Data

Scores, feedback, category breakdowns, strengths, and improvement suggestions.
5

Generated Reports

Any generated evaluation reports and their cached data.
The associated resume is NOT deleted. Only the interview session data is removed. The resume remains in the system and can be used for future interviews.

Use Cases

Cleanup

Remove old or test interview sessions to keep the database clean.

Privacy

Delete sensitive interview data when no longer needed for privacy compliance.

Retry

Delete a session to start fresh with a new interview for the same resume.

Storage Management

Remove sessions to free up storage space in the system.

Error Responses

code
integer
Error code. Non-200 values indicate an error.
message
string
Error message describing what went wrong.
data
null
Always null for error responses.

Common Errors

CodeMessageDescription
404Session not foundInvalid session ID or session already deleted
500Server errorDatabase error or internal server error
A 404 error on delete is idempotent - if the session doesn’t exist, the desired state (deleted) is already achieved. You can safely treat 404 as a successful delete in your client code.

Export Report

Export report as PDF before deleting

Get Session

Verify session exists before deleting

Create Session

Create a new interview session

Get Report

View report one last time before deletion

Best Practices

Always offer users the option to export their report before deleting:
async function deleteSessionSafely(sessionId) {
  // Confirm with user
  const confirmed = await showConfirmDialog({
    title: 'Delete Interview Session?',
    message: 'This action cannot be undone. Would you like to export the report first?',
    buttons: ['Export & Delete', 'Delete Only', 'Cancel']
  });
  
  if (confirmed === 'Cancel') return;
  
  if (confirmed === 'Export & Delete') {
    await exportReport(sessionId);
  }
  
  // Proceed with deletion
  await fetch(`/api/interview/sessions/${sessionId}`, {
    method: 'DELETE'
  });
  
  showSuccess('Session deleted successfully');
}
Always require explicit confirmation before deletion:
function ConfirmDeleteDialog({ sessionId, onConfirm, onCancel }) {
  return (
    <Dialog>
      <DialogTitle>Delete Interview Session?</DialogTitle>
      <DialogContent>
        <Alert severity="warning">
          This will permanently delete:
          <ul>
            <li>All interview questions and answers</li>
            <li>Evaluation scores and feedback</li>
            <li>Generated reports</li>
          </ul>
          This action cannot be undone.
        </Alert>
      </DialogContent>
      <DialogActions>
        <Button onClick={onCancel}>Cancel</Button>
        <Button onClick={onConfirm} color="error">
          Delete Permanently
        </Button>
      </DialogActions>
    </Dialog>
  );
}
When deleting multiple sessions, handle failures gracefully:
async function bulkDeleteSessions(sessionIds) {
  const results = await Promise.allSettled(
    sessionIds.map(id => 
      fetch(`/api/interview/sessions/${id}`, { method: 'DELETE' })
    )
  );
  
  const succeeded = results.filter(r => r.status === 'fulfilled').length;
  const failed = results.filter(r => r.status === 'rejected').length;
  
  showMessage(`Deleted ${succeeded} sessions. ${failed} failed.`);
  
  return { succeeded, failed };
}
Consider implementing a soft delete with recovery period:
// Mark as deleted but keep data for 30 days
async function softDeleteSession(sessionId) {
  await fetch(`/api/interview/sessions/${sessionId}`, {
    method: 'PATCH',
    body: JSON.stringify({ 
      status: 'DELETED',
      deletedAt: new Date().toISOString(),
      permanentDeleteAt: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000)
    })
  });
}

// Later: actual deletion via cron job
async function permanentlyDeleteExpired() {
  const expired = await getExpiredSessions();
  await bulkDeleteSessions(expired.map(s => s.sessionId));
}
Ensure UI reflects the deletion immediately:
async function handleDelete(sessionId) {
  try {
    // Optimistic UI update
    removeSessionFromList(sessionId);
    
    await fetch(`/api/interview/sessions/${sessionId}`, {
      method: 'DELETE'
    });
    
    showSuccess('Session deleted successfully');
  } catch (error) {
    // Rollback UI change
    restoreSessionToList(sessionId);
    showError('Failed to delete session');
  }
}
Treat 404 as successful deletion (idempotent):
async function deleteSession(sessionId) {
  const response = await fetch(
    `/api/interview/sessions/${sessionId}`,
    { method: 'DELETE' }
  );
  
  // 200 = deleted, 404 = already deleted
  if (response.ok || response.status === 404) {
    return { success: true };
  }
  
  throw new Error('Delete failed');
}

Complete Delete Flow

1

User Initiates Delete

User clicks delete button for a specific interview session.
2

Show Confirmation

Display a confirmation dialog explaining what will be deleted and that the action is irreversible.
3

Offer Export Option

Provide a button to export the report before deletion, especially if the report hasn’t been exported yet.
4

User Confirms

User explicitly confirms the deletion action.
5

Call Delete API

Send DELETE request to the endpoint with the session ID.
6

Update UI

Remove the session from the UI list and show success message.
7

Handle Errors

If deletion fails, show error message and allow retry. Treat 404 as success.

Implementation Example

Complete React component for session deletion:
import { useState } from 'react';
import { 
  Button, 
  Dialog, 
  DialogTitle, 
  DialogContent, 
  DialogActions,
  Alert 
} from '@/components/ui';

function DeleteSessionButton({ sessionId, sessionName, onDeleted }) {
  const [showDialog, setShowDialog] = useState(false);
  const [loading, setLoading] = useState(false);
  const [error, setError] = useState(null);
  
  const handleDelete = async () => {
    setLoading(true);
    setError(null);
    
    try {
      const response = await fetch(
        `/api/interview/sessions/${sessionId}`,
        { method: 'DELETE' }
      );
      
      const data = await response.json();
      
      // Handle success or 404 (idempotent)
      if (response.ok || response.status === 404) {
        setShowDialog(false);
        onDeleted?.(sessionId);
        return;
      }
      
      throw new Error(data.message || 'Delete failed');
      
    } catch (err) {
      setError(err.message);
    } finally {
      setLoading(false);
    }
  };
  
  const handleExportAndDelete = async () => {
    try {
      // Export first
      await downloadReport(sessionId);
      // Then delete
      await handleDelete();
    } catch (err) {
      setError('Export failed. Session not deleted.');
    }
  };
  
  return (
    <>
      <Button 
        onClick={() => setShowDialog(true)}
        variant="outlined"
        color="error"
      >
        Delete Session
      </Button>
      
      <Dialog open={showDialog} onClose={() => setShowDialog(false)}>
        <DialogTitle>Delete Interview Session?</DialogTitle>
        
        <DialogContent>
          <Alert severity="warning" className="mb-4">
            <strong>This action cannot be undone.</strong>
            <br />
            The following will be permanently deleted:
            <ul className="mt-2 ml-4">
              <li>All interview questions and answers</li>
              <li>Evaluation scores and feedback</li>
              <li>Generated reports and analysis</li>
            </ul>
          </Alert>
          
          {sessionName && (
            <p className="text-sm text-gray-600">
              Session: <strong>{sessionName}</strong>
            </p>
          )}
          
          {error && (
            <Alert severity="error" className="mt-2">
              {error}
            </Alert>
          )}
        </DialogContent>
        
        <DialogActions>
          <Button 
            onClick={() => setShowDialog(false)}
            disabled={loading}
          >
            Cancel
          </Button>
          
          <Button 
            onClick={handleExportAndDelete}
            disabled={loading}
            variant="outlined"
          >
            Export & Delete
          </Button>
          
          <Button 
            onClick={handleDelete}
            disabled={loading}
            color="error"
          >
            {loading ? 'Deleting...' : 'Delete Only'}
          </Button>
        </DialogActions>
      </Dialog>
    </>
  );
}

export default DeleteSessionButton;

Data Retention Policy

Consider implementing an automated data retention policy:
// Example: Auto-delete sessions older than 90 days
const RETENTION_DAYS = 90;

async function cleanupOldSessions() {
  const cutoffDate = new Date();
  cutoffDate.setDate(cutoffDate.getDate() - RETENTION_DAYS);
  
  const oldSessions = await fetchSessions({
    createdBefore: cutoffDate,
    status: ['COMPLETED', 'EVALUATED']
  });
  
  // Notify users before deletion
  await notifyUsersOfPendingDeletion(oldSessions);
  
  // Delete after grace period
  setTimeout(async () => {
    await bulkDeleteSessions(oldSessions.map(s => s.sessionId));
    console.log(`Deleted ${oldSessions.length} old sessions`);
  }, 7 * 24 * 60 * 60 * 1000); // 7 days grace period
}
Consider implementing a data retention policy that automatically deletes old sessions after a certain period (e.g., 90 days) to comply with privacy regulations and manage storage costs.

Interview Session Lifecycle

Sessions can be deleted at any stage of the lifecycle, not just after completion. However, it’s best practice to complete and export reports before deletion to preserve valuable interview data.

Build docs developers (and LLMs) love