Implementing booking synchronization with Outlook Calendar
Outlook Calendar is a standard in corporate environments. Booking synchronization with Outlook is relevant for B2B services, consulting, medical clinics where specialists work in Microsoft 365.
Microsoft Graph API
Outlook Calendar is managed via Microsoft Graph API. Authorization through Microsoft Identity Platform (Azure AD):
use Microsoft\Graph\Graph;
use Microsoft\Graph\Model\Event as GraphEvent;
class OutlookCalendarService
{
private Graph $graph;
public function __construct(string $accessToken)
{
$this->graph = new Graph();
$this->graph->setAccessToken($accessToken);
}
public function createEvent(Booking $booking): string
{
$event = new GraphEvent();
$event->setSubject("{$booking->service->name} — {$booking->customer_name}");
$event->setBody([
'contentType' => 'HTML',
'content' => $this->buildHtmlBody($booking),
]);
$event->setStart([
'dateTime' => $booking->starts_at->toIso8601String(),
'timeZone' => 'Russian Standard Time',
]);
$event->setEnd([
'dateTime' => $booking->ends_at->toIso8601String(),
'timeZone' => 'Russian Standard Time',
]);
$created = $this->graph
->createRequest('POST', '/me/events')
->attachBody($event)
->setReturnType(GraphEvent::class)
->execute();
return $created->getId();
}
}
OAuth2 flow for Microsoft 365
Register your application in Azure Portal, scope Calendars.ReadWrite:
Route::get('/integrations/outlook/connect', function () {
$url = 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize?' .
http_build_query([
'client_id' => config('services.microsoft.client_id'),
'scope' => 'Calendars.ReadWrite offline_access',
'redirect_uri' => route('integrations.outlook.callback'),
'response_type' => 'code',
]);
return redirect($url);
});
Differences from Google Calendar
- Uses Microsoft Graph, not Calendar API
- Time zones are passed by Windows name (Russian Standard Time, not Europe/Moscow)
- For enterprise accounts, authorization via Tenant ID, not
common - Microsoft Graph Webhooks for changes work via subscriptions with mandatory validation challenge
Timeline
Synchronization with Outlook Calendar via Microsoft Graph: 3–5 working days.







