Approve Lexi Task
curl --request POST \
--url https://api.example.com/v1/lexi/tasks/:id/approveimport requests
url = "https://api.example.com/v1/lexi/tasks/:id/approve"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/v1/lexi/tasks/:id/approve', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v1/lexi/tasks/:id/approve",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/lexi/tasks/:id/approve"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/v1/lexi/tasks/:id/approve")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/lexi/tasks/:id/approve")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_body{
"data": {
"task_id": "<string>",
"status": "<string>",
"execution_started": true
}
}Lexi AI
Approve Lexi Task
Approve a pending task for Lexi to execute
POST
/
v1
/
lexi
/
tasks
/
:id
/
approve
Approve Lexi Task
curl --request POST \
--url https://api.example.com/v1/lexi/tasks/:id/approveimport requests
url = "https://api.example.com/v1/lexi/tasks/:id/approve"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/v1/lexi/tasks/:id/approve', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v1/lexi/tasks/:id/approve",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/lexi/tasks/:id/approve"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/v1/lexi/tasks/:id/approve")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/lexi/tasks/:id/approve")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_body{
"data": {
"task_id": "<string>",
"status": "<string>",
"execution_started": true
}
}Request
Path Parameters
string
required
Task UUID
Headers
Authorization: Bearer wbk_your_api_key_here
Content-Type: application/json
Response
object
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"
import requests
API_KEY = "wbk_your_api_key_here"
BASE_URL = "https://data.leadlex.com/functions/v1/api-gateway"
TASK_ID = "task-uuid"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
response = requests.post(
f"{BASE_URL}/v1/lexi/tasks/{TASK_ID}/approve",
headers=headers
)
result = response.json()["data"]
print(f"Task approved: {result['status']}")
const TASK_ID = 'task-uuid';
const response = await fetch(
`https://data.leadlex.com/functions/v1/api-gateway/v1/lexi/tasks/${TASK_ID}/approve`,
{
method: 'POST',
headers: {
'Authorization': 'Bearer wbk_your_api_key_here',
'Content-Type': 'application/json'
}
}
);
const { data } = await response.json();
console.log(`Task approved: ${data.status}`);
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
| 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 |
Example Error (Already Approved)
{
"error": {
"code": "validation_error",
"message": "Task has already been approved"
}
}