Skip to content

Document Types

Document types classify documents into categories (e.g. Invoice, Contract, Receipt). They support the full CRUD lifecycle and permission management.

Models

See pypaperless/models/document_types.py for all fields and pypaperless/models/types.py for enum and filter types, and the Paperless-ngx API docs for the upstream schema.

Fetch one

document_type = await paperless.document_types(4)
print(document_type.name)            # "Invoice"
print(document_type.document_count)  # 17

Iterate

async for dt in paperless.document_types:
    print(dt.id, dt.name)

# Keyed by id
types = await paperless.document_types.as_dict()

Create

save() calls validate_draft() first — all of name, match, matching_algorithm and is_insensitive are required and raise DraftFieldRequiredError if missing.

from pypaperless.models.types import MatchingAlgorithm

draft = paperless.document_types.create(
    name="Invoice",
    match="",
    matching_algorithm=MatchingAlgorithm.AUTO,
    is_insensitive=True,
)

pk = await paperless.document_types.save(draft)
print(pk)  # primary key of the new document type

Update

dt = await paperless.document_types(4)
dt.name = "Invoice (updated)"
changed = await paperless.document_types.update(dt)

Delete

dt = await paperless.document_types(4)
await paperless.document_types.delete(dt)

Raises DeletionError on failure. Pass silent_fail=True to suppress it.

Permissions

async with paperless.document_types.with_permissions():
    dt = await paperless.document_types(4)
    print(dt.owner)        # owner user id
    print(dt.permissions)  # Permissions

See Permissions for details on reading and modifying permission sets.