Timeful uses session-based authentication. When a user signs in, the server sets an encrypted cookie namedDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ptshen/timeful-plus/llms.txt
Use this file to discover all available pages before exploring further.
session. Every subsequent request from the same browser or HTTP client automatically carries that cookie, allowing the server to identify the caller without requiring a token header.
Routes that require a valid session are wrapped with middleware.AuthRequired(). If the cookie is absent or the referenced user no longer exists in MongoDB, the middleware aborts the request with a 401 Unauthorized response:
Anonymous Use
Several endpoints work without signing in:GET /api/events/:eventId— view any eventPOST /api/events— create an event as a guestPOST /api/events/:eventId/response— submit availability as a guest (pass"guest": true)DELETE /api/events/:eventId/response— delete a guest responsePOST /api/events/:eventId/rename-user— rename a guest respondentPOST /api/events/:eventId/responded— mark a remindee as having responded
Sign-In Flow (Web)
The web client uses Google OAuth’s server-side authorization code flow.Initiate Google OAuth
The frontend redirects the user to Google’s authorization endpoint. Google returns an authorization
code and scope string to your redirect URI.POST /api/auth/sign-in
Exchange the code for a session by posting the authorization code to the server. The server calls Google’s token endpoint, creates or updates the user record in MongoDB, and sets the session cookie in the response.Request body:
Response
| Field | Type | Required | Description |
|---|---|---|---|
code | string | ✅ | Google OAuth authorization code |
scope | string | ✅ | OAuth scope string returned by Google |
calendarType | string | ✅ | "google" or "outlook" |
timezoneOffset | integer | ✅ | Caller’s UTC offset in minutes |
eventsToLink | string[] | — | Event IDs to associate with the new user |
200 OK: Returns the signed-in User object.Sign-In Flow (Mobile)
Mobile apps obtain OAuth tokens directly (e.g. via the Google Sign-In SDK) and then post those tokens to:| Field | Type | Required | Description |
|---|---|---|---|
accessToken | string | ✅ | OAuth 2.0 access token |
scope | string | ✅ | OAuth scope string |
idToken | string | ✅ | JWT ID token containing user profile claims |
expiresIn | int | ✅ | Seconds until the access token expires |
refreshToken | string | ✅ | OAuth 2.0 refresh token |
tokenOrigin | string | ✅ | Platform: "ios" or "android" |
calendarType | string | ✅ | "google" or "outlook" |
timezoneOffset | int | ✅ | Caller’s UTC offset in minutes |
200 OK: Returns an empty JSON object {}. The session cookie is set on the response.
CalendarType Values
Defined inmodels/calendar.go:
| JSON value | Meaning |
|---|---|
"google" | Google Calendar (OAuth 2.0) |
"outlook" | Microsoft Outlook (OAuth 2.0) |
"apple" | Apple Calendar (app password) |
TokenOrigin Values
Defined inmodels/user.go:
| JSON value | Meaning |
|---|---|
"web" | Browser |
"ios" | iOS app |
"android" | Android app |
Sign-Out
userId key from the session. No request body required.
Response 200 OK: Returns {}.
Auth Status
This endpoint is protected by
middleware.AuthRequired(). It returns 401 if the caller is not signed in.{} with a 200 status when the session is valid. Use this to check whether a session cookie is still active.
Example:
200 {}. If not, you receive:
Example: Check Auth Status
Protecting Custom Routes
Themiddleware.AuthRequired() function is a standard Gin middleware. When it succeeds it stores the authenticated *models.User under the "authUser" context key, accessible in handlers via: