Thank you for reaching out. I understand that you would like to create a shared mailbox using Microsoft graph API within a spring boot application.
Currently, Microsoft graph API does not directly support creating shared mailboxes. Shared mailboxes can only be created via exchange online PowerShell or exchange admin center(EAC) not via graph API.
Once a shared mailbox has been created in exchange, you can use Microsoft graph API too:
- access the shared mailbox messages and folder.
- Assign permissions.
- Manage members or delegate access.
Work around-Create shared mailbox via PowerShell
you can use exchange online PowerShell with the following command
New-Mailbox –Shared –Name “Support Team” –DisplayName “Support Mailbox” –Alias “support”
Then assign users access to it:
Add-MailboxPermission -Identity “support” -User “[******@contoso.com](mailto:******@contoso.com)” -AccessRights FullAccess -InheritanceType All
Add-RecipientPermission -Identity “support” -Trustee “[******@contoso.com](mailto:******@contoso.com)” -AccessRights SendAs
Once created, the mailboxes accessible through Microsoft graph under the /users endpoint using its mailbox identity
Accessing the shared mailbox via Microsoft graph
you can read messages from a shared mailbox using the /users/{shared_mailbox}/messages endpoint.
Example:
GET [https://graph.microsoft.com/v1.0/users/******@contoso.com/messages](https://graph.microsoft.com/v1.0/users/******@contoso.com/messages)
Authorization: Bearer <access_token>
You will need to ensure your Azure AD application has appropriate delegated or application permissions:
- Mail.Read
- Mail.ReadWrite
- Mail.Send
See official graph permissions reference:
Microsoft Graph permissions reference - Microsoft Graph | Microsoft Learn
Shared mailboxes | Microsoft Learn
Use the Outlook mail REST API - Microsoft Graph v1.0 | Microsoft Learn
Install a Microsoft Graph SDK - Microsoft Graph | Microsoft Learn
New-Mailbox (ExchangePowerShell) | Microsoft Learn
If your goal is to automate shared mailbox creation, you can use Microsoft graph PowerShell SDK or exchange online management module in your automation pipeline instead of calling graph directly.
Please let us know if you require any further assistance we’re happy to help. If you found this information useful, kindly mark this as "Accept Answer".