OneDrive
OneDrive connects through Microsoft Graph when a user signs in with their Microsoft work or school account (OAuth 2.0), through Truto's Microsoft app or your own. Truto can also tell you when anything in a connected drive changes.
Install the OneDrive integration
Install OneDrive from Available integrations in each environment you connect accounts from.
Use your own OneDrive OAuth app (optional)
Truto ships a OneDrive OAuth app, so OAuth 2.0 works without any setup. To show your own app on the consent screen instead, register an app in Microsoft Entra ID that allows accounts in any organizational directory, register the redirect URL below, and set the app's Client ID and Client Secret on the installed integration. See Overriding OAuth credentials.
https://api.truto.one/connect/onedrive/callbackIf you use a redirect URL on your own domain, register that URL instead.
By default, Truto asks OneDrive for these scopes. The Connect UI lists them under Permissions required, and you can change them when you override the OAuth credentials.
emailoffline_accessopenidprofilehttps://graph.microsoft.com/Files.Read.Allhttps://graph.microsoft.com/Files.ReadWrite.Allhttps://graph.microsoft.com/User.Readhttps://graph.microsoft.com/User.Read.Allhttps://graph.microsoft.com/Directory.Read.All
Enable the same scopes on your app. If your app allows fewer, change the list under Use your own OAuth settings → Scopes on the installed integration's Configuration tab to match.
Connect a OneDrive account
- In Integrated Accounts, click Connect Account.

- Enter a Tenant ID (your customer's ID; Truto creates the tenant if it is new), or pick one under Existing tenant (optional). Check the Environment and the Region (where Truto places the account; Western North America by default). To open the link straight on OneDrive, pick it under Advanced settings → Integration (optional). Click Get connection link.

- Click the open-in-new-tab button, or click Copy and send the link to your customer so they connect their own OneDrive account. The link works for 7 days, until an account is connected with it.

- Click Get Started if it shows, then select OneDrive.
- Sign in with a Microsoft account and allow access. Only work or school accounts can sign in.
User.Read.AllandDirectory.Read.Allneed an administrator's consent, so an admin may have to approve the app first. - Close the tab when you see Connection successful. The new account appears under Integrated Accounts. Click its Account ID to see its details and make API calls.
Get notified when a drive changes
Microsoft Graph tells Truto when anything in a watched drive changes, and Truto sends a record:updated event to your webhooks. The event says which drive changed, not what changed; call track to fetch the changes.
-
Install the File Storage Unified API in the same environment. Truto turns OneDrive notifications into
record:*events only through it. -
Create a Truto webhook subscribed to
record:updatedandrecord:meta(orall). -
Store a webhook secret on the integrated account, a random string of up to 128 characters. Truto sends it to Microsoft with the subscription and rejects every notification that doesn't carry it, so without a secret no events arrive.
curl -X PATCH https://api.truto.one/integrated-account/<integrated_account_id>/credentials \ -H "Authorization: Bearer $TRUTO_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{"context": {"webhook_secret": "<random string>"}}' -
Find the drive's ID with
GET /unified/file-storage/drives?integrated_account_id=<integrated_account_id>, then create the subscription:curl -X POST "https://api.truto.one/unified/file-storage/webhook-subscriptions?integrated_account_id=<integrated_account_id>" \ -H "Authorization: Bearer $TRUTO_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "notification_url": "https://api.truto.one/integrated-account-webhook/<integrated_account_id>", "drive": { "id": "<drive_id>" } }'The subscription watches the whole drive. Microsoft lets it live at most 42,300 minutes (about 29 days); read
expirationfrom the response. Becausenotification_urlpoints at Truto, Truto also receives Microsoft's renewal notices, renews the subscription for you and sends arecord:metaevent. -
Each
record:updatedevent hasresourcefile-storage/drive-itemsand a record whosedrive.idnames the drive that changed. Calltrackfor that drive with the lastsync_tokenyou stored:curl -g -X POST "https://api.truto.one/unified/file-storage/drive-items/track?integrated_account_id=<integrated_account_id>&drive[id]=<drive_id>&sync_token=<sync_token>" \ -H "Authorization: Bearer $TRUTO_API_TOKEN"Every record carries the
sync_tokento send next andhas_more. Keep calling whilehas_moreistrue, and store the newestsync_token. Deleted items come back withdeleted: true. Leave outsync_tokento list every item in the drive, or passlatestto start from now. Microsoft may send more than one notification for one change, so treat each event as "calltrack".
To stop, call DELETE /unified/file-storage/webhook-subscriptions/<subscription_id>?integrated_account_id=<integrated_account_id>. See Receiving vendor webhooks for the event format.