upload_file
Upload a source file into the workspace. Cost class: job.
The one route with two credentials: the tenant's X-API-Key, or a short-lived X-Upload-Token grant minted by create_upload_grant — which is how a customer's end client uploads directly without ever holding the key. A grant redeems the multipart path only, within the constraints frozen into it (workspace, optional pinned path, byte cap).
Two content paths, per the UploadFileRequest contract:
- multipart/form-data — file bytes in a file part, request parameters as a JSON string in a metadata form field.
- application/json — an UploadFileRequest body whose source carries a UrlSource; the bytes are fetched server-side and then take the exact same storage/ledger path as multipart.
Upload does NOT ingest. The file lands with ingestion_status = discovered and is not searchable. Making it searchable requires a separate POST .../ingestions call. This keeps the cost model honest: a caller can upload a thousand files and choose to ingest fifty.
Args: upload_auth: The resolved workspace context, plus the upload grant when the caller redeemed one instead of sending an API key. session: Database session. request: The raw request, for the JSON (URL-source) content path. file: The file bytes, as an UploadFile from the multipart body. metadata: JSON-encoded UploadFileRequest from the multipart body. wait_seconds: Accepted for uniformity; the work is already done. idempotency_key: Replaying with the same key returns the original job. response: Injected by FastAPI for status-code management.
Returns: A succeeded Job whose result is an UploadFileResult.
Raises: PlatformError: invalid_request when the body is malformed, the metadata JSON is invalid, or a URL source is refused or answers with an error status. PlatformError: path_conflict when on_conflict="reject" and a different file already occupies the destination path. PlatformError: file_too_large when the upload exceeds NDI_MAX_UPLOAD_BYTES or the grant's tighter max_bytes. Larger tabular files must use POST .../upload-sessions. PlatformError: access_denied when an upload grant is redeemed outside its constraints (URL source, or a pinned-path mismatch). PlatformError: unauthorized when a single-use grant is replayed.
Request
- Base URLhttps://ndi-api.nace.ai (the document declares no server; this is the origin it was published from)
- Auth
- API key in header X-API-Key
- or API key in header X-Upload-Token
- TypeScriptA function with typed inputs. Its response is checked against the schema.
Path parameters
Workspace identifier.
Query parameters
Bounded inline wait. 0 (the default) returns 202 immediately. Above 0 the route returns 200 with a terminal job if the work finished in time, and 202 with the still-running job if it did not. Either way, read status.
Headers
Replaying a request with the same key returns the original job with 200, never a second job. The key is kept with the job for replay and never cleared, so it must not contain personal data.
Request body multipart/form-data
Response
Successful Response
Changes
No recorded changes to this operation across all 1 revision of this API.