Skip to main content
POST
/
v1
/
lexi
/
tasks
/
:id
/
approve
Approve Lexi Task
curl --request POST \
  --url https://api.example.com/v1/lexi/tasks/:id/approve
{
  "data": {
    "task_id": "<string>",
    "status": "<string>",
    "execution_started": true
  }
}

Request

Path Parameters

id
string
required
Task UUID

Headers

Authorization: Bearer wbk_your_api_key_here
Content-Type: application/json

Response

data
object
curl -X POST \
  https://nbkxaqxwvkgbddekwsma.supabase.co/functions/v1/api-gateway/v1/lexi/tasks/task-uuid/approve \
  -H "Authorization: Bearer wbk_your_api_key_here" \
  -H "Content-Type: application/json"

Example Response

{
  "data": {
    "task_id": "task-uuid",
    "status": "approved",
    "execution_started": true
  }
}

Complete Workflow Example

Step 1: Chat with Lexi

# Ask Lexi to search for prospects
chat_response = requests.post(
    f"{BASE_URL}/v1/lexi/chat",
    headers=headers,
    json={
        "message": "Find 50 CEOs at law firms in California"
    }
)

result = chat_response.json()["data"]
if result["requires_approval"]:
    task_id = result["task_id"]
    print(f"Task created: {task_id}")

Step 2: Review the Task

# Get task details
tasks_response = requests.get(
    f"{BASE_URL}/v1/lexi/tasks",
    headers=headers,
    params={"status": "pending"}
)

tasks = tasks_response.json()["data"]["tasks"]
for task in tasks:
    if task["id"] == task_id:
        print(f"Task: {task['description']}")
        print(f"Query: {task['metadata']['query']}")

Step 3: Approve the Task

# Approve the task
approve_response = requests.post(
    f"{BASE_URL}/v1/lexi/tasks/{task_id}/approve",
    headers=headers
)

print("Task approved! Lexi is executing it now.")

Step 4: Check Completion

import time

# Poll for completion
while True:
    status_response = requests.get(
        f"{BASE_URL}/v1/lexi/tasks",
        headers=headers,
        params={"status": "completed"}
    )
    
    completed = status_response.json()["data"]["tasks"]
    if any(t["id"] == task_id for t in completed):
        print("Task completed!")
        break
    
    time.sleep(5)

Auto-Approval Pattern

For trusted automation, you can auto-approve tasks without manual review:
def auto_approve_lexi_tasks():
    """Automatically approve all pending Lexi tasks"""
    response = requests.get(
        f"{BASE_URL}/v1/lexi/tasks",
        headers=headers,
        params={"status": "pending"}
    )
    
    tasks = response.json()["data"]["tasks"]
    
    for task in tasks:
        # Optional: add conditions to filter which tasks to auto-approve
        if task["type"] == "prospect_search":
            requests.post(
                f"{BASE_URL}/v1/lexi/tasks/{task['id']}/approve",
                headers=headers
            )
            print(f"Auto-approved: {task['description']}")

Errors

StatusCodeDescription
400validation_errorTask is not in pending status
401invalid_keyInvalid API key
403insufficient_permissionsMissing lexi permission
404not_foundTask not found
429rate_limitedRate limit exceeded

Example Error (Already Approved)

{
  "error": {
    "code": "validation_error",
    "message": "Task has already been approved"
  }
}