Files API Overview

The Files API enables uploading, downloading, and managing file attachments in DealCloud. Binary downloads use GET .../entryfiles/{entryId}/fields/{fieldId} (no object in the path). Uploads use multipart POST .../entrydata/{object_id} as documented in the DealCloud file upload guide. HTTP is handled by intapp-rest-client; see Advanced configuration.

File Types in DealCloud

DealCloud has two types of file fields:

TypeField TypeDescription
ImagefieldType: 16Photo/image fields directly on objects
DocumentfieldType: 13Binary files on the Attachments object (or other objects)
💡

Many integrations use the Attachments object: a reference field (fieldType: 5) on your object points to attachment rows that store the actual file (fieldType: 13). The attachments object API name is often Attachment but can be site-specific—confirm with get_objects() / get_fields().

Key Methods

MethodDescription
download_file() / download_attachment()Download binary by entry_id and field_id (aliases; no object_id in the download URL)
download_attachment_metadata()Metadata for a file field via the row/query path (needs object_id, entry_id, field_id)
upload_attachment()Create a new attachment row with multipart upload (bytes + filename)
upload_file_to_entry_field()Put bytes onto an existing row’s IMAGE or BINARY field
delete_file() / delete_attachment()Remove file content (entry_id, field_id)
export_images() / export_documents() / export_files()Bulk export with optional filters
export_entry_files() / export_attachments()Entry- or attachment-scoped exports

Quick Examples

Download a File

from dealcloud_sdk import DealCloud, DealCloudConfig
 
config = DealCloudConfig(
    siteUrl="yoursite.dealcloud.com",
    clientId=12345,
    clientSecret="your-secret",
)
dc = DealCloud.from_config_object(config)
 
# Bytes in memory (API: entryfiles/{entryId}/fields/{fieldId})
content = dc.download_file(entry_id=12345, field_id="File")
 
# Or stream to disk (preferred for large files)
path = dc.download_file(
    entry_id=12345,
    field_id="File",
    output_path="./document.pdf",
)

Upload a New Attachment Row

Use upload_attachment() with the attachments object API name (often "Attachment"), file bytes, and filename:

from pathlib import Path
 
path = Path("contract.pdf")
result = dc.upload_attachment(
    "Attachment",
    path.read_bytes(),
    path.name,
    content_type="application/pdf",
)
entry_id = result["entry_id"]
field_id = result["document_field_id"]

Upload Onto an Existing Image or Binary Field

from pathlib import Path
 
p = Path("logo.png")
dc.upload_file_to_entry_field(
    "Company",
    12345,
    "Logo",
    p.read_bytes(),
    p.name,
    content_type="image/png",
)

Bulk Export

result = dc.export_images(
    "./backup/logos",
    object_id="Company",
    field_ids=["Logo"],
)
print(f"Exported {result.exported} images")

Attachments System

Typical pattern:

  1. Upload a new file with upload_attachment() (or create the row with insert_data() then upload_file_to_entry_field()).
  2. Link the parent’s reference field to the attachment entry_id with update_data() / write_cells() as appropriate.
# New attachment + link (conceptual; field API names vary by site)
result = dc.upload_attachment(
    "Attachment",
    open("contract.pdf", "rb").read(),
    "contract.pdf",
    content_type="application/pdf",
)
attachment_id = result["entry_id"]
 
dc.update_data("Deal", [{"EntryId": deal_id, "Contract": attachment_id}])

File Metadata

Get file information without downloading the bytes:

info = dc.download_attachment_metadata(
    object_id="Attachment",
    entry_id=12345,
    field_id="File",
)
 
print(info.get("fileName"), info.get("fileSize"), info.get("contentType"))

Related