Create Document Record
curl --request POST \
--url https://api.example.com/v1/documents \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"mime_type": "<string>",
"storage_path": "<string>",
"size_bytes": 123,
"description": "<string>",
"folder": "<string>",
"tags": [
{}
]
}
'import requests
url = "https://api.example.com/v1/documents"
payload = {
"name": "<string>",
"mime_type": "<string>",
"storage_path": "<string>",
"size_bytes": 123,
"description": "<string>",
"folder": "<string>",
"tags": [{}]
}
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({
name: '<string>',
mime_type: '<string>',
storage_path: '<string>',
size_bytes: 123,
description: '<string>',
folder: '<string>',
tags: [{}]
})
};
fetch('https://api.example.com/v1/documents', 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/documents",
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([
'name' => '<string>',
'mime_type' => '<string>',
'storage_path' => '<string>',
'size_bytes' => 123,
'description' => '<string>',
'folder' => '<string>',
'tags' => [
[
]
]
]),
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/documents"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"mime_type\": \"<string>\",\n \"storage_path\": \"<string>\",\n \"size_bytes\": 123,\n \"description\": \"<string>\",\n \"folder\": \"<string>\",\n \"tags\": [\n {}\n ]\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/documents")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"mime_type\": \"<string>\",\n \"storage_path\": \"<string>\",\n \"size_bytes\": 123,\n \"description\": \"<string>\",\n \"folder\": \"<string>\",\n \"tags\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/documents")
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 \"name\": \"<string>\",\n \"mime_type\": \"<string>\",\n \"storage_path\": \"<string>\",\n \"size_bytes\": 123,\n \"description\": \"<string>\",\n \"folder\": \"<string>\",\n \"tags\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": {}
}Documents
Create Document Record
Register a new document record in the workspace’s document library
POST
/
v1
/
documents
Create Document Record
curl --request POST \
--url https://api.example.com/v1/documents \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"mime_type": "<string>",
"storage_path": "<string>",
"size_bytes": 123,
"description": "<string>",
"folder": "<string>",
"tags": [
{}
]
}
'import requests
url = "https://api.example.com/v1/documents"
payload = {
"name": "<string>",
"mime_type": "<string>",
"storage_path": "<string>",
"size_bytes": 123,
"description": "<string>",
"folder": "<string>",
"tags": [{}]
}
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({
name: '<string>',
mime_type: '<string>',
storage_path: '<string>',
size_bytes: 123,
description: '<string>',
folder: '<string>',
tags: [{}]
})
};
fetch('https://api.example.com/v1/documents', 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/documents",
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([
'name' => '<string>',
'mime_type' => '<string>',
'storage_path' => '<string>',
'size_bytes' => 123,
'description' => '<string>',
'folder' => '<string>',
'tags' => [
[
]
]
]),
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/documents"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"mime_type\": \"<string>\",\n \"storage_path\": \"<string>\",\n \"size_bytes\": 123,\n \"description\": \"<string>\",\n \"folder\": \"<string>\",\n \"tags\": [\n {}\n ]\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/documents")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"mime_type\": \"<string>\",\n \"storage_path\": \"<string>\",\n \"size_bytes\": 123,\n \"description\": \"<string>\",\n \"folder\": \"<string>\",\n \"tags\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/documents")
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 \"name\": \"<string>\",\n \"mime_type\": \"<string>\",\n \"storage_path\": \"<string>\",\n \"size_bytes\": 123,\n \"description\": \"<string>\",\n \"folder\": \"<string>\",\n \"tags\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": {}
}Request
Binary uploads are handled out-of-band through a signed URL flow. This endpoint records the metadata for a document whose bytes have already been uploaded to the workspace’s object store atstorage_path. To obtain a signed upload URL, use POST /v1/documents/upload-url (documented separately under Storage).
Headers
Authorization: Bearer wbk_your_api_key_here
Content-Type: application/json
string
Optional UUID for retry deduplication within 24 hours.
Body Parameters
string
required
Display name of the document. 1 - 255 characters.
string
required
IANA media type of the file (e.g.
application/pdf, image/png).string
required
Object storage key where the uploaded bytes live. Usually returned by the signed-upload flow.
integer
Size of the uploaded file, in bytes. Used for quota tracking.
string
Optional description.
string
Optional folder path. Created on demand. Example:
/clients/acme/ndas.array
Optional array of tag strings.
Response
object
The created document record (same shape as
GET /v1/documents/{id}).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/documents \
-H "Authorization: Bearer wbk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme-NDA-2026.pdf",
"mime_type": "application/pdf",
"storage_path": "workspaces/ws_123/documents/new-upload.pdf",
"size_bytes": 183204,
"folder": "/clients/acme/ndas",
"tags": ["nda", "confidentiality"]
}'
import requests
API_KEY = "wbk_your_api_key_here"
BASE_URL = "https://data.leadlex.com/functions/v1/api-gateway"
payload = {
"name": "Acme-NDA-2026.pdf",
"mime_type": "application/pdf",
"storage_path": "workspaces/ws_123/documents/new-upload.pdf",
"size_bytes": 183204,
"folder": "/clients/acme/ndas",
"tags": ["nda", "confidentiality"],
}
r = requests.post(
f"{BASE_URL}/v1/documents",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
},
json=payload,
)
print(r.json()["data"]["id"])
const res = await fetch(
'https://data.leadlex.com/functions/v1/api-gateway/v1/documents',
{
method: 'POST',
headers: {
'Authorization': 'Bearer wbk_your_api_key_here',
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'Acme-NDA-2026.pdf',
mime_type: 'application/pdf',
storage_path: 'workspaces/ws_123/documents/new-upload.pdf',
size_bytes: 183204,
folder: '/clients/acme/ndas',
tags: ['nda'],
}),
}
);
const { data } = await res.json();
console.log(data.id);
Example Response
{
"data": {
"id": "doc_01HY1",
"name": "Acme-NDA-2026.pdf",
"description": null,
"mime_type": "application/pdf",
"size_bytes": 183204,
"storage_path": "workspaces/ws_123/documents/new-upload.pdf",
"folder": "/clients/acme/ndas",
"tags": ["nda", "confidentiality"],
"created_by": "usr_01HW0",
"created_at": "2026-04-17T10:45:00Z",
"updated_at": "2026-04-17T10:45:00Z"
}
}
Errors
| Status | Code | Description |
|---|---|---|
| 400 | validation_error | Missing required fields or invalid MIME type |
| 401 | invalid_key | Invalid or expired API key |
| 403 | insufficient_permissions | Missing write:documents permission |
| 409 | storage_conflict | A document already exists at the supplied storage_path |
| 429 | rate_limited | Rate limit exceeded |