Skip to main content

BlobElementsApi

Upload and download binary file elements (blobs) in Onshape documents.

blob_api = client.blob_elements

Base path: /api/v6/blobelements

Methods

download

Download the contents of a blob element.

blob_elements.download(did: str, wvm: str, wvm_id: str, eid: str) -> bytes

Handles the S3 redirect that Onshape uses for binary content.

data = client.blob_elements.download(did, "w", wid, eid)
with open("downloaded_file.pdf", "wb") as f:
f.write(data)
print(f"Downloaded {len(data)} bytes")

upload

Upload a local file as a new blob element in a document.

blob_elements.upload(
did: str, wid: str,
file_path: str,
content_type: str | None = None
) -> dict
ParameterTypeDefaultDescription
didstrrequiredDocument ID
widstrrequiredWorkspace ID
file_pathstrrequiredPath to local file
content_typestrNoneMIME type (auto-detected from extension if omitted)
result = client.blob_elements.upload(
did, wid,
file_path="reference.pdf",
content_type="application/pdf",
)
print(f"Created element: {result}")
Workspace Only

Upload only works on workspaces (w), not versions or microversions.