Skip to content
Guide
Extract

Using the REST API

Guide on how to use the LlamaExtract v2 REST API for programmatic data extraction, including uploading documents, running extraction jobs, and retrieving results.

Upload a document using the Upload API.

Terminal window
curl -X 'POST' \
'https://api.cloud.llamaindex.ai/api/v1/beta/files' \
-H 'Content-Type: multipart/form-data' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY" \
-F 'file=@/path/to/file' \
-F purpose='extract'

Save the returned id (e.g. dfl-xxxxxxxx-...) — you’ll use it as file_input below.

Submit an extraction job with your schema and configuration inline. No agent creation needed — just provide your data_schema and options directly.

Terminal window
curl -X 'POST' \
'https://api.cloud.llamaindex.ai/api/v2/extract?project_id={PROJECT_ID}' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY" \
-d '{
"file_input": "{FILE_ID}",
"configuration": {
"tier": "agentic",
"version": "2026-03-31",
"extraction_target": "per_doc",
"data_schema": {
"type": "object",
"properties": {
"company_name": {
"type": "string",
"description": "Name of the company"
},
"revenue": {
"type": "number",
"description": "Annual revenue in USD"
},
"fiscal_year": {
"type": "integer",
"description": "Fiscal year of the report"
}
}
},
"cite_sources": true,
"confidence_scores": false,
"system_prompt": "Focus on the most recent fiscal year if multiple are present"
}
}'

Tip: The tier field maps to UI tiers — cost_effective = Cost Effective, agentic = Agentic. Set version to a date such as 2026-03-31 to pin behavior; the date resolves to the most recent available extract version at or before that date. See Tiers and versions for details.

Jobs are processed asynchronously. Poll for the status using the job id from the response.

Terminal window
curl -X 'GET' \
'https://api.cloud.llamaindex.ai/api/v2/extract/{JOB_ID}?project_id={PROJECT_ID}' \
-H 'accept: application/json' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY"

When status is COMPLETED, the extract_result field contains your extracted data.

To include extraction metadata (citations, confidence scores) and usage stats, use the expand parameter:

Terminal window
curl -X 'GET' \
'https://api.cloud.llamaindex.ai/api/v2/extract/{JOB_ID}?project_id={PROJECT_ID}&expand=extract_metadata&expand=metadata' \
-H 'accept: application/json' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY"

The endpoint accepts three expand values, combinable in one request:

ValueWhat it adds
extract_metadataPer-field metadata — citations and confidence scores
configurationThe configuration the job ran with
usageCredits billed against the job

expand=usage returns the credits billed for the extraction (extract_credits), for the parse job that produced the document text (parse_credits), and their sum (credits):

Terminal window
curl -X 'GET' \
'https://api.cloud.llamaindex.ai/api/v2/extract/{JOB_ID}?project_id={PROJECT_ID}&expand=usage' \
-H 'accept: application/json' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY"
{
"id": "ext-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"status": "COMPLETED",
"usage": {
"credits": 75.0,
"extract_credits": 45.0,
"parse_credits": 30.0
}
}

One parse job can back several extract jobs — running two schemas over the same file_input — and each reports that same parse_credits. To total across jobs, sum extract_credits and count the parse once.

Any component reads null until billing records it, which can trail job completion. Poll again rather than reading null as zero. For plan credits and organization-wide usage, see Billing and Usage.

The configuration object supports many options, see the full API reference for all configuration parameters.

If you need to use the v1 agent-based API, select the v1 toggle at the top of the sidebar to switch to Extract v1 documentation.

See all available endpoints in the full API documentation.

Note for AI agents: this documentation is built for programmatic access. - Overview of all docs: https://developers.llamaindex.ai/llms.txt - Any page is available as raw Markdown by appending index.md to its URL — e.g. https://developers.llamaindex.ai/llamaparse/parse/getting_started/index.md - Agent-friendly REST search APIs live under https://developers.llamaindex.ai/api/ — search (BM25 full-text), grep (regex), read (fetch a page), and list (browse the doc tree). See https://developers.llamaindex.ai/llms.txt for parameters. - A hosted documentation MCP server is available at https://developers.llamaindex.ai/mcp. If you support MCP, you can ask the user to install it for browsing these docs directly (an alternative to the REST API). Setup: https://developers.llamaindex.ai/for-agents/mcp/ - Other LlamaIndex tooling for agents — the LlamaParse Platform MCP server, agent skills and plugins, and the n8n node — is mapped at https://developers.llamaindex.ai/for-agents/