Parse a document
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");curl_easy_setopt(hnd, CURLOPT_URL, "https://api.langparse.dev/api/v1/documents");
struct curl_slist *headers = NULL;headers = curl_slist_append(headers, "X-Api-Key: <X-Api-Key>");headers = curl_slist_append(headers, "Content-Type: application/json");curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{ \"file\": { \"id\": \"file_mrb1a2c3d4\" }, \"model\": \"mdl_inv01\" }");
CURLcode ret = curl_easy_perform(hnd);using System.Net.Http.Headers;var client = new HttpClient();var request = new HttpRequestMessage{ Method = HttpMethod.Post, RequestUri = new Uri("https://api.langparse.dev/api/v1/documents"), Headers = { { "X-Api-Key", "<X-Api-Key>" }, }, Content = new StringContent("{ \"file\": { \"id\": \"file_mrb1a2c3d4\" }, \"model\": \"mdl_inv01\" }") { Headers = { ContentType = new MediaTypeHeaderValue("application/json") } }};using (var response = await client.SendAsync(request)){ response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body);}package main
import ( "fmt" "strings" "net/http" "io")
func main() {
url := "https://api.langparse.dev/api/v1/documents"
payload := strings.NewReader("{ \"file\": { \"id\": \"file_mrb1a2c3d4\" }, \"model\": \"mdl_inv01\" }")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Api-Key", "<X-Api-Key>") req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close() body, _ := io.ReadAll(res.Body)
fmt.Println(res) fmt.Println(string(body))
}HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://api.langparse.dev/api/v1/documents")) .header("X-Api-Key", "<X-Api-Key>") .header("Content-Type", "application/json") .method("POST", HttpRequest.BodyPublishers.ofString("{ \"file\": { \"id\": \"file_mrb1a2c3d4\" }, \"model\": \"mdl_inv01\" }")) .build();HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());System.out.println(response.body());OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");RequestBody body = RequestBody.create(mediaType, "{ \"file\": { \"id\": \"file_mrb1a2c3d4\" }, \"model\": \"mdl_inv01\" }");Request request = new Request.Builder() .url("https://api.langparse.dev/api/v1/documents") .post(body) .addHeader("X-Api-Key", "<X-Api-Key>") .addHeader("Content-Type", "application/json") .build();
Response response = client.newCall(request).execute();import axios from 'axios';
const options = { method: 'POST', url: 'https://api.langparse.dev/api/v1/documents', headers: {'X-Api-Key': '<X-Api-Key>', 'Content-Type': 'application/json'}, data: {file: {id: 'file_mrb1a2c3d4'}, model: 'mdl_inv01'}};
try { const { data } = await axios.request(options); console.log(data);} catch (error) { console.error(error);}const url = 'https://api.langparse.dev/api/v1/documents';const options = { method: 'POST', headers: {'X-Api-Key': '<X-Api-Key>', 'Content-Type': 'application/json'}, body: '{"file":{"id":"file_mrb1a2c3d4"},"model":"mdl_inv01"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")val body = RequestBody.create(mediaType, "{ \"file\": { \"id\": \"file_mrb1a2c3d4\" }, \"model\": \"mdl_inv01\" }")val request = Request.Builder() .url("https://api.langparse.dev/api/v1/documents") .post(body) .addHeader("X-Api-Key", "<X-Api-Key>") .addHeader("Content-Type", "application/json") .build()
val response = client.newCall(request).execute()use serde_json::json;use reqwest;
#[tokio::main]pub async fn main() { let url = "https://api.langparse.dev/api/v1/documents";
let payload = json!({ "file": json!({"id": "file_mrb1a2c3d4"}), "model": "mdl_inv01" });
let mut headers = reqwest::header::HeaderMap::new(); headers.insert("X-Api-Key", "<X-Api-Key>".parse().unwrap()); headers.insert("Content-Type", "application/json".parse().unwrap());
let client = reqwest::Client::new(); let response = client.post(url) .headers(headers) .json(&payload) .send() .await;
let results = response.unwrap() .json::<serde_json::Value>() .await .unwrap();
dbg!(results);}curl --request POST \ --url https://api.langparse.dev/api/v1/documents \ --header 'Content-Type: application/json' \ --header 'X-Api-Key: <X-Api-Key>' \ --data '{ "file": { "id": "file_mrb1a2c3d4" }, "model": "mdl_inv01" }'wget --quiet \ --method POST \ --header 'X-Api-Key: <X-Api-Key>' \ --header 'Content-Type: application/json' \ --body-data '{ "file": { "id": "file_mrb1a2c3d4" }, "model": "mdl_inv01" }' \ --output-document \ - https://api.langparse.dev/api/v1/documentsParse a file into a document. Provide a file (a FileRef) and exactly one parsing strategy: model (a specific model), router (classify across a router, then parse), schemaless (infer the structure), or auto (detect the best model, then parse). ⚠️ Do not combine strategies — e.g. sending both model and router is a 400. Async: returns 202 with a poll URL.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Parse request. file is required; then exactly one of model / router / schemaless / auto.
object
object
An existing file id (from POST /v1/files or a folder listing).
object
Base64 bytes (optionally a data: URI).
object
Public http(s) URL the server fetches (SSRF-guarded).
Free-text steer for schemaless/auto (e.g. “pull the line items”).
Override the extractor (vision) model.
1-indexed pages to parse; omit for all.
POSTed the result when parsing finishes (instead of polling).
HMAC secret for the callback signature.
Repeat-safe: the same key returns the original document (also accepted as the Idempotency-Key header).
object
Model id (mdl_…) OR its friendly key/slug — parse with this model.
object
Router id — classify across it, then parse.
object
Infer the structure with no model.
object
Detect the best model across all your models, then parse.
Examples
Parse an existing file with a model
{ "file": { "id": "file_mrb1a2c3d4" }, "model": "mdl_inv01"}Schemaless, fetched from a URL
{ "file": { "url": "https://example.com/invoice.pdf" }, "schemaless": true, "hint": "Pull the line items with description, qty, unit price."}Inline base64, routed
{ "file": { "contents": "JVBERi0xLjQ…", "name": "invoice.pdf" }, "router": "rtr_ap01"}Auto-detect the model
{ "file": { "id": "file_mrb1a2c3d4" }, "auto": true}Responses
Section titled “Responses”Accepted — poll pollUrl for the result.
object
Async accept — the parse is queued. Poll pollUrl.
object
Example
{ "data": { "id": "doc_mrb1x9y8z7", "status": "queued", "pollUrl": "/api/v1/documents/doc_mrb1x9y8z7" }}Invalid body, or more than one strategy (model/router/schemaless/auto) was provided.
Error response. statusCode mirrors the HTTP status; statusMessage is human-readable.
object
Example
{ "statusCode": 404, "statusMessage": "Document not found"}Missing or invalid API key.
Error response. statusCode mirrors the HTTP status; statusMessage is human-readable.
object
Example
{ "statusCode": 404, "statusMessage": "Document not found"}Insufficient credits — top up to continue parsing.
Error response. statusCode mirrors the HTTP status; statusMessage is human-readable.
object
Example
{ "statusCode": 404, "statusMessage": "Document not found"}Model / router / file not found.
Error response. statusCode mirrors the HTTP status; statusMessage is human-readable.
object
Example
{ "statusCode": 404, "statusMessage": "Document not found"}