Error handling

The error envelope and every error code.

All errors return a consistent JSON structure:

{
  "error": "MISSING_FILE",
  "message": "No file was uploaded. Attach a file using the 'file' form field.",
  "request_id": "d4e5f6a7-...",
  "details": { }
}
  • error — Machine-readable error code (use this for programmatic handling)
  • message — Human-readable description
  • request_id — Unique ID for support tracing
  • details — Additional context (optional, included on some errors)

Error Codes

Upload Errors

CodeHTTPDescription
MISSING_FILE400No file attached
EMPTY_FILE400File is 0 bytes
FILE_TOO_LARGE413Exceeds 100MB limit
INVALID_FILE_TYPE415Not PDF/PNG/JPG/TIFF/BMP

Validation Errors

CodeHTTPDescription
MISSING_DOCUMENT_TYPE400document_type not provided
INVALID_DOCUMENT_TYPE400Unrecognized document type
DOCUMENT_TYPE_NOT_ALLOWED403Org not authorized for this type
INVALID_DOCUMENT_ID400ID is not a valid positive integer
INVALID_BASE64400Base64 string is malformed
EMPTY_BASE64400Base64 decodes to empty content
MISSING_FILENAME400filename required with file_base64
MISSING_FILE_SOURCE400Neither file_url nor file_base64 provided
INVALID_FILE_URL400URL is malformed or uses unsupported protocol
FILE_URL_DOWNLOAD_FAILED400Could not download from URL (403=private bucket needs presigned URL, 404=file not found, timeout)
INVALID_WEBHOOK_URL400Webhook not a valid HTTP/HTTPS URL

Batch Errors

CodeHTTPDescription
MISSING_BATCH_DOCUMENTS400documents array missing or empty
BATCH_TOO_LARGE400More than 100 documents
UPGRADE_REQUIRED403Batch not available on free tier

Merge Errors

CodeHTTPDescription
MERGE_MIN_FILES400Fewer than 2 files
MERGE_MAX_FILES400More than 50 files
MERGE_UNSUPPORTED_TYPE400File type not supported for merge

Resource Errors

CodeHTTPDescription
DOCUMENT_NOT_FOUND404Document doesn't exist or not in your org
JOB_NOT_FOUND404Processing job not found
BATCH_NOT_FOUND404Batch doesn't exist or not in your org

Export Errors

CodeHTTPDescription
MISSING_DOCUMENT_IDS400document_ids not provided
INVALID_EXPORT_FORMAT400Format not json, csv, or excel
INVALID_EXPORT_TYPE400No export schema available for this document type
DOCUMENT_NOT_PROCESSED400Document has not finished processing yet

Server Errors

CodeHTTPDescription
STORAGE_ERROR502File storage failed — retry
QUEUE_ERROR502Processing queue failed — retry
INTERNAL_ERROR500Unexpected server error

Handling Errors in Code

import requests
 
response = requests.post(
    "https://api.kita.ai/api/v1/documents",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    files={"file": open("statement.pdf", "rb")},
    data={"document_type": "bank_statement"}
)
 
if response.status_code == 202:
    data = response.json()
    print(f"Processing: {data['status_url']}")
elif response.status_code == 413:
    print("File too large — max 100MB")
elif response.status_code == 502:
    error = response.json()
    if error["error"] in ("STORAGE_ERROR", "QUEUE_ERROR"):
        print("Temporary failure — retry in a few seconds")
else:
    error = response.json()
    print(f"Error {error['error']}: {error['message']}")
const res = await fetch("https://api.kita.ai/api/v1/documents", {
  method: "POST",
  headers: { Authorization: "Bearer YOUR_API_KEY" },
  body: formData,
});
 
if (res.status === 202) {
  const { status_url } = await res.json();
  // Poll status_url until status is "completed" or "failed"
} else {
  const { error, message, request_id } = await res.json();
  console.error(`${error}: ${message} (ref: ${request_id})`);
}

On this page