Authentication
You'll need to authenticate your requests to access any of the endpoints in the Apiroc Calendar API. In this guide, we'll look at how authentication works.
Request Authentication
Apiroc uses API keys to authenticate requests to the Unified Calendar API. You can generate an API key in your Apiroc Dashboard, select your application and navigate to the API Keys page from the left navigation menu. Your API Key must then be passed to all requests made to Apiroc in the x-api-key header.
Example request with API key
curl https://api.apiroc.com/api/v1/endUserAccounts \
-H "x-api-key: {API KEY}"
End User Authentication
Your end users will need to authenticate their calendars with your application. For Google and Microsoft, this is done through an OAuth2 redirect flow. For Apple Calendar, authentication is done via a direct API call using the user's Apple ID email and an app-specific password. See Apple Calendar Authentication below. CalDAV accounts work the same way, plus the address of the user's CalDAV server. See CalDAV Authentication below.
OAuth2 (Google & Microsoft)
Redirect your end users to one of the URLs below for the provider they want to authenticate with. Apiroc will in-turn redirect the user to the OAuth2 flow for the specified provider based on the configurations you have made in the Apiroc Dashboard for that provider.
| Provider Type | Authentication URL |
|---|---|
GET /v1/oauth/authorize/{:APP_ID}/google | |
| Microsoft | GET /v1/oauth/authorize/{:APP_ID}/microsoft |
Once authenticated, Apiroc will redirect the end user back to your application with an endUserAccountId query parameter. You can then use the /v1/endUserAccounts endpoint to get the details of the end user account.
Query parameters
You can also pass additional query parameters to the authentication URL to control the behavior of the authentication flow.
- Name
prompt- Type
- string
- Description
The prompt to use for the OAuth2 flow. Possible values are
consent,select_account, andnone.
- Name
loginHint- Type
- enum
- Description
The login hint to use for the OAuth2 flow. If you know which email address the user will need to authenticate with, you can provide it in this parameter.
- Name
redirectUrl- Type
- string
- Description
The URL to redirect the end user to after authentication. This URL must be a valid redirect URL for the application in the Apiroc Dashboard under Configurations > Application.
- Name
state- Type
- string
- Description
A string which will be passed back to you in the redirect URL. This can be used to store additional information about the user or request which you may need after the authentication is complete. We recommend using a base64 encoded string for this field.
Using the SDK
If you are using the SDK, you can get the OAuth authentication URL by doing the following:
The getOAuthUrl function is only applicable to Google and Microsoft providers. For Apple Calendar and CalDAV, see Apple Calendar Authentication and CalDAV Authentication below.
TypeScript
import { getOAuthUrl } from '@apiroc/unified-calendar-api-node-sdk/oauth'
const googleUrl = getOAuthUrl('your-app-id', 'GOOGLE', {
redirectUrl: 'https://your-app.com/callback',
externalId: 'user-123',
loginHint: 'user@example.com',
})
Apple Calendar Authentication
Apple Calendar uses a different authentication model. Instead of an OAuth2 redirect flow, your application collects the user's Apple ID email and an app-specific password, then sends them directly to the Apiroc API.
The password must be an Apple app-specific password, not the user's regular iCloud sign-in password. See how to generate an Apple app-specific password for instructions. App-specific passwords require that two-factor authentication is enabled on the user's Apple ID.
No redirect flow is involved — the End User Account is created and returned directly in the API response.
You can also create or update Apple Calendar End User Accounts using the unified POST /v1/endUserAccounts endpoint with providerType set to APPLE and a password field.
Connect Apple Calendar
This endpoint authenticates an Apple Calendar account using Basic Auth and creates an End User Account.
Path parameters
- Name
APP_ID- Type
- string
- Description
Your application ID from the Apiroc Dashboard.
Request body
- Name
email- Type
- string
- Description
The user's Apple ID email address.
- Name
password- Type
- string
- Description
An Apple app-specific password generated at appleid.apple.com.
- Name
externalId- Type
- string?
- Description
An optional custom ID for the end user account.
Request
curl -X POST https://api.apiroc.com/api/v1/basicAuth/connect/{APP_ID}/apple \
-H "x-api-key: {apiKey}" \
-H "Content-Type: application/json" \
-d '{"email": "user@icloud.com", "password": "xxxx-xxxx-xxxx-xxxx"}'
Response
{
"id": "user_account_1",
"createdAt": "2025-09-12T10:15:00.000Z",
"updatedAt": "2025-09-12T10:15:00.000Z",
"email": "user@icloud.com",
"externalId": "",
"authorizedScopes": [],
"providerAccountId": null,
"providerId": "provider_1",
"applicationId": "application_1",
"status": "ACTIVE",
"providerType": "APPLE"
}
CalDAV Authentication
CalDAV lets your users connect calendars from any standards-compliant CalDAV server, such as Fastmail, Yahoo, Zoho, GMX, mailbox.org or a self-hosted Nextcloud. Like Apple Calendar, there is no redirect flow: your application collects the server address, the user's login and an app-specific password, then sends them to the Apiroc API.
Apiroc discovers the user's calendars from the server address automatically (via /.well-known/caldav), so the base address of the server is usually enough.
| Provider | Server URL |
|---|---|
| Fastmail | https://caldav.fastmail.com |
| Yahoo | https://caldav.calendar.yahoo.com |
| AOL | https://caldav.aol.com |
| Zoho | https://calendar.zoho.com, https://calendar.zoho.eu or https://calendar.zoho.com.au |
| GMX | https://caldav.gmx.net (gmx.com addresses: https://caldav.gmx.com) |
| WEB.DE | https://caldav.web.de |
| mail.com | https://caldav.mail.com |
| mailbox.org | https://dav.mailbox.org |
| Nextcloud | https://{your-host}/remote.php/dav |
The server URL must use https and resolve to a public address. Most hosted providers require an app-specific password rather than the user's regular password.
You can also create or update CalDAV End User Accounts using the unified POST /v1/endUserAccounts endpoint with providerType set to CALDAV, a password and a serverUrl.
Connect CalDAV
This endpoint authenticates a CalDAV account and creates an End User Account.
Path parameters
- Name
APP_ID- Type
- string
- Description
Your application ID from the Apiroc Dashboard.
Request body
- Name
serverUrl- Type
- string
- Description
The address of the user's CalDAV server, e.g.
https://caldav.fastmail.com. If no scheme is given,https://is assumed.
- Name
email- Type
- string
- Description
The user's login for the CalDAV server. This is usually an email address, but some servers (such as Nextcloud) use a plain username.
- Name
password- Type
- string
- Description
The user's password for the CalDAV server, usually an app-specific password.
- Name
externalId- Type
- string?
- Description
An optional custom ID for the end user account.
Errors
| Status | Meaning |
|---|---|
400 | The request is invalid, the server URL is not allowed (not https, or not a public address), or the server rejected the login. |
502 | No CalDAV server could be reached at that address. |
Request
curl -X POST https://api.apiroc.com/api/v1/basicAuth/connect/{APP_ID}/caldav \
-H "x-api-key: {apiKey}" \
-H "Content-Type: application/json" \
-d '{"serverUrl": "https://caldav.fastmail.com", "email": "user@fastmail.com", "password": "app-specific-password"}'
Response
{
"id": "user_account_2",
"createdAt": "2026-10-08T10:15:00.000Z",
"updatedAt": "2026-10-08T10:15:00.000Z",
"email": "user@fastmail.com",
"externalId": "",
"authorizedScopes": [],
"providerAccountId": null,
"applicationId": "application_1",
"status": "ACTIVE",
"providerType": "CALDAV",
"serverUrl": "https://caldav.fastmail.com/"
}