curl --request POST \
--url https://api.example.com/v1/lexi/tasks/:id/approve{
"data": {
"task_id": "<string>",
"status": "<string>",
"execution_started": true
}
}Approve a pending task for Lexi to execute
curl --request POST \
--url https://api.example.com/v1/lexi/tasks/:id/approve{
"data": {
"task_id": "<string>",
"status": "<string>",
"execution_started": true
}
}Authorization: Bearer wbk_your_api_key_here
Content-Type: application/json
curl -X POST \
https://data.leadlex.com/functions/v1/api-gateway/v1/lexi/tasks/task-uuid/approve \
-H "Authorization: Bearer wbk_your_api_key_here" \
-H "Content-Type: application/json"
{
"data": {
"task_id": "task-uuid",
"status": "approved",
"execution_started": true
}
}
# 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}")
# 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']}")
# 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.")
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)
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']}")
| Status | Code | Description |
|---|---|---|
| 400 | validation_error | Task is not in pending status |
| 401 | invalid_key | Invalid API key |
| 403 | insufficient_permissions | Missing lexi permission |
| 404 | not_found | Task not found |
| 429 | rate_limited | Rate limit exceeded |
{
"error": {
"code": "validation_error",
"message": "Task has already been approved"
}
}