Skip to main content

Endpoint

POST /upload
Upload one or more documents to receive document IDs for extraction. Supports PDF, DOCX, DOC, JPG, and PNG formats.

Authentication

X-API-Key
string
required
API key for authentication. Your unique API key.

Request Parameters

files
file[]
required
One or more document files to upload. Maximum 100 files per request.Supported formats:
  • application/pdf (.pdf)
  • application/msword (.doc)
  • application/vnd.openxmlformats-officedocument.wordprocessingml.document (.docx)
  • image/jpeg (.jpg, .jpeg)
  • image/png (.png)

Response

document_ids
string[]
Array of UUID v4 document identifiers. Use these IDs for extraction requests.

Examples

curl -X POST https://api.documind.com/api/v1/upload \
  -H 'X-API-Key: YOUR_API_KEY' \
  -F '[email protected]' \
  -F '[email protected]' \
  -F '[email protected]'
[
  "550e8400-e29b-41d4-a716-446655440000"
]

File Size & Limits

  • Maximum file size: 50 MB per file
  • Maximum files per request: 100 files
  • Total request size: 500 MB
For larger batches, split into multiple upload requests.

Storage Duration

Uploaded documents are stored for 30 days after upload. After this period, documents are automatically deleted. Extraction results remain accessible indefinitely.
Download original documents via /documents/{document_id}/download if you need to archive them beyond 30 days.

Processing Time

Document upload is typically completed within:
  • Single page PDF: < 1 second
  • 10-page PDF: 2-3 seconds
  • Large image (10MB): 3-5 seconds
The API returns document IDs immediately after upload, before any processing begins.

Error Responses

400 Bad Request

Invalid file format or size:
{
  "detail": "File format not supported. Supported formats: PDF, DOCX, DOC, JPG, PNG"
}
Common causes:
  • Unsupported file format (e.g., .txt, .xls)
  • Corrupt or invalid file
  • File size exceeds 50 MB

402 Payment Required

Insufficient credits:
{
  "detail": "Insufficient credits. Please upgrade your plan or wait for your daily credits to refresh."
}
Solution: Check your credit balance via /usage/credits and upgrade if needed.

413 Payload Too Large

Request exceeds size limits:
{
  "detail": "Request payload too large. Maximum total size: 500MB"
}
Solution: Split your batch into smaller requests.

500 Internal Server Error

Server-side processing error:
{
  "detail": "Failed to upload documents. Please try again later."
}
Solution: Retry the request. If the error persists, contact support.

Best Practices

Upload multiple documents in a single request to reduce API calls:
# ✓ Good: Batch upload
files = [("files", open(f, "rb")) for f in file_paths]
response = requests.post(url, headers=headers, files=files)

# ✗ Avoid: Multiple single uploads
for file_path in file_paths:
    response = requests.post(url, headers=headers, 
                           files={"files": open(file_path, "rb")})
Always close file handles after upload:
# Using context manager (recommended)
with open("document.pdf", "rb") as f:
    response = requests.post(url, files={"files": f})

# Or explicitly close
files = [("files", open(f, "rb")) for f in file_paths]
try:
    response = requests.post(url, files=files)
finally:
    for _, fh in files:
        fh.close()
Check file format and size before uploading:
import os

MAX_SIZE = 50 * 1024 * 1024  # 50 MB
SUPPORTED = {'.pdf', '.docx', '.doc', '.jpg', '.jpeg', '.png'}

def validate_file(file_path):
    ext = os.path.splitext(file_path)[1].lower()
    size = os.path.getsize(file_path)
    
    if ext not in SUPPORTED:
        raise ValueError(f"Unsupported format: {ext}")
    if size > MAX_SIZE:
        raise ValueError(f"File too large: {size/1024/1024:.1f}MB")
    
    return True

# Validate before upload
valid_files = [f for f in file_paths if validate_file(f)]
Map document IDs to original filenames for tracking:
# Create mapping
filename_to_id = {}

for file_path in file_paths:
    with open(file_path, "rb") as f:
        response = requests.post(url, files={"files": f})
        doc_id = response.json()[0]
        filename_to_id[os.path.basename(file_path)] = doc_id

# Save mapping for later reference
import json
with open("document_mapping.json", "w") as f:
    json.dump(filename_to_id, f, indent=2)

Next Steps

After uploading documents, you can: