Skip to main content
documents.create_upload stages bytes for one parse, extract, split, classify, or ground operation. It returns an UploadResponse that can be passed directly as the operation’s source.
Ordinary uploads stay until explicit deletion. Use workspace files to organize a searchable corpus.

Basic usage


Method signature

Parameters

Returns

UploadResponse:

Upload options

From a path

Use Path when the file is on disk:
String filesystem paths are also accepted:

From an open binary file

From bytes

Raw bytes do not have a filename. Supply one so NDI can select the correct processing lane:

Use a URL instead

You do not need to call create_upload when NDI can fetch the source directly:
The URL must use HTTPS and be reachable by NDI. For private storage, provide a presigned HTTPS URL. See Sources and uploads.

Async upload


Limits and formats

The upload endpoint enforces the byte cap configured for your API key and rejects formats that no granular document operation supports. Format support then narrows for the operation that consumes the upload; a file accepted by upload can still be rejected by parse, split, classify, extract, or ground.

Format support

Check which document, image, spreadsheet, email, and media formats each operation accepts.

Errors and limits

Review upload size, rate, concurrency, and request limits.

Error handling

Common upload outcomes:
  • file_too_large (413) — the bytes exceed the upload cap.
  • zero_byte_file (422) — the staged file is empty.
  • unsupported_file_type (422) — raised by create_upload when no granular operation supports the format, when the filename conflicts with a conclusive byte signature, or by the consuming operation when that specific operation does not support it.
  • FileNotFoundError — a local path does not exist; this is raised before an HTTP request.
Consuming operations can return upload_expired (409) for an expired handle or upload_not_found (404) for an unknown, cross-tenant, or already removed handle. These are not raised by create_upload itself. unsupported_file_type is synchronous and non-retryable. A rejection from create_upload creates no upload handle; a rejection from the consuming operation creates no job, so there is nothing to poll with jobs.wait. The service inspects only a bounded byte prefix and treats multipart Content-Type as advisory.

Best practices

Prefer Path objects

Use pathlib.Path for local files so the filename travels with the bytes.

Create near use

Ordinary upload handles have no automatic expiry. Zero-retention uploads use isolated temporary staging and are deleted automatically.

Name raw bytes

Always pass file_name with raw bytes so NDI can infer the format.

Use workspaces for persistence

Put files in a workspace to browse and organize a searchable corpus.

Delete an unused upload

documents.delete_upload deletes an unused upload and returns no value. A used upload returns 409 storage_conflict, even after its consuming jobs are deleted; delete its consuming jobs instead and NDI erases the upload in the background. The same rule protects historical API requests; contact support for legacy request deletion. A missing or already removed upload returns 404 upload_not_found.
The async Python client supports await client.documents.delete_upload(upload_id) too.

Next steps