SharePoint Integration Guide

Complete guide to integrating Microsoft SharePoint / OneDrive through LawLink.ai

☁️ SharePoint & OneDrive for Business
🚀

Integration Steps

Follow these steps to integrate your application with Microsoft SharePoint through LawLink.ai.

Create Organization Admin & Login

A Superuser or Admin creates an Organization Admin (ORG_ADMIN) account for your law firm. The ORG_ADMIN manages users and API tokens.

💡 Tip: Login to LawLink at https://app.lawlink.ai using your ORG_ADMIN credentials.

Create API Access Token

Navigate to API Tokens and create a new access token. Set an appropriate expiration period. Copy the token immediately — it is only shown once.

⚠️ Important: Store your API token securely. It grants access to all users in your organization.

Add User Accounts

As an ORG_ADMIN, navigate to the Organization page and add user accounts. Each user will have their own Microsoft OAuth connection.

📋 Fields Required: Email, Full Name, Password. Users are automatically assigned the USER role.

🔐

Authentication

Authorize Microsoft / SharePoint Access

Each user must authorize LawLink to access their Microsoft account (SharePoint / OneDrive). Call /authorize to obtain the Microsoft OAuth URL, redirect the user, and LawLink will handle the token exchange on callback.

Step 1 — Get the Authorization URL

# Initiate Microsoft OAuth flow curl.exe -X GET \ "https://app.lawlink.ai/api/v1/sharepoint/authorize" \ -H "Authorization: Bearer ACCESS_TOKEN"
{ "url": "https://login.microsoftonline.com/common/oauth2/v2.0/authorize?..." }

🔐 OAuth Flow: Redirect the user to the returned URL. Microsoft authenticates the user and calls LawLink's callback automatically. The user is then redirected to the Drive Picker page.

Check Connection Status

# Check if user has an active SharePoint connection curl.exe -X GET \ "https://app.lawlink.ai/api/v1/sharepoint/status" \ -H "Authorization: Bearer ACCESS_TOKEN"
{ "connected": true }

Disconnect SharePoint

# Revoke the SharePoint connection curl.exe -X DELETE \ "https://app.lawlink.ai/api/v1/sharepoint/disconnect" \ -H "Authorization: Bearer ACCESS_TOKEN"
💾

Drive Picker

List & Select a Drive

After OAuth, the user must select which drive to work with: their personal OneDrive for Business (My Drive) or a SharePoint site drive. The selection is persisted and used for all subsequent file/folder operations.

🗂️ Drive Types:

  • My Drive — personal OneDrive for Business (/me/drive)
  • SharePoint Site Drive — a document library on a SharePoint site (/sites/{site-id}/drive)

List Available Drives

# Fetch all drives the user can connect to curl.exe -X GET \ "https://app.lawlink.ai/api/v1/sharepoint/drives" \ -H "Authorization: Bearer ACCESS_TOKEN"
{ "drives": [ { "id": "b!abc...", "name": "OneDrive", "drive_base_url": "/me/drive", "type": "personal" }, { "id": "b!xyz...", "name": "Legal Documents", "drive_base_url": "/sites/contoso.sharepoint.com,abc/drive", "type": "documentLibrary" } ] }

Select a Drive

# Persist the chosen drive for all future operations curl.exe -X POST \ "https://app.lawlink.ai/api/v1/sharepoint/drives/select" \ -H "Authorization: Bearer ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "drive_base_url": "/me/drive" }'
{ "status": "success", "drive_base_url": "/me/drive" }
📄

File Operations

Full file lifecycle: list, search, upload, download, move, copy, and delete. All item IDs are opaque Microsoft Graph IDs (e.g. 01ABC...), not paths.

1. List & Search Files

List files in a folder by parent_id, or search across the entire drive with query. Omit parent_id to list the root.

# List files in the root of the selected drive curl.exe -X GET \ "https://app.lawlink.ai/api/v1/sharepoint/files?limit=25" \ -H "Authorization: Bearer ACCESS_TOKEN" # Search across the drive curl.exe -X GET \ "https://app.lawlink.ai/api/v1/sharepoint/files?query=retainer&limit=25" \ -H "Authorization: Bearer ACCESS_TOKEN"
{ "items": [ { "id": "01ABCDE...", "name": "Retainer_Agreement.pdf", "size": 204800, "lastModifiedDateTime": "2026-04-01T10:00:00Z", "webUrl": "https://contoso.sharepoint.com/..." } ] }

2. Upload a File

Send a multipart/form-data POST. Files larger than 4 MB automatically use a Microsoft Graph upload session (chunked upload) — this is handled transparently.

⚠️ Overwrite: Set overwrite=true to replace an existing file with the same name. Default is false (rename on conflict).

# Upload a file to the drive root curl.exe -X POST \ "https://app.lawlink.ai/api/v1/sharepoint/files/upload" \ -H "Authorization: Bearer ACCESS_TOKEN" \ -F "file=@Retainer_Agreement.pdf" \ -F "overwrite=false" # Upload into a specific folder curl.exe -X POST \ "https://app.lawlink.ai/api/v1/sharepoint/files/upload" \ -H "Authorization: Bearer ACCESS_TOKEN" \ -F "file=@Contract.pdf" \ -F "parent_id=01ABCDE..."
{ "id": "01FGHIJ...", "name": "Contract.pdf", "size": 102400, "webUrl": "https://contoso.sharepoint.com/..." }

3. Download a File

Returns the file content base64-encoded. Maximum file size is 50 MB.

# Download a file by item ID curl.exe -X GET \ "https://app.lawlink.ai/api/v1/sharepoint/files/download?item_id=01ABCDE..." \ -H "Authorization: Bearer ACCESS_TOKEN"
{ "name": "Contract.pdf", "content_base64": "JVBERi0xLjQK...", "size": 102400 }

4. Move, Copy & Delete Files

Move or copy a file by supplying its item_id, the target new_parent_id, and an optional new_name. Copy returns 202 Accepted with a monitor_url to poll for completion.

# Move a file to a new folder curl.exe -X POST \ "https://app.lawlink.ai/api/v1/sharepoint/files/move" \ -H "Authorization: Bearer ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "item_id": "01ABCDE...", "new_parent_id": "01XYZAB...", "new_name": "Contract_FINAL.pdf" }' # Copy a file curl.exe -X POST \ "https://app.lawlink.ai/api/v1/sharepoint/files/copy" \ -H "Authorization: Bearer ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "item_id": "01ABCDE...", "new_parent_id": "01XYZAB..." }' # Delete a file curl.exe -X POST \ "https://app.lawlink.ai/api/v1/sharepoint/files/delete" \ -H "Authorization: Bearer ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "item_id": "01ABCDE..." }'

🗑️ Deletion: SharePoint deletion is permanent for files not in a Recycle Bin-enabled library. Verify your site settings before deleting.

📁

Folder Operations

Create, list, move, and delete folders. All operations use Microsoft Graph item IDs.

1. List Folders

List sub-folders inside a parent folder. Omit parent_id to list root folders.

# List folders at the root of the drive curl.exe -X GET \ "https://app.lawlink.ai/api/v1/sharepoint/folders?limit=50" \ -H "Authorization: Bearer ACCESS_TOKEN"
{ "items": [ { "id": "01FOLDER...", "name": "Contracts", "childCount": 12 }, { "id": "01FOLDER2...", "name": "Correspondence", "childCount": 5 } ] }

2. Create a Folder

Create a new folder. Optionally specify a parent_id to nest it inside an existing folder; omit to create at the root.

# Create a folder at the root curl.exe -X POST \ "https://app.lawlink.ai/api/v1/sharepoint/folders" \ -H "Authorization: Bearer ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "2026 Cases" }'
{ "id": "01NEWFOLDER...", "name": "2026 Cases" }

3. Move & Delete Folders

Move a folder by supplying its item_id and the target new_parent_id. Delete removes the folder and all contents.

# Move a folder curl.exe -X POST \ "https://app.lawlink.ai/api/v1/sharepoint/folders/move" \ -H "Authorization: Bearer ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "item_id": "01FOLDER...", "new_parent_id": "01PARENT..." }' # Delete a folder (and all contents) curl.exe -X POST \ "https://app.lawlink.ai/api/v1/sharepoint/folders/delete" \ -H "Authorization: Bearer ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "item_id": "01FOLDER..." }'