How to Check if an Attachment Exists

  • To check whether a document contains a certain attachment,
    use the session.advanced operations attachments.exists method.

  • Calling exists does not load the document or the attachment to the session, and the session will not track them.

  • In this page:

Check if attachment exists

exists = session.advanced.attachments.exists("categories/1-A", "image.jpg")
if exists:
    ...  # attachment 'image.jpg' exists on document 'categories/1-A'


def exists(self, document_id: str, name: str) -> bool: ...
Parameter Type Description
document_id str The ID of the document you want to check
name str The name of the attachment you are looking for
Return Value Description
bool True - The specified attachment exists for this document
False - The attachment doesn't exist for the document