Skip to main content

Files

dcy file upload uses the Files module presigned upload flow by default:
  1. Request a presigned upload URL from POST /v1/files/presigned-urls
  2. Upload the file directly to S3
  3. Confirm the upload with PATCH /v1/files/batch-update
That means CLI uploads can run autonomously from scripts and CI jobs while still triggering the normal file classification pipeline.

Upload a File

dcy file upload ./invoice.pdf

Upload into a Folder

dcy file upload ./invoice.pdf --folder-id <folder-id>
dcy file upload ./invoice.pdf --project-id <project-id>
When --project-id is present, the CLI passes that value to PATCH /v1/files/batch-update so the backend creates file_project associations after the S3 upload succeeds.

Choose the Upload Mode

# Recommended: direct-to-S3 upload
dcy file upload ./invoice.pdf --mode presigned

# Legacy fallback: backend multipart upload
dcy file upload ./invoice.pdf --mode multipart

Inspect Uploaded Files

dcy file list
dcy file show <file-id>
dcy file process <file-id>
dcy file delete <file-id> --yes
dcy file recover <file-id>

Retry File Processing

If a file was uploaded and classified but has still not produced a file_reading, re-queue processing:
dcy file process <file-id>
This command calls POST /v1/files/send-event with event_type=PROCESS_DOCUMENT.

Work With File Readings

dcy file reading list
dcy file reading show <file-id>
Filter down to a specific file or category:
dcy file reading list --file-id <file-id> --category water

Correct Extracted Reading Content

Prepare a JSON file containing either:
  • a full {"content":{"items":[...]}} object, or
  • a raw items array
Then update the reading:
dcy file reading update <file-reading-id> --content-file ./reading.json

Create Linked Records

Create invoices or wastes from a parsed reading and assign facility percentages in the same command:
dcy file reading create-records <file-reading-id> \
  --facility <facility-id>=1.0
Multiple facilities are supported as long as the total percentage is <= 1.0:
dcy file reading create-records <file-reading-id> \
  --facility <facility-a>=0.6 \
  --facility <facility-b>=0.4 \
  --project-id <project-id>

Current Limitation

The backend currently supports exactly one file reading per create-records request, so the CLI processes one reading at a time for this step.

Automation Example

#!/usr/bin/env bash
set -euo pipefail

dcy auth login
dcy org set "$DCYCLE_ORG_ID"
dcy file upload ./artifacts/invoice.pdf --project-id "$DCYCLE_PROJECT_ID" --format json