> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prod.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Databricks Lakebase

> Build apps with read and write access to a Databricks Lakebase database

Databricks Lakebase is a fully managed Postgres database integrated with the Databricks lakehouse, built for modern operational workloads. It provides a Postgres-compatible OLTP database that eliminates complex ETL pipelines and ensures transactional data is seamlessly integrated with analytics and AI-driven applications. Integrate Databricks Lakebase with Prod AI to build internal tools and workflows that query, analyze, and update your data using familiar PostgreSQL syntax.

## Setting up Databricks Lakebase

On Dedicated Cloud, allowlist your [Prod AI data plane IP addresses](https://docs.prod.ai/deployment/security/overview.md#ip-addresses) to connect to your database.
Learn how to configure this in Databricks' guide on&#x20;
[Configuring IP access lists](https://docs.databricks.com/aws/en/security/network/front-end/ip-access-list-workspace).
Alternatively, use Managed BYOC to keep your data within your own AWS account.

### Configure authentication

To access your Databricks Lakebase database, you'll need to authenticate using a Databricks account. Prod AI provides several different ways to authenticate. See the Databricks documentation below for how to configure your preferred authentication method.

| Method | Description |
| - | - |
| [Personal access token (PAT)](https://docs.databricks.com/aws/en/dev-tools/auth/pat) | Use a short or long-lived access token for a user or service principal. |
| [Machine-to-machine OAuth](https://docs.databricks.com/aws/en/dev-tools/auth/oauth-m2m) | Configure OAuth client credentials for a service principal. Prod AI will exchange the client credentials with Databricks to retrieve a short-lived OAuth token. |
| [OAuth token federation](https://docs.databricks.com/aws/en/dev-tools/auth/oauth-federation) | Use OAuth tokens issued by your identity provider when users log in to Prod AI to authenticate with Databricks using the authenticated user's permissions. |

### Add integration

1. In the web app, navigate to the&#x20;
   **Integrations** page
2. Click **Add integration**
3. Search for **Databricks Lakebase** and select it from the list of available integrations
4. **Name** the integration
5. Fill out the integration configuration as follows:

> [tab] Personal access token
>
> | Field | Required | Description |
> | - | - | - |
> | Host | ✓ | Databricks Lakebase host name (e.g. `xxxx.cloud.databricks.com`) |
> | Port | ✓ | Port to use when connecting (default: `5432`) |
> | Database Name | ✓ | Name of database to connect to |
> | Default schema | ✗ | An optional initial schema to use |
> | Database Username | ✓ | Username to use to connect |
> | Access token | ✓ | Databricks personal access token |
> | Enable SSL | ✗ | Connect using SSL |
> | Use a self-signed SSL certificate | ✗ | Provide **Server CA**, **Client Key**, and **Client Cert** |

> [tab] Machine-to-machine OAuth
>
> | Field | Required | Description |
> | - | - | - |
> | Host | ✓ | Databricks Lakebase host name (e.g. `xxxx.cloud.databricks.com`) |
> | Port | ✓ | Port to use when connecting (default: `5432`) |
> | Database Name | ✓ | Name of database to connect to |
> | Default schema | ✗ | An optional initial schema to use |
> | Database Username | ✓ | Username to use to connect |
> | OAuth client ID | ✓ | Client ID associated with your service principal |
> | OAuth client secret | ✓ | Client secret associated with your service principal |
> | Enable SSL | ✗ | Connect using SSL |
> | Use a self-signed SSL certificate | ✗ | Provide **Server CA**, **Client Key**, and **Client Cert** |

> [tab] OAuth token federation
>
> | Field | Required | Description |
> | - | - | - |
> | Host | ✓ | Databricks Lakebase host name (e.g. `xxxx.cloud.databricks.com`) |
> | Port | ✓ | Port to use when connecting (default: `5432`) |
> | Database Name | ✓ | Name of database to connect to |
> | Default schema | ✗ | An optional initial schema to use |
> | Database Username | ✓ | Username to use to connect |
> | Subject token source | ✓ | Select **Login identity provider** to use the access token issued to Prod AI when users log in via SSO, or provide a **Static token**. |
> | Token URL | ✓ | Databricks token URL. Choose a URL format based on the federation policy you previously configured. **Workspace identity federation** `https://<databricks-workspace-host>/oidc/v1/token` **Account-wide token federation** `https://<databricks-account-host>/oidc/accounts/<account-id>/v1/token` |
> | Service Principal UUID | ✗ | Only required if using [Workload identity federation](https://docs.databricks.com/aws/en/dev-tools/auth/oauth-federation-policy). The service principal client ID to authenticate as. |
> | Enable SSL | ✗ | Connect using SSL |
> | Use a self-signed SSL certificate | ✗ | Provide **Server CA**, **Client Key**, and **Client Cert** |
>
> **Login identity provider** token source is only supported for Enterprise organizations with OIDC-based [Single Sign-On](https://docs.prod.ai/admin/org-administration/auth/single-sign-on.md) configured. If you're not sure how your SSO provider is configured, contact support for assistance.

6. Optionally, add more configurations to set credentials for [different environments](https://docs.prod.ai/development-lifecycle/build/data-tags.md)
7. Click **Test Connection** to check that Prod AI can connect to the data source
8. Click **Create**

**Databricks Lakebase connected!**
You can now build
[apps](https://docs.prod.ai/coding-agents/apps.md) and [agents](https://docs.prod.ai/coding-agents/agents.md) with Databricks Lakebase.

## Using Databricks Lakebase in APIs

Once your Databricks Lakebase integration is created, you can start using it by writing SQL in Prod AI APIs. Since Lakebase is fully Postgres-compatible, you can use standard PostgreSQL syntax for all your queries, including support for Postgres extensions like PostGIS and pgvector.

## Troubleshooting

If you run into issues, first see our guide on [Troubleshooting Database Integrations](https://docs.prod.ai/integrations/troubleshooting/troubleshooting-databases.md).

There are also several common errors you may see when using Databricks Lakebase. The table below includes error messages, why they happen, and how to address them.

| Error message | Why it's happening & Resolution |
| - | - |
| `IntegrationOAuthError: OAuth2 - "On-Behalf-Of Token Exchange" could not find identity provider token` | **Reason** You've selected **Login identity provider** as the subject token source when using OAuth token federation, but you are not currently logged in to Prod AI using an OIDC-based Identity Provider. **Resolution** Reach out to [[support@prod.ai](mailto:support@prod.ai)](mailto:support@prod.ai) for assistance configuring SSO or migrating your SSO configuration to OIDC. |
| `Failed to process token: TOKEN_EXPIRED` | **Reason** The access token issued to Prod AI when you logged in, or the static token you've provided has expired. **Resolution** If using **Login identity provider**, log out of and back into Prod AI. If using a static token, obtain a new federated JWT from your identity provider. |
| `Failed to process token: TOKEN_INVALID (Ensure a valid federation policy has been configured)` | **Reason** Your Databricks account either does not have a federation policy configured, or the `subject_token` being sent to Databricks by Prod AI does not satisfy the policy. This can happen if the token is not a valid JWT, or has a different `aud` or `iss` than configured in the Databricks federation policy. **Resolution** Make sure the `aud` and `iss` configured in Databricks are the same `aud` and `iss` your IdP uses when issuing tokens to Prod AI. Make sure the Databricks federation policy points to a valid JWKS URI. By default, Databricks uses the URI provided at `<issuer-url>/.well-known/openid-configuration`. You may need to change this if your IdP uses a non-default authorization server or does not support a `/.well-known` discovery URL. |

If you are encountering an error that's not listed, or the provided steps are insufficient to resolve the error, please contact us at [[support@prod.ai](mailto:support@prod.ai)](mailto:support@prod.ai)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.