Note: when a clinic website lets patients book a doctor's appointment while the doctor's Outlook slot remains free—trouble starts. Manual cross-checking takes hours and leads to double bookings. The solution is to connect the website with Outlook calendars via the Microsoft Graph API. In 3–4 days we implement automatic event creation and availability checks. Updates happen in real time with less than 2 seconds delay. Below are the technical details of the integration.
Without the Outlook API, developers commonly face three issues: duplicate bookings due to lack of atomicity in scheduling, time inconsistencies from manual event transfers, and erroneous slots from unaccounted meeting series. The Graph API eliminates these risks but requires proper authentication configuration and handling of findMeetingTimes. We configure OAuth 2.0 with delegated permissions so the app works without access to the admin's mailbox.
Beyond basic scenarios, we solve complex tasks: syncing multiple calendars in one tenant, handling recurring events, and supporting time zones. Thanks to delta queries, updates arrive instantly without extra API calls. Average request speed is about 200 ms—3 times faster than the legacy EWS.
How to Set Up Authentication for Outlook Calendar?
The first step is registering an app in Azure AD. We create a client certificate for secure token exchange and grant the app Calendars.ReadWrite.All and User.Read permissions. This allows working with any user's calendar in the tenant. Then we obtain an access token via the OAuth 2.0 On-Behalf-Of flow—the system can act on behalf of an authorized admin. The whole process takes about an hour and is documented in a Postman collection. To work with all users' calendars, the Calendars.ReadWrite.All permission is needed. If only one calendar is required, Calendars.ReadWrite suffices. Permissions are assigned in Azure AD through the app. We help select the minimal necessary rights.
How to Integrate Outlook Calendar via Microsoft Graph?
The primary scenario is reading events for the upcoming week:
import { Client } from '@microsoft/microsoft-graph-client'; const client = Client.initWithMiddleware({ authProvider: tokenCredentialAuthProvider }); async function getCalendarEvents(userId: string): Promise<Event[]> { const response = await client .api(`/users/${userId}/calendarView`) .query({ startDateTime: new Date().toISOString(), endDateTime: new Date(Date.now() + 7 * 86400000).toISOString(), }) .select('subject,start,end,location,isAllDay') .orderby('start/dateTime') .get(); return response.value.map((e: any) => ({ id: e.id, title: e.subject, start: e.start.dateTime, end: e.end.dateTime, location: e.location?.displayName, allDay: e.isAllDay, })); } Creating an event requires binding to a specific user's calendar:
async function createEvent(userId: string, booking: Booking): Promise<string> { const event = await client.api(`/users/${userId}/events`).post({ subject: booking.serviceName, start: { dateTime: booking.startsAt, timeZone: 'Russian Standard Time' }, end: { dateTime: booking.endsAt, timeZone: 'Russian Standard Time' }, body: { contentType: 'HTML', content: `<p>Client: ${booking.customerName}</p><p>Phone: ${booking.phone}</p>`, }, attendees: [{ emailAddress: { address: booking.customerEmail }, type: 'required' }], isReminderOn: true, reminderMinutesBeforeStart: 60, }); return event.id; } Error handling is critical: we account for rate limits (10,000 requests per hour per app) and retry calls with exponential backoff on status 429. We also check that the new event does not conflict with existing ones via findMeetingTimes.
Why Graph API over EWS?
EWS (Exchange Web Services) falls short on all metrics: it is slower—TTFB is 3 times higher (200 ms vs. 600 ms), requires certificate setup, and does not support delta queries. Graph API is a modern REST solution built on OAuth2 with excellent documentation. Here's a comparison:
| Feature | Graph API | EWS |
|---|---|---|
| Authentication | OAuth 2.0 (passwordless) | Basic or complex OAuth setup |
| Request speed | ~200 ms per request | ~600 ms |
| Throughput | 10,000 requests/h per app | 1,000/h |
| Delta synchronization | Yes (change notifications) | No |
Additional Graph API capabilities:
- Working with Teams meetings (onlineMeetingProvider, joinWebUrl)
- Attachment support (up to 150 MB per event)
- Reminder and room availability management
Moreover, Graph API is cheaper to maintain—no certificate renewal needed, and it supports modern scenarios like collaborative calendar management via webhook notifications. Over the last 5 years, we have delivered more than 30 projects integrating corporate calendars for clinics, rental services, and HR platforms.
Common Errors When Working with Graph API
| Error Code | Cause | Solution |
|---|---|---|
| 429 Too Many Requests | Rate limit exceeded | Implement retry with exponential backoff |
| 401 Unauthorized | Expired or invalid token | Refresh token via refresh mechanism |
| 404 Not Found | User not found | Verify userId in tenant |
What's Included in the Work
- App registration in Azure AD and generation of client certificates
- Implementation of REST endpoints for reading, creating, and updating events
- Setting up change notifications (webhook) for real-time synchronization
- Integration with CMS (WordPress, Drupal, Strapi, etc.)
- Integration documentation (Postman collection, DB schema)
- Testing with consideration of N+1 queries and API limits
- Error monitoring and alerts on authorization failures
Process Steps
- Analysis: clarify scenarios—booking, synchronization, public slots.
- Design: choose between delegated and application permissions.
- Implementation: write service layer on Node.js/Nest.js, connect Redis cache.
- Testing: cover with unit tests, check edge cases (timezone, meeting series).
- Deployment: set up CI/CD, add health endpoints.
Estimated Timeline
Basic integration (read + create) takes 3–4 business days. With webhook synchronization—up to 7 days. The cost is calculated individually after analyzing your booking schema. Time saved on manual cross-checking reaches up to 60%, which pays off in 2–3 months. Average savings on operational expenses are around 20,000 RUB per month.
We have 5+ years of experience integrating corporate calendars—delivered over 30 projects for clinics, rental services, and HR platforms. Contact us to get a consultation on optimizing Core Web Vitals and managing Graph API rate limits. Order the integration, and we'll show you examples of working solutions.







