Office 365 Integration

Ghost RPA can read and write to Excel workbooks hosted on OneDrive or SharePoint using the Microsoft Graph API. This guide walks you through registering an Azure app, connecting your Microsoft account, and preparing your online spreadsheet.

Time required: About 10–15 minutes for first-time setup. After that, connecting a new workbook takes seconds.
Same data tokens, different cloud. Office 365 uses the exact same column layout and data tokens ({{EMAIL}}, {{PHONE}}, etc.) as Google Sheets — the only difference is the authentication provider and where the file lives.

Prerequisites

  • A Microsoft account (personal, work, or school)
  • Access to the Azure Portal (free — no Azure subscription needed)
  • An Excel workbook stored on OneDrive or SharePoint
  • Ghost RPA installed and running on your PC

Step 1 — Register an Azure App

Ghost RPA needs an Azure "App registration" to authenticate with Microsoft. You create this once in the Azure Portal.

  1. Go to Azure Portal → App registrations and sign in with your Microsoft account.
  2. Click + New registration.
  3. Fill in the Name — for example GHOST RPA.
  4. Under Supported account types, select Any Entra ID Tenant + Personal Microsoft accounts (this is the broadest option — works for personal, work, and school accounts).
  5. Under Redirect URI (optional), select Mobile and desktop applications from the dropdown and enter:
    http://localhost
    (Ghost RPA listens on a random local port during sign-in — Microsoft ignores the port when http://localhost is registered.)
  6. Click Register at the bottom of the page.
No Azure subscription required. App registrations are free. You only need a Microsoft account that can sign in to the Azure Portal.
Azure Portal — New App Registration form with name Ghost RPA and redirect URI set to http://localhost

Step 2 — Copy Application (Client) ID

After registration, Azure takes you to the app's Overview page. You need one value from here:

  1. Copy the Application (client) ID — a UUID like a1b2c3d4-e5f6-7890-abcd-ef1234567890.
  2. Optionally, note the Directory (tenant) ID if you want to restrict sign-in to a specific organization. For most users, leave this as the default (organizations) which allows any Microsoft account.
Keep your Client ID safe. Do not share it publicly. While it's not a secret on its own, it identifies your app registration.
Azure App Registration Overview — Application (client) ID and Directory (tenant) ID highlighted

Step 3 — Set API Permissions

Your app needs permission to access OneDrive files and Excel workbooks through Microsoft Graph.

  1. In your app registration, go to API permissions in the left sidebar.
  2. Click + Add a permission → Microsoft Graph → Delegated permissions.
  3. Search for and add these permissions:
    • User.Read — Sign in and read user profile
    • Files.ReadWrite — Read and write user files
    • Sites.ReadWrite.All — Read and write items in SharePoint sites
    • offline_access — Maintain access to data (for token refresh)
  4. Click Add permissions.
Admin consent not required. These are delegated permissions — the user grants them when signing in. You do not need an Azure admin to approve.
Azure API permissions — User.Read, Files.ReadWrite, Sites.ReadWrite.All, and offline_access added

Step 4 — Configure in Ghost RPA

Now paste your Azure app credentials into Ghost RPA so it can connect to your Microsoft account.

  1. Open Ghost RPA and go to Settings (gear icon in the sidebar).
  2. Scroll down to Sheet Connections and find the Office 365 card.
  3. Click "Set up the OAuth client" to expand the configuration form.
  4. Paste your Application (client) ID from Step 2.
  5. If you noted a specific Tenant ID, enter it in the Tenant field. Otherwise, leave it as organizations (the default — works for any Microsoft account).
  6. Click Save client. You'll see a confirmation message.
Ghost RPA Settings — Office 365 card expanded with Client ID and Tenant fields, Save client button

Step 5 — Connect Your Microsoft Account

With the app credentials configured, you can now authorize Ghost RPA to access your OneDrive files.

  1. On the Office 365 card, click the Connect button.
  2. Your default browser will open to Microsoft's sign-in page. Sign in with the Microsoft account that has access to your OneDrive workbook.
  3. Review the permissions and click Accept to grant Ghost RPA access.
  4. The browser will show a success message. Go back to Ghost RPA — the card now shows "Connected" with your account.
Microsoft sign-in — Permissions requested by Ghost RPA, with Accept button
Per-workspace connection. Each workspace has its own Microsoft account connection. If you have multiple workspaces, connect each one separately from its settings.

Step 6 — Prepare Your Excel Workbook

Your Excel workbook on OneDrive needs the same column structure as Google Sheets so the engine can read data and write results.

Create the workbook

  1. Go to OneDrive or office.com and create a new Excel workbook (or upload an existing .xlsx file).
  2. Name the first sheet tab Sheet1 (exact spelling, case-sensitive).

Column layout

The first three columns (A, B, C) are reserved by the engine. Your data columns start from column D onward.

ColumnHeaderPurposeWho writes
ASTATUSRun result — "success", "failure", or custom statusEngine
BRUNNER_IDWhich runner processed this rowEngine
CUsedTsTimestamp when the row was usedEngine
D+Your headersData columns — EMAIL, FIRST_NAME, LAST_NAME, PHONE, ADDRESS, etc.You
Excel Online workbook with proper column layout — STATUS, RUNNER_ID, UsedTs, USED_URL, FIRST_NAME, LAST_NAME, EMAIL, PHONE, ADDRESS, CITY, STATE, ZIP

Example sheet

Here's what a typical workbook looks like before a run:

STATUSRUNNER_IDUsedTsEMAILFIRST_NAMELAST_NAMEPHONE
john@example.comJohnSmith5551234567
jane@example.comJaneDoe5559876543

After a run, the engine fills in STATUS, RUNNER_ID, and UsedTs for each processed row. Rows with an existing STATUS are skipped (already done).

Optional: Sheet2 (VCC / Billing)

If your workflow involves Virtual Credit Card (VCC) billing, add a second tab named Sheet2. The engine uses this for billing-specific status writes (vcc_sheet_status action). If you don't use VCC, you can skip this tab.

Optional columns

HeaderPurpose
COMMENT or COMMENTSThe sheet_comment action writes here
USED_URLThe URL that was opened for this row

Ghost RPA needs the OneDrive sharing URL to locate your workbook via the Microsoft Graph API.

  1. Open your workbook in OneDrive or Excel Online.
  2. Click the Share button at the top-right corner.
  3. Click Copy link to get the sharing URL. It looks something like:
    https://1drv.ms/x/s!AmXeZ... or https://onedrive.live.com/edit.aspx?...
Same account = automatic access. If you're signed in to Ghost RPA with the same Microsoft account that owns the workbook, Ghost RPA can access it directly — no extra sharing needed. The sharing link is only used to identify which workbook to open.
OneDrive — Share dialog with Copy link button highlighted

Finally, tell your script which workbook to use by adding the sharing URL and setting the sheet type to office365.

JSON
{
  "sheet": {
    "type": "office365"
  },
  "sources": {
    "office365_sheet_url": "https://1drv.ms/x/s!AmXeZ..."
  }
}
Type aliases: You can also use o365, ms, microsoft, or excel_online as the sheet type — they all map to the same Office 365 driver.

That's it — your Office 365 workbook is now connected and ready to use. When you run the script, the engine will read rows from Sheet1 and write results back automatically through the Microsoft Graph API.

How It Works at Runtime

When a run starts, the engine:

  1. Authenticates with Microsoft using MSAL (Microsoft Authentication Library) and your stored token.
  2. Resolves the sharing URL to a OneDrive drive ID and item ID, then creates a persistent workbook session for performance.
  3. Reads all rows from Sheet1 and picks rows where the STATUS column is empty (not yet processed).
  4. For each profile, assigns a row and writes the RUNNER_ID and UsedTs to claim it.
  5. Runs the script actions — data tokens like {{EMAIL}}, {{PHONE}} etc. pull values from that row's columns.
  6. After completing (or failing), writes the final STATUS and optional COMMENT back to the row.
Built-in reliability. The Office 365 driver includes session healing (auto-recreates expired workbook sessions), token refresh (silently renews expired access tokens), rate-limit handling (respects Retry-After headers), and a per-workbook write gate to prevent concurrent write conflicts.

Troubleshooting

Missing tenant_id or client_id

Error: office365: missing tenant_id/client_id in uploads/office365.json

Fix: Go to Settings → Sheet Connections → Office 365 and enter your Application (client) ID from Step 2. Click Save client, then try connecting again.

Failed to get access token

Error: office365: failed to get access token

Fix: Click Connect on the Office 365 card in Settings. If the browser window doesn't appear, check that the Redirect URI in your Azure app registration is set to http://localhost (under Mobile and desktop applications platform). Microsoft ignores the port number.

Failed to resolve sharing URL

Error: office365: failed to resolve sharing URL to driveItem

Fix: Double-check the office365_sheet_url in your script JSON. Make sure you copied the full sharing link from OneDrive. The file must be accessible to the Microsoft account you connected.

Sheet1 tab not found

Fix: Rename the first tab in your workbook to exactly Sheet1 (case-sensitive). Excel Online sometimes defaults to locale-specific names.

Missing STATUS or RUNNER_ID columns

Error: office365: missing STATUS/RUNNER_ID columns

Fix: Make sure Row 1 of Sheet1 has STATUS in column A and RUNNER_ID in column B. The engine needs these headers to claim and track rows.

Token expired / Disconnected

MSAL tokens can expire if unused for a long time or if you revoke access from your Microsoft account security settings.

Fix: Go to Settings → Sheet Connections → Office 365 and click Connect again to re-authorize.

Throttle errors (429)

Microsoft Graph has rate limits. Ghost RPA automatically handles 429 Too Many Requests responses by respecting the Retry-After header and backing off.

Fix: The engine handles this automatically. If it persists, reduce the number of concurrent threads or wait a few minutes.

Workbook session expired

Persistent workbook sessions expire after ~5 minutes of inactivity. Ghost RPA detects this and automatically recreates the session.

Fix: No action needed — this is handled automatically. If you see repeated session errors, check your network connection and make sure the workbook is not locked by another application.