Analyze Document
curl --request POST \
--url https://api.example.com/v1/ai/analyze-document \
--header 'Content-Type: application/json' \
--data '
{
"document_id": "<string>",
"sections": [
{}
],
"prompt": "<string>"
}
'import requests
url = "https://api.example.com/v1/ai/analyze-document"
payload = {
"document_id": "<string>",
"sections": [{}],
"prompt": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({document_id: '<string>', sections: [{}], prompt: '<string>'})
};
fetch('https://api.example.com/v1/ai/analyze-document', 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/ai/analyze-document",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'document_id' => '<string>',
'sections' => [
[
]
],
'prompt' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/ai/analyze-document"
payload := strings.NewReader("{\n \"document_id\": \"<string>\",\n \"sections\": [\n {}\n ],\n \"prompt\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
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/ai/analyze-document")
.header("Content-Type", "application/json")
.body("{\n \"document_id\": \"<string>\",\n \"sections\": [\n {}\n ],\n \"prompt\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/ai/analyze-document")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"document_id\": \"<string>\",\n \"sections\": [\n {}\n ],\n \"prompt\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"summary": "<string>",
"clauses": [
{}
],
"entities": [
{}
],
"risks": [
{}
],
"obligations": [
{}
],
"dates": [
{}
],
"amounts": [
{}
],
"signatories": [
{}
],
"page_count": 123,
"credits_remaining": 123
}
}AI Analysis
Analyze Document
Extract structured insights from a stored document - summary, clauses, entities, and risks
POST
/
v1
/
ai
/
analyze-document
Analyze Document
curl --request POST \
--url https://api.example.com/v1/ai/analyze-document \
--header 'Content-Type: application/json' \
--data '
{
"document_id": "<string>",
"sections": [
{}
],
"prompt": "<string>"
}
'import requests
url = "https://api.example.com/v1/ai/analyze-document"
payload = {
"document_id": "<string>",
"sections": [{}],
"prompt": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({document_id: '<string>', sections: [{}], prompt: '<string>'})
};
fetch('https://api.example.com/v1/ai/analyze-document', 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/ai/analyze-document",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'document_id' => '<string>',
'sections' => [
[
]
],
'prompt' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/ai/analyze-document"
payload := strings.NewReader("{\n \"document_id\": \"<string>\",\n \"sections\": [\n {}\n ],\n \"prompt\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
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/ai/analyze-document")
.header("Content-Type", "application/json")
.body("{\n \"document_id\": \"<string>\",\n \"sections\": [\n {}\n ],\n \"prompt\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/ai/analyze-document")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"document_id\": \"<string>\",\n \"sections\": [\n {}\n ],\n \"prompt\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"summary": "<string>",
"clauses": [
{}
],
"entities": [
{}
],
"risks": [
{}
],
"obligations": [
{}
],
"dates": [
{}
],
"amounts": [
{}
],
"signatories": [
{}
],
"page_count": 123,
"credits_remaining": 123
}
}This endpoint consumes AI credits based on document size: 3 credits for documents up to 10 pages, 6 credits up to 50 pages, and 12 credits up to 250 pages. Documents larger than 250 pages are rejected with
413 payload_too_large. If the workspace balance is insufficient, the API returns 402 insufficient_credits.Request
Headers
Authorization: Bearer wbk_your_api_key_here
Content-Type: application/json
string
Optional UUID. Deduplicates retries within 24 hours.
Body Parameters
string
required
UUID of a document stored via
POST /v1/documents.array
Optional subset of sections to produce:
summary, clauses, entities, risks, obligations, dates, amounts, signatories. Defaults to all.string
Optional free-form instruction to steer the analysis (e.g. “focus on indemnity and limitation of liability clauses”).
Response
object
Show properties
Show properties
string
One-paragraph summary of the document
array
Detected clauses, each with
type, title, text, pagearray
Named entities:
type (person/company/jurisdiction/court), name, pagearray
Each with
description and severityarray
Parties’ obligations extracted from the document
array
Detected dates with context
array
Monetary amounts with
currency and contextarray
Detected signatories:
name, role, partyinteger
Total pages analyzed
integer
Balance after this call
X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, and X-Request-ID.
curl -X POST \
https://data.leadlex.com/functions/v1/api-gateway/v1/ai/analyze-document \
-H "Authorization: Bearer wbk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{"document_id": "doc_01HY1", "sections": ["summary", "risks", "clauses"]}'
import requests
API_KEY = "wbk_your_api_key_here"
BASE_URL = "https://data.leadlex.com/functions/v1/api-gateway"
r = requests.post(
f"{BASE_URL}/v1/ai/analyze-document",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
},
json={"document_id": "doc_01HY1"},
)
print(r.json()["data"]["summary"])
const res = await fetch(
'https://data.leadlex.com/functions/v1/api-gateway/v1/ai/analyze-document',
{
method: 'POST',
headers: {
'Authorization': 'Bearer wbk_your_api_key_here',
'Content-Type': 'application/json',
},
body: JSON.stringify({ document_id: 'doc_01HY1' }),
}
);
const { data } = await res.json();
console.log(data.summary);
Example Response
{
"data": {
"summary": "Mutual non-disclosure agreement between Acme Corp and EMA Sex, effective April 17 2026, with a two-year term and carve-outs for regulatory disclosure.",
"clauses": [
{ "type": "term", "title": "Term", "text": "This Agreement shall remain in effect for a period of two (2) years from the Effective Date...", "page": 2 }
],
"entities": [
{ "type": "company", "name": "Acme Corp", "page": 1 },
{ "type": "company", "name": "EMA Sex", "page": 1 }
],
"risks": [
{ "description": "No explicit residuals clause", "severity": "medium" }
],
"obligations": [
{ "party": "Receiving Party", "description": "Keep Confidential Information secret" }
],
"dates": [
{ "context": "Effective date", "value": "2026-04-17" }
],
"amounts": [],
"signatories": [
{ "name": "Jane Doe", "role": "General Counsel", "party": "Acme Corp" }
],
"page_count": 4,
"credits_remaining": 4851
}
}
Errors
| Status | Code | Description |
|---|---|---|
| 400 | validation_error | Missing or malformed document_id |
| 401 | invalid_key | Invalid or expired API key |
| 402 | insufficient_credits | Workspace credit balance is exhausted |
| 403 | insufficient_permissions | Missing write:ai permission |
| 404 | not_found | Document not found |
| 413 | payload_too_large | Document exceeds the 250-page limit |
| 429 | rate_limited | Rate limit exceeded |