> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.alfa.boosted.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.alfa.boosted.ai/_mcp/server.

# Edit and manage workplans

Once you've created workplans, you may need to modify your workplans to improve or add new requirements to the analysis. This guide explains how to edit and manage your existing workplans.

## Editing a workplan

You can modify an existing workplan using a text prompt that describes the changes you want to make. Note that modifying an existing workplan completely replaces the execution plan.

```python
import requests

BASE_URL = "https://alfa.boosted.ai/client"
API_KEY = "YOUR_API_KEY_HERE"

headers = {"x-api-key": API_KEY, "Content-Type": "application/json"}

def edit_workplan(workplan_id, prompt, args=None):
    """Edit an existing workplan with a new prompt."""
    url = f"{BASE_URL}/v2/workplans/{workplan_id}/edit"
    payload = {"prompt": prompt}
    
    response = requests.patch(url, headers=headers, json=payload)
    
    if response.status_code == 200:
        data = response.json()
        success = data.get("success", False)
        new_status = data.get("status")
        
        if success:
            print(f"Workplan {workplan_id} updated successfully")
            print(f"New status: {new_status}")
        else:
            print("Workplan update failed")
        
        return success
    else:
        print(f"Error: {response.status_code}, {response.text}")
        return False

# Edit a workplan with a refined prompt
workplan_id = "your-workplan-id"
new_prompt = "Analyze Apple's stock performance over the last 3 months, include earnings data, and show both price trends and volume analysis"
success = edit_workplan(workplan_id, new_prompt)
```

### Editing with document references

You can also update workplans to reference new or different documents.

```python
def edit_workplan_with_documents(workplan_id, prompt, document_ids):
    """Edit a workplan to reference specific documents."""
    args = {}
    
    for i, doc_id in enumerate(document_ids):
        args[f"doc{i+1}"] = {
            "id": doc_id,
            "type": "custom_document"
        }
    
    # Create a prompt that references the documents
    document_prompt = prompt
    for i in range(len(document_ids)):
        document_prompt = document_prompt.replace(f"{{doc{i+1}}}", f"{{doc{i+1}}}")
    
    return edit_workplan(workplan_id, document_prompt, args)

# Edit workplan to use new quarterly reports
new_docs = ["file_id_1", "file_id_2", "file_id_3"]
new_prompt = "Analyze the quarterly reports in {doc1}, {doc2}, and {doc3}. Compare performance across quarters and identify trends."
success = edit_workplan_with_documents(workplan_id, new_prompt, new_docs)
```

## Monitoring workplan

Get comprehensive information about a workplan, including its current status and exucution plan.

```python
def get_workplan_details(workplan_id):
    """Get detailed information about a workplan."""
    url = f"{BASE_URL}/v2/workplans/{workplan_id}/view"
    
    response = requests.get(url, headers=headers)
    
    if response.status_code == 200:
        data = response.json()
        
        print(f"Workplan ID: {data.get('workplan_id')}")
        print(f"Plan Status: {data.get('plan_status')}")
        
        execution_plan = data.get("execution_plan")
        if execution_plan:
            nodes = execution_plan.get("nodes", [])
            print(f"Execution Plan: {len(nodes)} nodes")
            
            for i, node in enumerate(nodes):
                tool_name = node.get("tool_name", "Unknown")
                description = node.get("description", "No description")
                print(f"  Node {i+1}: {tool_name} - {description}")
        
        return data
    else:
        print(f"Error: {response.status_code}, {response.text}")
        return None

# Get workplan details
workplan_info = get_workplan_details(workplan_id)
```

### Listing all workplans

View all your workplans to see which ones need updates or maintenance. Workplans are listed by creation date.

```python
def list_all_workplans():
    """List all workplans with their current status."""
    url = f"{BASE_URL}/v2/workplans"
    
    response = requests.get(url, headers=headers)
    
    if response.status_code == 200:
        data = response.json()
        workplans = data.get("workplans", [])
        
        print(f"Total workplans: {len(workplans)}")
        
        for workplan in workplans:
            print(f"\nWorkplan {workplan["workplan_id"]}:")
            print(f"  Name: {workplan.get("workplan_name", "Unnamed")}")
            print(f"  Description: {workplan.get("workplan_description", "No description")}")
            print(f"  Status: {workplan.get("workplan_status", "Unknown")}")
            print(f"  Created: {created_at = workplan.get("created_at", "Unknown")}")
        
        return workplans
    else:
        print(f"Error: {response.status_code}, {response.text}")
        return None

# List all workplans
all_workplans = list_all_workplans()
```

### Deleting workplans

If you no longer need a workplan, you can delete it permanently.

```python
def delete_workplan(workplan_id):
    """Permanently delete a workplan."""
    url = f"{BASE_URL}/v2/workplans/{workplan_id}/delete"
    
    response = requests.delete(url, headers=headers)
    
    if response.status_code == 200:
        data = response.json()
        success = data.get("success", False)
        
        if success:
            print(f"Workplan {workplan_id} deleted successfully")
        else:
            print("Workplan deletion failed")
        
        return success
    else:
        print(f"Error: {response.status_code}, {response.text}")
        return False

# Delete a workplan (use with caution!)
delete_workplan(workplan_id)
```

> **Warning**
>
> **Deleting a workplan is permanent and cannot be undone.**

### Example: Finding workplans by pattern matching

#### Get all workplans

First, retrieve the list of all your workplans

#### Filter by criteria

Search for workplans that match certain patterns:

```python
# Get all available workplans
all_workplans = list_all_workplans()

# Filter workplans by name pattern
earnings_workplans, recent_workplans = [], []
if all_workplans:
    earnings_workplans = [a for a in all_workplans if "earnings" in a["workplan_name"].lower()]
    recent_workplans = [a for a in all_workplans if a["created_at"] > "2025-06-30"]

# Display filtered results
print(f"\nFound {len(earnings_workplans)} earnings-related workplans:")
for workplan in earnings_workplans:
    print(f"- {workplan['workplan_name']} (ID: {workplan['workplan_id']})")

print(f"\nFound {len(recent_workplans)} workplans created since July 2025:")
for workplan in recent_workplans:
    print(f"- {workplan['workplan_name']} (created: {workplan['created_at']})")
```

## Next steps

Now that you understand how to edit and manage workplans, you can:

* Learn how to [create and manage reports](/guides/build-with-alfa/workplans/create-and-manage-reports) to build reports with Alfa
* Learn how to [schedule and automate workplans](/guides/build-with-alfa/scheduling-workplans/schedule-and-automate-workplans) to run on a custom schedule
* Learn how to [monitor token usage](/guides/build-with-alfa/workplans/track-token-usage) efficiently build reports
* Explore using [documents](/guides/build-with-alfa/knowledge-base/documents) with your workplans

> **Tip**
>
> Workplan editing is a powerful feature that allows you to continuously improve your analysis capabilities. Regular updates can lead to better results and more efficient token usage.