About Exchange Online
Exchange Online is Microsoft’s cloud-based email and calendaring service, part of Microsoft 365. Connecting Exchange Online to Serval enables automated mailbox management, distribution group operations, and Exchange administration directly from your service desk workflows.What the Exchange Online integration enables
| Capability | Description |
|---|---|
| Mailbox Management | Get and configure mailbox settings for users |
| Distribution Groups | Create, modify, and remove distribution groups and their members |
| Custom Commands | Run arbitrary Exchange Online PowerShell commands via Serval |
Azure AD Configuration
Prerequisites
- You must have Global Administrator or Application Administrator access to your Azure AD tenant
- You must know your Microsoft 365 tenant domain (e.g.,
contoso.onmicrosoft.com)
1. Create an App Registration
- Log in to the Azure Portal
- Navigate to Azure Active Directory → App registrations
- Click New registration
- Enter a name (e.g., “Serval Exchange Online”)
- Set Supported account types to “Accounts in this organizational directory only”
- Leave Redirect URI blank
- Click Register
- Copy the Application (client) ID and Directory (tenant) ID from the Overview page
2. Create Credentials (Client Secret or Certificate)
Serval supports two authentication methods for Exchange Online. Choose the one that fits your security requirements:Option A: Client Secret
- In your app registration, go to Certificates & secrets
- Click New client secret
- Enter a description (e.g., “Serval”) and select an expiration period
- Click Add
- Copy the secret value immediately — it won’t be shown again
Option B: Certificate
- Generate a self-signed certificate:
- In your app registration, go to Certificates & secrets → Certificates tab
- Click Upload certificate and upload
cert.pem(the certificate only, not the private key) - Keep
combined.pem— you’ll paste its contents into Serval during configuration
3. Add API Permissions
- In your app registration, go to API permissions
- Click Add a permission
- Select APIs my organization uses
- Search for Office 365 Exchange Online and select it
- Select Application permissions
- Check Exchange.ManageAsApp
- Click Add permissions
- Click Grant admin consent for [your organization]
4. Assign the Exchange Administrator Role
The app registration’s service principal must be assigned the Exchange Administrator role in Azure AD:- In the Azure Portal, navigate to Azure Active Directory → Roles and administrators
- Search for and click Exchange Administrator
- Click Add assignments
- Search for your app registration name (e.g., “Serval Exchange Online”)
- Select the service principal and click Add
Without the Exchange Administrator role, the app will be able to authenticate
but will not have permission to run Exchange Online cmdlets.
5. Register the Service Principal in Exchange Online
Azure AD authentication alone is not enough — you must also register the app as a service principal directly in Exchange Online. This is a one-time setup that requires PowerShell.- Install the Exchange Online PowerShell module (if not already installed):
- Connect as an Exchange admin:
- Get your app’s Enterprise Application Object ID from the Entra admin center → Identity → Applications → Enterprise Applications → search for your app → copy the Object ID.
- Register the service principal in Exchange Online:
- Assign a management role. For full Exchange management access:
| Role | Enables |
|---|---|
| Mail Recipients | Get-Mailbox, Set-Mailbox |
| Distribution Groups | Distribution group management |
| View-Only Configuration | Get-OrganizationConfig |
- Disconnect:
Exchange Online caches permissions for up to 30 minutes. If actions fail with
“UnAuthorized” immediately after setup, wait and retry.
Serval Configuration
- In Serval, navigate to Apps → Available → Exchange Online → Connect
-
Enter the following information:
Field Description App (Client) ID The Application (client) ID from your Azure AD app registration Tenant (Directory) ID The Directory (tenant) ID from your Azure AD app registration Organization Your Microsoft 365 tenant domain (e.g., contoso.onmicrosoft.com)Authentication Method Choose Client Secret or Certificate (PEM) Client Secret The client secret value (shown when Client Secret is selected) Certificate (PEM) The combined cert + private key PEM contents (shown when Certificate is selected) Instance Name (Optional) A friendly name to identify this connection - Click Save
.onmicrosoft.com.
If using certificate authentication, paste the full contents of combined.pem (both the BEGIN CERTIFICATE and BEGIN PRIVATE KEY blocks) into the Certificate (PEM) field.
You should now be able to build workflows that manage Exchange Online
mailboxes, distribution groups, and run Exchange PowerShell commands.
How It Works
The Exchange Online integration uses PowerShell under the hood. When a workflow runs an Exchange Online action: Client Secret authentication:- Serval acquires an OAuth access token using your app’s client credentials
- The token is passed to
Connect-ExchangeOnlinein a secure PowerShell session - The requested Exchange cmdlet is executed
- Results are returned to your workflow
- Serval retrieves the stored certificate and private key
- PowerShell loads the certificate and authenticates directly with Azure AD using
Connect-ExchangeOnline -Certificate - The requested Exchange cmdlet is executed
- Results are returned to your workflow
Troubleshooting
”AADSTS7000215: Invalid client secret”
The client secret may have expired or been entered incorrectly:- Verify the secret hasn’t expired in Azure AD → App registrations → Certificates & secrets
- Generate a new secret and update the integration in Serval
”AADSTS700016: Application not found”
The App ID or Tenant ID is incorrect:- Double-check the Application (client) ID from the app registration’s Overview page
- Verify the Directory (tenant) ID matches your Azure AD tenant
Exchange commands fail with “UnAuthorized”
The app can authenticate with Azure AD but Exchange Online rejects the token. This means the service principal is not registered in Exchange Online:- Complete Step 5 in the setup guide above to register the service principal via PowerShell
- If already registered, the role assignment may not have propagated yet — wait up to 30 minutes
Exchange commands fail with “Access Denied”
The service principal is missing the required Exchange management role:- Verify the role assignment in Azure AD → Roles and administrators → Exchange Administrator
- Ensure admin consent was granted for the
Exchange.ManageAsApppermission - Verify the Exchange Online management role assignment via
Get-ManagementRoleAssignment -RoleAssignee <object-id>
”PEM must contain a private key” (certificate auth)
The PEM you pasted is missing the private key:- Ensure your PEM file contains both a
BEGIN CERTIFICATEand aBEGIN PRIVATE KEYblock - If you generated separate
cert.pemandkey.pemfiles, combine them:cat cert.pem key.pem > combined.pem - Paste the full contents of the combined file
”The term ‘Get-Mailbox’ is not recognized”
The Exchange Online PowerShell module may not be available on the worker:- Contact support@serval.com if the issue persists
Need help? Contact support@serval.com for assistance with your Exchange Online integration.

