DELETE
/
v1
/
loops
/
{id}
curl -X DELETE https://api.hitl.sh/v1/loops/65f1234567890abcdef12345 \
  -H "Authorization: Bearer your_api_key_here"
{
  "error": false,
  "msg": "Loop deleted successfully",
  "data": {
    "loop_id": "65f1234567890abcdef12345",
    "deleted_at": "2024-03-15T15:30:00Z",
    "deleted_data": {
      "members_removed": 5,
      "requests_deleted": 23,
      "responses_deleted": 18
    }
  }
}
Permanently delete a loop and all its associated data including members, requests, and history. This is a destructive operation that cannot be undone.
This action permanently deletes the loop and all associated data including:
  • All loop members and their membership history
  • All requests created within the loop
  • All responses and feedback from reviewers
  • All analytics and performance data
This operation cannot be undone.

Authentication

Authorization
string
required
Your API key for authentication

Path Parameters

id
string
required
The unique identifier of the loop to delete

Response

error
boolean
Whether an error occurred
msg
string
Success message confirming deletion
data
object
curl -X DELETE https://api.hitl.sh/v1/loops/65f1234567890abcdef12345 \
  -H "Authorization: Bearer your_api_key_here"
{
  "error": false,
  "msg": "Loop deleted successfully",
  "data": {
    "loop_id": "65f1234567890abcdef12345",
    "deleted_at": "2024-03-15T15:30:00Z",
    "deleted_data": {
      "members_removed": 5,
      "requests_deleted": 23,
      "responses_deleted": 18
    }
  }
}

Pre-Deletion Considerations

What Gets Deleted

When you delete a loop, the following data is permanently removed:

Data That Survives Deletion

Safety Checks

Before Deleting a Loop

Implement these safety checks in your code:
def safe_delete_loop(loop_id, require_confirmation=True):
    """Safely delete a loop with pre-flight checks"""
    
    # Get loop information first
    response = requests.get(f"https://api.hitl.sh/v1/loops/{loop_id}", headers=headers)
    if response.status_code != 200:
        return {"error": True, "msg": "Loop not found or inaccessible"}
    
    loop_data = response.json()["data"]["loop"]
    
    # Check for active members
    active_members = loop_data["member_count"] - loop_data["pending_count"]
    if active_members > 1:  # More than just the creator
        print(f"Warning: Loop has {active_members} active members")
    
    # Check for recent activity (optional: get requests)
    requests_response = requests.get(f"https://api.hitl.sh/v1/loops/{loop_id}/requests", headers=headers)
    if requests_response.status_code == 200:
        requests_data = requests_response.json()["data"]["requests"]
        recent_requests = [r for r in requests_data if r["status"] in ["pending", "claimed"]]
        
        if recent_requests:
            print(f"Warning: Loop has {len(recent_requests)} active requests")
    
    # Confirmation
    if require_confirmation:
        confirmation = input(f"Delete loop '{loop_data['name']}'? This cannot be undone. (yes/no): ")
        if confirmation.lower() != 'yes':
            return {"error": False, "msg": "Deletion cancelled by user"}
    
    # Proceed with deletion
    delete_response = requests.delete(f"https://api.hitl.sh/v1/loops/{loop_id}", headers=headers)
    return delete_response.json()

Bulk Operations

Delete Multiple Loops

Handle multiple loop deletions with error handling:
def bulk_delete_loops(loop_ids, dry_run=True):
    """Delete multiple loops with safety checks"""
    results = []
    
    for loop_id in loop_ids:
        try:
            if dry_run:
                # Just check if we can access the loop
                response = requests.get(f"https://api.hitl.sh/v1/loops/{loop_id}", headers=headers)
                if response.status_code == 200:
                    loop_data = response.json()["data"]["loop"]
                    results.append({
                        "loop_id": loop_id,
                        "name": loop_data["name"],
                        "members": loop_data["member_count"],
                        "status": "ready_to_delete" if dry_run else "deleted"
                    })
                else:
                    results.append({
                        "loop_id": loop_id,
                        "error": response.json()["msg"],
                        "status": "error"
                    })
            else:
                # Actually delete the loop
                response = requests.delete(f"https://api.hitl.sh/v1/loops/{loop_id}", headers=headers)
                if response.status_code == 200:
                    results.append({
                        "loop_id": loop_id,
                        "status": "deleted",
                        "deleted_at": response.json()["data"]["deleted_at"]
                    })
                else:
                    results.append({
                        "loop_id": loop_id,
                        "error": response.json()["msg"],
                        "status": "error"
                    })
        except Exception as e:
            results.append({
                "loop_id": loop_id,
                "error": str(e),
                "status": "exception"
            })
    
    return results

# Usage
loop_ids = ["65f1234567890abcdef12345", "65f1234567890abcdef12346"]

# Dry run first
print("Dry run results:")
dry_results = bulk_delete_loops(loop_ids, dry_run=True)
for result in dry_results:
    print(f"  {result}")

# Actual deletion (uncomment to execute)
# print("\nActual deletion:")
# actual_results = bulk_delete_loops(loop_ids, dry_run=False)

Access Control

Who Can Delete Loops

Error Handling

Common Error Scenarios

Alternatives to Deletion

Archive Instead of Delete

Consider these alternatives before permanent deletion:
def archive_loop(loop_id):
    """Archive a loop by updating its name instead of deleting"""
    
    # Get current loop data
    response = requests.get(f"https://api.hitl.sh/v1/loops/{loop_id}", headers=headers)
    loop_data = response.json()["data"]["loop"]
    
    # Update with archived naming
    archived_name = f"[ARCHIVED] {loop_data['name']}"
    archived_description = f"ARCHIVED on {datetime.now().strftime('%Y-%m-%d')} - {loop_data.get('description', '')}"
    
    update_response = requests.put(
        f"https://api.hitl.sh/v1/loops/{loop_id}",
        headers=headers,
        json={
            "name": archived_name,
            "description": archived_description
        }
    )
    
    return update_response.json()

Recovery Options

No Recovery Available

Once a loop is deleted, there is no way to recover the data. The deletion is immediate and permanent.

Prevention Strategies

  1. Export Data First: Before deletion, export important data
  2. Use Staging Loops: Test with non-production loops
  3. Archive Instead: Consider archiving rather than deleting
  4. Team Review: Have deletions reviewed by team members

Next Steps

Create New Loop

Create a new loop to replace the deleted one if needed.

Export Data

Learn how to export request and response data before deletion.

Loop Management

Return to loop management and view your remaining loops.