Skip to main content
Glama

get_document_download_link

Generate a download link for SignNow documents or document groups using the document ID to access completed or signed files.

Instructions

Get download link for a document or document group

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
entity_idYesID of the document or document group
entity_typeNoType of entity: 'document' or 'document_group' (optional). If you're passing it, make sure you know what type you have. If it's not found, try using a different type.

Implementation Reference

  • MCP tool handler for 'get_document_download_link'. Handles input parameters (with schema), retrieves token, initializes client, and delegates to helper function _get_document_download_link.
    @mcp.tool(name="get_document_download_link", description="Get download link for a document or document group", tags=["document", "document_group", "download", "link"]) def get_document_download_link( ctx: Context, entity_id: Annotated[str, Field(description="ID of the document or document group")], entity_type: Annotated[ Literal["document", "document_group"] | None, Field(description="Type of entity: 'document' or 'document_group' (optional). If you're passing it, make sure you know what type you have. If it's not found, try using a different type."), ] = None, ) -> DocumentDownloadLinkResponse: """Get download link for a document or document group. For documents: Returns direct download link. For document groups: Merges all documents in the group and returns download link for the merged document. Args: entity_id: ID of the document or document group entity_type: Type of entity: 'document' or 'document_group' (optional). If you're passing it, make sure you know what type you have. If it's not found, try using a different type. Returns: DocumentDownloadLinkResponse with download link """ headers = get_http_headers() token = token_provider.get_access_token(headers) if not token: raise ValueError("No access token available") # Initialize client and use the imported function from document_download_link module client = SignNowAPIClient(token_provider.signnow_config) return _get_document_download_link(entity_id, entity_type, token, client)
  • Helper function implementing the core logic: auto-detects entity type if needed, handles document groups by merging documents if multiple, and retrieves download links via client.
    def _get_document_download_link(entity_id: str, entity_type: Literal["document", "document_group"] | None, token: str, client: SignNowAPIClient) -> DocumentDownloadLinkResponse: """Private function to get download link for a document or document group. Args: entity_id: ID of the document or document group entity_type: Type of entity: 'document' or 'document_group' (optional). If you're passing it, make sure you know what type you have. If it's not found, try using a different type. token: Access token for SignNow API client: SignNow API client instance Returns: DocumentDownloadLinkResponse with download link """ # Determine entity type if not provided document_group = None # Store document group if found during auto-detection if not entity_type: # Try to determine entity type by attempting to get document group first (higher priority) try: document_group = client.get_document_group(token, entity_id) entity_type = "document_group" except Exception: # If document group not found, try document try: client.get_document(token, entity_id) entity_type = "document" except Exception: raise ValueError(f"Entity with ID {entity_id} not found as either document group or document") from None if entity_type == "document_group": # For document group, we need to merge all documents first # Get the document group if we don't have it yet if not document_group: document_group = client.get_document_group(token, entity_id) # Extract document IDs from the group document_ids = [doc.id for doc in document_group.documents] if not document_ids: raise ValueError(f"Document group {entity_id} contains no documents") # If only one document, just get its download link directly if len(document_ids) == 1: response = client.get_document_download_link(token, document_ids[0]) return DocumentDownloadLinkResponse(link=response.link) # Merge all documents in the group merge_request = MergeDocumentsRequest(name=document_group.group_name, document_ids=document_ids, upload_document=True) merge_response = client.merge_documents(token, merge_request) # Get download link for the merged document response = client.get_document_download_link(token, merge_response.document_id) return DocumentDownloadLinkResponse(link=response.link) else: # For single document, just get its download link response = client.get_document_download_link(token, entity_id) return DocumentDownloadLinkResponse(link=response.link)
  • SignNow API client method that performs the actual HTTP POST request to the SignNow API endpoint /document/{document_id}/download/link to generate the download link.
    def get_document_download_link(self, token: str, document_id: str) -> DocumentDownloadLinkResponse: """ Get download link for a document. This endpoint generates a download link for a specific document. Args: token: Access token for authentication document_id: ID of the document to download Returns: Validated DocumentDownloadLinkResponse model with the download link """ headers = {"Accept": "application/json", "Content-Type": "application/json", "Authorization": f"Bearer {token}"} return self._post(f"/document/{document_id}/download/link", headers=headers, validate_model=DocumentDownloadLinkResponse)
  • Input schema definitions using Pydantic Field and typing.Annotated for the tool parameters.
    entity_id: Annotated[str, Field(description="ID of the document or document group")], entity_type: Annotated[ Literal["document", "document_group"] | None, Field(description="Type of entity: 'document' or 'document_group' (optional). If you're passing it, make sure you know what type you have. If it's not found, try using a different type."), ] = None, ) -> DocumentDownloadLinkResponse:
  • MCP tool registration decorator specifying name, description, and tags.
    @mcp.tool(name="get_document_download_link", description="Get download link for a document or document group", tags=["document", "document_group", "download", "link"])

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mihasicehcek/sn-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server