Calendar API
Connect a Google Calendar account and manage events, check availability, and schedule directly through the API.All calendar endpoints require an authenticated session. Use the connect flow to authorize Google Calendar access before calling event endpoints.
Authentication
All calendar endpoints require a valid NextAuth session. The user identity is derived from your session — you never pass auserId directly. Unauthenticated requests receive a 401 response.
Base URL
Check connection status
{ "connected": false } without an error.
Query parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
action | string | Yes | Must be status |
Response
| Field | Type | Description |
|---|---|---|
connected | boolean | true if the user has a Google Calendar connected, false otherwise |
Connect calendar
Request body
| Field | Type | Required | Description |
|---|---|---|---|
action | string | Yes | Must be connect |
Response
authUrl to begin the OAuth consent flow. After granting access, Google redirects to the callback endpoint below.
Errors
| Code | Description |
|---|---|
| 401 | Not authenticated |
| 400 | Invalid action |
OAuth callback
Query parameters
| Parameter | Type | Description |
|---|---|---|
code | string | Authorization code provided by Google |
state | string | HMAC-signed state token that encodes the authenticated user and a timestamp. The server verifies this signature before accepting the callback. |
error | string | Error code if the user denied access or an error occurred |
Behavior
On success, this endpoint:- Verifies the HMAC signature on the
stateparameter and checks that it has not expired (10-minute window). - Exchanges the authorization code for access and refresh tokens.
- Retrieves the user’s primary calendar ID and timezone.
- Stores the connection for future API calls, keyed to the verified user from the signed state.
- Redirects to
/dashboard/calendar?connected=true.
Error redirects
If an error occurs, the endpoint redirects to/dashboard/calendar with an error query parameter:
| Redirect query | Description |
|---|---|
error=<google_error> | The user denied access or Google returned an error |
error=no_code | No authorization code was present in the callback |
error=missing_state | The state parameter was not included in the callback |
error=invalid_state | The state signature is invalid or the state has expired |
error=token_failed | The authorization code could not be exchanged for tokens |
error=unknown | An unexpected error occurred during the callback |
Start OAuth (redirect)
Query parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
action | string | Yes | Must be auth |
List events
Query parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
action | string | Yes | Must be list |
start | string | No | ISO 8601 start date. Defaults to now. |
end | string | No | ISO 8601 end date. Defaults to 30 days from now. |
Response
Errors
| Code | Description |
|---|---|
| 401 | Not authenticated or calendar not connected |
Check availability
Query parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
action | string | Yes | Must be availability |
date | string | No | Date in YYYY-MM-DD format. Defaults to today. |
Response
Errors
| Code | Description |
|---|---|
| 401 | Not authenticated or calendar not connected |
Create event
Request body
| Field | Type | Required | Description |
|---|---|---|---|
action | string | Yes | Must be create-event |
title | string | Yes | Event title |
start | string | Yes | ISO 8601 start time |
end | string | Yes | ISO 8601 end time |
description | string | No | Event description |
location | string | No | Event location |
attendees | string[] | No | List of attendee email addresses |
Example request
Response
Errors
| Code | Description |
|---|---|
| 401 | Not authenticated or calendar not connected |
| 500 | Internal error |
Update event
Request body
| Field | Type | Required | Description |
|---|---|---|---|
action | string | Yes | Must be update-event |
eventId | string | Yes | ID of the event to update |
title | string | No | Updated event title |
description | string | No | Updated description |
start | string | No | Updated start time (ISO 8601) |
end | string | No | Updated end time (ISO 8601) |
location | string | No | Updated location |
Response
Errors
| Code | Description |
|---|---|
| 401 | Not authenticated or calendar not connected |
| 500 | Internal error |
Delete event
Request body
| Field | Type | Required | Description |
|---|---|---|---|
action | string | Yes | Must be delete-event |
eventId | string | Yes | ID of the event to delete |
Response
Errors
| Code | Description |
|---|---|
| 401 | Not authenticated or calendar not connected |
| 500 | Internal error |
Quick add
Request body
| Field | Type | Required | Description |
|---|---|---|---|
action | string | Yes | Must be quick-add |
text | string | Yes | Natural language event description (for example, "Meeting with Sarah tomorrow at 3pm") |
Response
Errors
| Code | Description |
|---|---|
| 401 | Not authenticated or calendar not connected |
| 500 | Internal error |