PUT
/
v1
/
loops
/
{id}
curl -X PUT https://api.hitl.sh/v1/loops/65f1234567890abcdef12345 \
  -H "Authorization: Bearer your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Enhanced Content Moderation",
    "description": "Advanced review system for user-generated content with improved guidelines",
    "icon": "shield-exclamation"
  }'
{
  "error": false,
  "msg": "Loop updated successfully",
  "data": {
    "loop": {
      "id": "65f1234567890abcdef12345",
      "name": "Enhanced Content Moderation",
      "description": "Advanced review system for user-generated content with improved guidelines",
      "icon": "shield-exclamation",
      "creator_id": "65f1234567890abcdef12346",
      "members": [
        {
          "user_id": "65f1234567890abcdef12346",
          "email": "creator@example.com",
          "status": "active",
          "joined_at": "2024-03-15T10:30:00Z"
        },
        {
          "user_id": "65f1234567890abcdef12347",
          "email": "reviewer1@example.com",
          "status": "active", 
          "joined_at": "2024-03-15T11:45:00Z"
        }
      ],
      "member_count": 2,
      "pending_count": 0,
      "created_at": "2024-03-15T10:30:00Z",
      "updated_at": "2024-03-15T14:20:00Z"
    }
  }
}
Update the details of an existing loop. You can modify the name, description, and icon of any loop you’ve created. This operation preserves all members and existing requests.

Authentication

Authorization
string
required
Your API key for authentication

Path Parameters

id
string
required
The unique identifier of the loop to update

Body Parameters

name
string
New name for the loop (1-100 characters)
description
string
New description of the loop’s purpose (max 500 characters)
icon
string
New icon identifier for the loop
All body parameters are optional. Only provide the fields you want to update.

Response

error
boolean
Whether an error occurred
msg
string
Success message
data
object
curl -X PUT https://api.hitl.sh/v1/loops/65f1234567890abcdef12345 \
  -H "Authorization: Bearer your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Enhanced Content Moderation",
    "description": "Advanced review system for user-generated content with improved guidelines",
    "icon": "shield-exclamation"
  }'
{
  "error": false,
  "msg": "Loop updated successfully",
  "data": {
    "loop": {
      "id": "65f1234567890abcdef12345",
      "name": "Enhanced Content Moderation",
      "description": "Advanced review system for user-generated content with improved guidelines",
      "icon": "shield-exclamation",
      "creator_id": "65f1234567890abcdef12346",
      "members": [
        {
          "user_id": "65f1234567890abcdef12346",
          "email": "creator@example.com",
          "status": "active",
          "joined_at": "2024-03-15T10:30:00Z"
        },
        {
          "user_id": "65f1234567890abcdef12347",
          "email": "reviewer1@example.com",
          "status": "active", 
          "joined_at": "2024-03-15T11:45:00Z"
        }
      ],
      "member_count": 2,
      "pending_count": 0,
      "created_at": "2024-03-15T10:30:00Z",
      "updated_at": "2024-03-15T14:20:00Z"
    }
  }
}

Update Scenarios

Name Only Update

Update just the loop name:
{
  "name": "Content Review V2"
}

Description Only Update

Update just the description:
{
  "description": "Updated workflow for reviewing user submissions with new compliance requirements"
}

Icon Only Update

Update just the icon:
{
  "icon": "shield-alt"
}

Partial Update

Update multiple fields (but not all):
{
  "name": "Premium Content Review",
  "icon": "star"
}

Available Icons

Security

shield-check, shield-alt, shield-exclamation, lock, key

Content

document-text, document-check, file-text, clipboard, edit

Review

eye, search, thumbs-up, thumbs-down, star

Quality

badge-check, certificate, award, beaker, cog

Communication

chat, comment, bell, megaphone, mail

General

folder, tag, flag, bookmark, heart

Validation Rules

Name Validation

  • Required: No (optional for updates)
  • Min length: 1 character
  • Max length: 100 characters
  • Allowed: Letters, numbers, spaces, and basic punctuation

Description Validation

  • Required: No (optional for updates)
  • Max length: 500 characters
  • Allowed: All characters including newlines

Icon Validation

  • Required: No (optional for updates)
  • Format: String identifier
  • Validation: Must be a valid icon identifier from available icons

Use Cases

Rebranding Loops

Update loop name and icon for rebranding:
def rebrand_loop(loop_id, new_name, new_icon):
    url = f"https://api.hitl.sh/v1/loops/{loop_id}"
    data = {
        "name": new_name,
        "icon": new_icon
    }
    
    response = requests.put(url, headers=headers, json=data)
    
    if response.status_code == 200:
        loop_data = response.json()["data"]["loop"]
        print(f"Successfully rebranded loop to '{loop_data['name']}'")
        return loop_data
    else:
        print(f"Failed to rebrand loop: {response.json()['msg']}")
        return None

Improving Descriptions

Add more detailed descriptions to existing loops:
async function improveLoopDescription(loopId, newDescription) {
    try {
        const response = await axios.put(
            `https://api.hitl.sh/v1/loops/${loopId}`,
            { description: newDescription },
            { headers: { 'Authorization': `Bearer ${apiKey, 'Content-Type': 'application/json'}` } }
        );
        
        console.log('Description updated successfully');
        return response.data.data.loop;
    } catch (error) {
        console.error('Failed to update description:', error.response?.data?.msg);
        throw error;
    }
}

// Usage
await improveLoopDescription(
    'loopId',
    'Comprehensive content moderation with AI pre-filtering and human oversight for policy violations'
);

Bulk Loop Updates

Update multiple loops with a consistent naming scheme:
def standardize_loop_names(loop_prefix="Review"):
    # Get all loops
    loops_response = requests.get("https://api.hitl.sh/v1/loops", headers=headers)
    loops = loops_response.json()["data"]["loops"]
    
    updated_loops = []
    for loop in loops:
        # Skip loops that already follow the naming convention
        if loop["name"].startswith(loop_prefix):
            continue
            
        new_name = f"{loop_prefix} - {loop['name']}"
        
        update_response = requests.put(
            f"https://api.hitl.sh/v1/loops/{loop['id']}", 
            headers=headers, 
            json={"name": new_name}
        )
        
        if update_response.status_code == 200:
            updated_loops.append(update_response.json()["data"]["loop"])
    
    return updated_loops

Access Control

Who Can Update Loops

Error Handling

Common Error Scenarios

Best Practices

Versioning Updates

Track major changes with version numbers in names:
def version_loop_update(loop_id, updates, version=None):
    if version:
        if 'name' in updates:
            updates['name'] = f"{updates['name']} v{version}"
        updates['description'] = f"{updates.get('description', '')} (Updated to v{version})"
    
    return requests.put(f"https://api.hitl.sh/v1/loops/{loop_id}", headers=headers, json=updates)

Gradual Updates

Update loops incrementally rather than all at once:
async function updateLoopGradually(loopId, updates) {
    const updateOrder = ['description', 'icon', 'name']; // Update description first, name last
    
    for (const field of updateOrder) {
        if (updates[field]) {
            await axios.put(
                `https://api.hitl.sh/v1/loops/${loopId}`,
                { [field]: updates[field] },
                { headers: { 'Authorization': `Bearer ${apiKey}` } }
            );
            
            // Small delay between updates
            await new Promise(resolve => setTimeout(resolve, 100));
        }
    }
}

Backup Before Updates

Keep a record of previous state:
def safe_loop_update(loop_id, updates):
    # Get current state
    current_response = requests.get(f"https://api.hitl.sh/v1/loops/{loop_id}", headers=headers)
    backup = current_response.json()["data"]["loop"]
    
    # Perform update
    update_response = requests.put(
        f"https://api.hitl.sh/v1/loops/{loop_id}", 
        headers=headers, 
        json=updates
    )
    
    if update_response.status_code == 200:
        return {
            "success": True,
            "updated": update_response.json()["data"]["loop"],
            "backup": backup
        }
    else:
        return {
            "success": False,
            "error": update_response.json()["msg"],
            "backup": backup
        }

Next Steps

Delete Loop

Learn how to delete loops when they’re no longer needed.

Manage Members

Add or remove members from your updated loop.

View Loop Requests

See all requests that have been created within this loop.