Upload files
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");curl_easy_setopt(hnd, CURLOPT_URL, "https://api.langparse.dev/api/v1/files");
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, "{ \"files\": [ { \"contents\": \"JVBERi0xLjQ…\", \"name\": \"invoice.pdf\" } ] }");
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/files"), Headers = { { "X-Api-Key", "<X-Api-Key>" }, }, Content = new StringContent("{ \"files\": [ { \"contents\": \"JVBERi0xLjQ…\", \"name\": \"invoice.pdf\" } ] }") { 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/files"
payload := strings.NewReader("{ \"files\": [ { \"contents\": \"JVBERi0xLjQ…\", \"name\": \"invoice.pdf\" } ] }")
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/files")) .header("X-Api-Key", "<X-Api-Key>") .header("Content-Type", "application/json") .method("POST", HttpRequest.BodyPublishers.ofString("{ \"files\": [ { \"contents\": \"JVBERi0xLjQ…\", \"name\": \"invoice.pdf\" } ] }")) .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, "{ \"files\": [ { \"contents\": \"JVBERi0xLjQ…\", \"name\": \"invoice.pdf\" } ] }");Request request = new Request.Builder() .url("https://api.langparse.dev/api/v1/files") .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/files', headers: {'X-Api-Key': '<X-Api-Key>', 'Content-Type': 'application/json'}, data: {files: [{contents: 'JVBERi0xLjQ…', name: 'invoice.pdf'}]}};
try { const { data } = await axios.request(options); console.log(data);} catch (error) { console.error(error);}const url = 'https://api.langparse.dev/api/v1/files';const options = { method: 'POST', headers: {'X-Api-Key': '<X-Api-Key>', 'Content-Type': 'application/json'}, body: '{"files":[{"contents":"JVBERi0xLjQ…","name":"invoice.pdf"}]}'};
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, "{ \"files\": [ { \"contents\": \"JVBERi0xLjQ…\", \"name\": \"invoice.pdf\" } ] }")val request = Request.Builder() .url("https://api.langparse.dev/api/v1/files") .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/files";
let payload = json!({"files": ( json!({ "contents": "JVBERi0xLjQ…", "name": "invoice.pdf" }) )});
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/files \ --header 'Content-Type: application/json' \ --header 'X-Api-Key: <X-Api-Key>' \ --data '{ "files": [ { "contents": "JVBERi0xLjQ…", "name": "invoice.pdf" } ] }'wget --quiet \ --method POST \ --header 'X-Api-Key: <X-Api-Key>' \ --header 'Content-Type: application/json' \ --body-data '{ "files": [ { "contents": "JVBERi0xLjQ…", "name": "invoice.pdf" } ] }' \ --output-document \ - https://api.langparse.dev/api/v1/filesCreate one or many files. Each item carries exactly one source: contents (base64), url (server fetches it — SSRF-guarded, public http(s) only), or presign: true (returns a presigned PUT URL to upload to yourself — best for large files). name/contentType are inferred when omitted (filename → url → magic bytes). Results are per-item (partial success).
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
object
object
object
Return a presigned PUT URL instead of uploading now.
Examples
Inline base64
{ "files": [ { "contents": "JVBERi0xLjQ…", "name": "invoice.pdf" } ]}Fetch from a URL
{ "files": [ { "url": "https://example.com/invoice.pdf" } ]}Presigned upload (large files)
{ "files": [ { "presign": true, "name": "big.pdf", "contentType": "application/pdf" } ]}Responses
Section titled “Responses”Per-item results (partial success — inspect each ok).
object
Per-item result. On success ok:true + the file; on failure ok:false + error. status:"pending" (presign) also carries uploadUrl.
object
Presign mode only — PUT the bytes here.
object
Example
{ "data": [ { "ok": true, "id": "file_mrb1a2c3d4", "name": "invoice.pdf", "contentType": "application/pdf", "byteSize": 48213, "status": "stored" }, { "ok": true, "id": "file_mrb1a2c3e5", "name": "big.pdf", "contentType": "application/pdf", "status": "pending", "uploadUrl": "https://…s3…X-Amz-Signature=…", "method": "PUT", "expiresInSeconds": 900 } ]}Body must be { files: [ … ] }; each item needs exactly one of contents/url/presign.
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"}