OAuth 2.0: Installation grant flow
The installation grant is Apaleo’s custom OAuth 2.0 grant for organization-level apps. Apaleo stores the connection as an installation owned by the hotel’s account and issues access tokens bound to that account. The connection continues through staff, role, and admin changes.
Before you start
Register your client
In the registration form, select Fine-grained client and Organization app. Clients of type OrgIntegration use the installation grant exclusively. See Register a Connect client.
How it works
- Your app sends a hotel user to AppsConnect. The user signs in, selects properties if needed, and consents.
- Apaleo Identity redirects the user to your callback with the installation ID.
- Your server gets an installation token using the installation ID and your client credentials.
- Your server exchanges the installation token for an access token.
- Your app calls the Apaleo APIs with the access token.
Step 1. Redirect the user to AppsConnect
Send the hotel user to the Apaleo consent screen at /AppsConnect.
https://identity.apaleo.com/AppsConnect?clientId={clientId}&state={state}&redirectUri={encodedRedirectUri}
| Parameter | Required | Description |
|---|---|---|
clientId |
Yes | The client ID of your OrgIntegration app. |
state |
Yes | Generate a fresh, unpredictable value for each connection attempt and save it with the user’s session. Apaleo returns it unchanged in the callback. Validate it to prevent cross-site request forgery (CSRF). |
redirectUri |
No | URL-encode the URI where Apaleo should redirect the user after consent. The decoded URI must exactly match a registered redirect URI. If you omit it, Apaleo uses the first registered URI. An unregistered URI results in an error page. |
Apaleo connects the app to the account the user signs in to.
Who can connect
The installing user needs app:account-level-connected-apps.manage and every permission the app requests. By default, the Account Admin role has the management permission.
Property selection
When the app requests property permissions, the user can grant access only to properties where they hold all the required permissions. At least one property must qualify.
- All properties — the default. Apaleo stores this selection as
*to cover the account’s current and future properties. - Selected properties — the user selects at least one eligible property.
For apps that request account-level permissions only, the consent screen goes straight to confirmation.
Consent errors
Apaleo returns an error instead of the consent screen in these cases.
- The user lacks
app:account-level-connected-apps.manage. - The user is missing permissions the app requests or lacks access to an eligible property (
403). - The client ID is unknown, the client is disabled, or the client type is ineligible for the installation grant.
- The
stateparameter is missing.
Step 2. Handle the callback
After the user consents, Apaleo redirects to the callback URI with installationId and state.
https://your-app.example/callback?installationId={installationId}&state={state}
Compare the returned state with the value you saved for this connection attempt. Reject a missing or mismatched value before exchanging tokens or changing any installation. Invalidate the saved value after a successful match so it can be used only once.
Apaleo creates one installation per account and client pair. The installation ID stays the same when a user consents again for an existing installation.
To remove an orphaned installation, first verify its ID and that it is orphaned independently of the callback. Then call DELETE /api/v0-nsfw/installations/{installationId} with your client credentials.
Step 3. Get an installation token
Apaleo creates the installation when the user consents. After you validate the callback, request its installation token from your server. Authenticate with HTTP Basic using your client ID and client secret.
POST https://identity.apaleo.com/api/v0-nsfw/installations/{installationId}/token
Authorization: Basic {base64(clientId:clientSecret)}
The installation endpoints use the
v0-nsfwnamespace and may change. Apaleo will announce breaking changes in advance.
Apaleo returns the installation token and the account code.
{
"installationToken": "{64-character hexadecimal token}",
"accountCode": "WXFX"
}
Apaleo returns the token value once. Immediately store installationToken and accountCode under installationId in a secret manager or encrypted store. Keep your client secret and installation tokens server-side and out of redirects and logs. If you lose the token, call the endpoint again to rotate it. Rotation invalidates the previous installation token immediately.
The installation token is a credential for /connect/token. To call the Apaleo APIs, exchange it for an access token in the next step.
Installation token errors
| Status | Meaning |
|---|---|
401 |
The client credentials are missing or incorrect. |
404 |
The installation does not exist for this client. Apaleo also returns this status if the installation belongs to another client. |
Step 4. Get an access token
Post the installation grant to /connect/token from your server. Authenticate with HTTP Basic using your client ID and client secret, and URL-encode the form values. Apaleo determines API access from the installation, so you can omit scope.
POST https://identity.apaleo.com/connect/token
Authorization: Basic {base64(clientId:clientSecret)}
Content-Type: application/x-www-form-urlencoded
grant_type=urn%3Aapaleo%3Agrant-type%3Ainstallation&installation_token={installationToken}
Apaleo returns a bearer access token valid for one hour.
{
"access_token": "{accessToken}",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "identity:permissions"
}
The access token is a JWT that includes the client_id, account_code, and installation_id claims and omits sub. The response omits refresh_token. To get a fresh access token, repeat this exchange with the stored installation token.
Token exchange errors
| Error | Meaning |
|---|---|
invalid_request |
The installation_token parameter is missing. |
invalid_grant |
The installation token is unknown, has been rotated, belongs to a disconnected installation, or was issued to a different client. |
invalid_client |
The client secret is incorrect. |
unauthorized_client |
The client is public and has no client secret. |
Recover from an invalid installation token
If a previously valid installation token returns invalid_grant, call the installation token endpoint with your stored installation ID and client credentials. A successful response confirms the installation still exists and rotates its token. Replace the stored token atomically before retrying the exchange. A 404 means the installation is gone for your client. Remove its credentials and clean up the local installation data.
Step 5. Call the Apaleo APIs
Send the access token in the Authorization header as a bearer token.
GET https://api.apaleo.com/booking/v1/reservations?propertyId=MUC
Authorization: Bearer {accessToken}
Apaleo grants access where the permissions registered on the client overlap with the permissions approved on the installation. Property permissions apply to the installation’s selected properties. See Scopes and permissions.
Token lifecycle
| Token | Lifetime | Use |
|---|---|---|
| Installation token | Until rotated or the installation is removed | Store it securely and exchange it for access tokens. |
| Access token | 1 hour | Send it with Apaleo API requests. |
Cache the access token by installationId and reuse it until it approaches expiry. Apaleo checks that the installation still exists on each token exchange.
Credential rotation
Apaleo recommends rotating the installation token every 90 days and rotating it immediately if you suspect exposure. To rotate it, request an installation token again. Coordinate rotations for each installation and replace the stored token atomically when Apaleo returns the new value.
Manage installations
A user with the relevant permissions can open an installation under Connected apps → Account apps and change its property selection. The change applies to the existing installation.
When you add permissions to your client, a user from each connected account must approve them. In Apps → Connected apps → Account apps, open the app marked Consent required and click Review new permissions. Approval on the consent screen updates the existing installation. The approving user must meet the installation permission requirements.
Disconnect handling
When a user removes the app in Connected apps, Apaleo deletes the installation and its grants. The installation token stops working immediately. Previously issued access tokens keep their original expiration. Once the removal propagates, normally within seconds, requests made with those tokens are denied.
Create the subscription
Subscribe to application/disconnected as soon as each account connects the app. Use the installation’s access token so Apaleo can identify the account and client. The app needs the webhook.subscriptions.create permission.
POST https://api.apaleo.com/webhook/v1/subscriptions
Authorization: Bearer {accessToken}
Content-Type: application/json
{
"endpointUrl": "https://your-app.example/webhooks",
"events": ["application/disconnected"]
}
Use events to select the disconnect event and omit topics. Omit propertyIds for the global Application topic. Apaleo pings endpointUrl when you create the subscription and saves it only if the endpoint returns a success status. See Create a new subscription.
Process the event
Apaleo sends one event per removed installation to the corresponding app. It also removes your app’s webhook subscriptions, ARI push subscriptions, and UI integrations for the account.
{
"id": "{eventId}",
"topic": "Application",
"type": "disconnected",
"accountId": "WXFX",
"timestamp": 1761570000000,
"data": {
"entityId": "ABC123"
}
}
data.entityId is the ID of the removed installation. After verifying the event, delete the installation token, cached access tokens, and local account data for that installation. Cancel its scheduled jobs. If your endpoint misses a notification, an invalid_grant response during token exchange can help you detect the disconnection.
Reconnect after a disconnect
When the hotel reconnects, the user consents again and Apaleo creates a new installation with a new ID. Get a new installation token, exchange it for an access token, and create a new disconnect subscription.