Document Types
Python SDK - Document Types resource API reference
Document Types resource for document type catalog operations.
DocumentTypes
Synchronous document type operations.
Example:
client = Client(api_key="...")
page = client.document_types.list()
for doc_type in page.data:
print(f"{doc_type.codeType}: {doc_type.name}")
# Iterate through all document types across pages
for doc_type in client.document_types.list().auto_paging_iter():
print(doc_type.name)Arguments:
client: The parent client instance.
Methods:
get
def get(self, type_id: str) -> DocumentTypeGet a specific document type by ID.
Arguments:
type_id: The document type ID.
Returns:
The document type details including schema.
Raises:
NotFoundError: If the document type doesn't exist.
Example:
doc_type = client.document_types.get("dt_abc123")
print(f"Name: {doc_type.name}")
print(f"Schema: {doc_type.schema_}")list
def list(self, page: int | None = None, limit: int | None = None, search: str | None = None) -> Page[DocumentType]List available document types.
Arguments:
page: Page number (1-indexed). Defaults to 1.limit: Number of items per page. Defaults to server default.search: Search term to filter document types by name.
Returns:
A Page of document types with pagination support.
Example:
# List all document types
page = client.document_types.list()
for doc_type in page.data:
print(doc_type.name)
# Iterate through all pages
for page in client.document_types.list().iter_pages():
print(f"Page {page.page}: {len(page.data)} items")
# Iterate through all items automatically
for doc_type in client.document_types.list().auto_paging_iter():
print(doc_type.name)
# Search for specific types
page = client.document_types.list(search="invoice")validate
def validate(self, type_id: str, data: dict[str, Any]) -> ValidationResultValidate JSON data against a document type's schema.
This validates extracted data to check if it conforms to the document type's expected structure and requirements.
Arguments:
type_id: The document type ID to validate against.data: The JSON data to validate.
Returns:
Validation result with errors and warnings.
Example:
result = client.document_types.validate(
"dt_invoice",
{"invoice_number": "INV-001", "total": 100}
)
if result.is_valid():
print("Data is valid!")
else:
for error in result.errors.messages:
print(f"Error: {error}")Properties:
with_raw_response: Access methods that return raw HTTP responses.
AsyncDocumentTypes
Asynchronous document type operations.
Example:
async with AsyncClient(api_key="...") as client:
page = await client.document_types.list()
for doc_type in page.data:
print(f"{doc_type.codeType}: {doc_type.name}")
# Iterate through all document types across pages
async for doc_type in (await client.document_types.list()).auto_paging_iter_async():
print(doc_type.name)Arguments:
client: The parent async client instance.
Methods:
get
async def get(self, type_id: str) -> DocumentTypeGet a specific document type by ID.
Arguments:
type_id: The document type ID.
Returns:
The document type details including schema.
list
async def list(self, page: int | None = None, limit: int | None = None, search: str | None = None) -> AsyncPage[DocumentType]List available document types.
Arguments:
page: Page number (1-indexed). Defaults to 1.limit: Number of items per page. Defaults to server default.search: Search term to filter document types by name.
Returns:
An AsyncPage of document types with pagination support.
validate
async def validate(self, type_id: str, data: dict[str, Any]) -> ValidationResultValidate JSON data against a document type's schema.
Arguments:
type_id: The document type ID to validate against.data: The JSON data to validate.
Returns:
Validation result with errors and warnings.
Properties:
with_raw_response: Access methods that return raw HTTP responses.