View Categories

Backing up documents from Legale.io to an external repository using Legale.io APIs

Overview #

This guide outlines the complete process for backing up documents from Legale.io to an external repository using the Legale.io API. It assumes the external repository is capable of receiving and storing files via HTTPS requests or another integration pipeline.

Two main approaches are described:

  1. Custom Script-Based Integration with any external repository (e.g., S3, Google Drive, etc.)
  2. No-Code Integration using SharePoint and Power Automate

Prerequisites #

  • A valid Legale.io API token with permissions to access documents and signatures
  • Access to an external repository (e.g., SharePoint, AWS S3, Google Drive, or a custom endpoint)
  • Server or script execution environment (e.g., Node.js, Python, Bash) or Power Automate access

Option 1: Custom script-based backup (All Repositories) #

Step 1: List all documents #

Endpoint: GET /v1/document/all

Documentation: List Documents

Action:
Call this endpoint to retrieve a list of all documents available for the authenticated user.

Example Request:

GET https://api.legale.io/v1/document/all
Authorization: Bearer YOUR_API_TOKEN

Step 2: Get detailed information for each document #

Endpoint: GET /v1/document/{document_id}

Documentation: Document Detail

Action:
Retrieve full document details using the ID.

Step 3: Confirm signature status #

Endpoint: GET /v1/sign/status/{document_id}

Documentation: Signature Status

Action:
Ensure all required parties have signed before backup.

Step 4: Download the signed document #

Endpoint: GET /v1/sign/download/{document_id}

Documentation: Download Signed Document

Action:
Download the signed PDF file.

Step 5: Upload to external repository #

Example (SharePoint via Graph API):

PUT https://graph.microsoft.com/v1.0/sites/{site-id}/drives/{drive-id}/items/{parent-id}:/{file-name}.pdf:/content
Authorization: Bearer YOUR_MICROSOFT_GRAPH_TOKEN
Content-Type: application/pdf

<binary pdf content>

Step 6: Archive Metadata (Optional) #

Store metadata alongside the file (title, ID, signers, etc.)


Option 2: No-Code backup using Power Automate and SharePoint #

Step 1: Create a Power Automate flow #

  1. Go to Power Automate
  2. Create a new Automated cloud flow
  3. Set a trigger, such as a scheduled recurrence or HTTP request received

Step 2: Configure HTTP request to Legale.io #

  1. Add an HTTP action to call GET https://api.legale.io/v1/document/all
  2. Set the method to GET, and add the header:
    Authorization: Bearer YOUR_API_TOKEN
    
  3. Parse the JSON response and loop through documents

Step 3: Confirm signature status (Optional) #

  1. Add a HTTP action to call GET /v1/sign/status/{document_id} for each document
  2. Check if signatures are complete before continuing

Step 4: Download and upload to SharePoint #

  1. Add an HTTP action to call GET /v1/sign/download/{document_id}
  2. Use a Create file action in SharePoint to upload the binary content:
    • Site Address: your SharePoint site
    • Folder Path: target backup folder
    • File Name: dynamic content from document
    • File Content: body from download step

Step 5: Log metadata #

Optionally add metadata to SharePoint columns or store as a companion .json file


Final recommendations #

  • Automate the backup process using a scheduled job or Power Automate schedule
  • Apply retry logic for transient API errors (with Do Until loops in Power Automate or try-catch in scripts)
  • Monitor API usage limits and maintain secure token storage
  • Always verify signature completion before backup

Powered by BetterDocs

Scroll to Top