Skip to main content
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>"
}
'
{
  "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
Idempotency-Key
string
Optional UUID. Deduplicates retries within 24 hours.

Body Parameters

document_id
string
required
UUID of a document stored via POST /v1/documents.
sections
array
Optional subset of sections to produce: summary, clauses, entities, risks, obligations, dates, amounts, signatories. Defaults to all.
prompt
string
Optional free-form instruction to steer the analysis (e.g. “focus on indemnity and limitation of liability clauses”).

Response

data
object
Responses include 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"]}'

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

StatusCodeDescription
400validation_errorMissing or malformed document_id
401invalid_keyInvalid or expired API key
402insufficient_creditsWorkspace credit balance is exhausted
403insufficient_permissionsMissing write:ai permission
404not_foundDocument not found
413payload_too_largeDocument exceeds the 250-page limit
429rate_limitedRate limit exceeded