Media Ingest Jobs API¶
Submit background media ingestion jobs with cancellation support.
Base path: /api/v1/media
Related Connector Sync Jobs¶
External file-hosting sync does not use the /api/v1/media/ingest/jobs endpoints directly.
Google Drive and Microsoft OneDrive source sync runs are queued through the connectors API and the core Jobs domain connectors.
- Connector endpoints:
GET /api/v1/connectors/sources/{source_id}/sync- source-level sync status, cursor state, webhook status, and active job summaryPOST /api/v1/connectors/sources/{source_id}/sync- queue a manualincremental_syncjobPOST /api/v1/connectors/providers/{provider}/webhook- webhook callback that validates, dedupes, and queuesincremental_sync- Connector job types currently used for file-hosting sync:
import- source creation / legacy bootstrap pathincremental_sync- cursor-backed delta syncsubscription_renewal- webhook renewal before expiryrepair_rescan- scheduled replay/full-rescan recovery when a source is markedneeds_full_rescan- Sync job result payloads include
processed,skipped,failed, and, for file-hosting sync,degradedcounts.
Endpoints¶
- POST
/ingest/jobs- Submit jobs (one job per item) - Body: multipart form-data matching
/media/addfields plus optionalfiles - Response:
{ batch_id, jobs: [{ id, uuid, source, source_kind, status }], errors: [] } -
Notes:
errorscontains per-item staging failures; if every item fails, response uses HTTP 207. -
GET
/ingest/jobs?batch_id=...- List jobs for a batch (owner or admin) - Response:
{ batch_id, jobs: [MediaIngestJobStatus...] } -
Notes: Uses indexed
batch_grouplookup with legacy payload fallback for older rows. -
GET
/ingest/jobs/{job_id}- Get job status (owner or admin) -
Response includes progress fields (
progress_percent,progress_message), result summary, and payload metadata (media_type,source,source_kind,batch_id). -
DELETE
/ingest/jobs/{job_id}- Cancel a job (owner or admin) -
Response:
{ success, job_id, status, message } -
POST
/ingest/jobs/cancel?batch_id=...- Cancel jobs for an entire batch (owner or admin) - Alias:
session_idcan be provided instead ofbatch_id - Optional query:
reason -
Response:
{ success, batch_id, requested, cancelled, already_terminal, failed, message }
-
GET
/ingest/jobs/events/stream- Stream ingest job events via SSE (owner or admin) - Optional query:
batch_idto scope to one batch - Optional query:
after_idto resume from a previous event id - Stream events:
snapshotevent containing current job statusesjobevents containing incrementalevent_id,job_id,event_type, andattrs
Cancellation Semantics¶
- Cancellation is cooperative and best-effort.
- Queued jobs are cancelled immediately.
- In-flight jobs check cancellation before persistence and finalize as
cancelledwithout DB writes. - Audio/video ingestion attempts to preempt long-running FFmpeg/STT work when cancellation is requested.
- Batch/session cancellation applies the same semantics to each matched non-terminal job.
Worker¶
- Service:
tldw_Server_API/app/services/media_ingest_jobs_worker.py - Env flags:
MEDIA_INGEST_JOBS_WORKER_ENABLED:true|false(default false)MEDIA_INGEST_JOBS_QUEUE: queue name (defaultdefault)JOBS_DB_URLorJOBS_DB_PATH: Jobs backend (Postgres DSN or SQLite path)
Staging¶
- Uploads are staged into a per-file temp directory.
- The temp dir is stored in the job payload and cleaned up by the worker on completion/cancel.