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

# Databricks

> Sync your 3RD visibility, citation, competitor and sentiment data into Delta tables in your Databricks workspace every day.

The Databricks integration writes 3RD's **Export API datasets** into Delta tables in a Unity Catalog schema in your workspace, and refreshes them every day. Query them in Databricks SQL, notebooks or dashboards, or join them with the rest of your marketing data.

It runs on the same data as the [Export API](https://docs.get3rd.com/api-reference/introduction.md), so the numbers match the API and the 3RD dashboard.

> [!NOTE]
>
> The sync is available on plans that include the Export API. Your workspace needs Unity Catalog and a SQL warehouse.

## What you need

* A workspace admin who can create a service principal.
* A catalog owner or metastore admin to run three GRANT statements once.
* The owner or admin role in your 3RD organization.

## Set it up

**1. Create a service principal**

In your workspace, go to **Settings → Identity and access → Service principals** and add one for 3RD, for example `3rd-sync`. On its **Secrets** tab, click **Generate secret**. Note the **application ID** and the **secret**. You can't see the secret again after you close the dialog.

**2. Let it use a SQL warehouse**

Open the SQL warehouse 3RD should use, click **Permissions**, and give the service principal **Can use**. A small serverless warehouse is enough; a daily sync takes seconds.

**3. Connect in 3RD**

Go to **Brand → Integrations**, and under **Reporting** open **Databricks**. Enter:

* the **workspace URL**, as in your browser;
* the warehouse's **HTTP path**, from its **Connection details** tab;
* the **catalog** and the **schema** for 3RD's tables (the schema defaults to `third`);
* the service principal's **application ID** and **secret**.

Click **Connect**.

**4. Run the GRANT statements**

3RD shows three statements with your catalog, schema and application ID filled in. Run them in the SQL editor as the catalog's owner or a metastore admin:

```sql theme={null}
CREATE SCHEMA IF NOT EXISTS `main`.`third`;

GRANT USE CATALOG ON CATALOG `main` TO `<application id>`;
GRANT USE SCHEMA, CREATE TABLE ON SCHEMA `main`.`third` TO `<application id>`;
```

**5. Test the connection**

Back in 3RD, click **Test connection**. When it passes, 3RD starts loading your history. If it fails, the message tells you which step to fix. See [Troubleshooting](#troubleshooting).

**6. Give your team read access**

The service principal owns the tables it creates. Grant read access to the groups your analysts use:

```sql theme={null}
GRANT USE CATALOG ON CATALOG `main` TO `analysts`;
GRANT USE SCHEMA, SELECT ON SCHEMA `main`.`third` TO `analysts`;
```

> [!TIP]
>
> Under **What to sync**, untick any tables or brands you don't want. Changes apply from the next sync.

## Security

* **Your principal, your control.** 3RD signs in as the service principal you created, with OAuth machine-to-machine. Delete its secret, or revoke its grants, and 3RD loses access.
* **Least privilege.** The grants cover one schema. The principal can't read anything else in your catalog.
* **Encrypted secret.** 3RD stores the secret encrypted and only ever shows its last four characters.
* **Your compute.** The sync runs on the SQL warehouse you chose.

If your workspace uses an **IP access list**, 3RD can't reach it yet: 3RD has no fixed IP addresses to add. Contact support before you connect.

## Tables

Each dataset becomes one Delta table in your schema. Table and column names are the Export API names in lower case; see the [Export API reference](https://docs.get3rd.com/api-reference/introduction.md) for what each field means.

| Table | Source | One row per |
| - | - | - |
| `brands` | `/brands` | Brand |
| `visibility_daily` | `/visibility` | Date × model × provider × market |
| `citations_daily` | `/citations` | Date × cited URL |
| `competitors_daily` | `/competitors` | Date × competitor |
| `citation_share_daily` | `/citation-share` | Date × cited URL |
| `recommended_rate_daily` | `/recommended-rate` | Date × brand or competitor |
| `sentiment_daily` | `/sentiment` | Date |
| `_3rd_sync_runs` | — | Sync run, with rows written and status |

Every dated table also has `brand_id`, which joins to `brands.id`, and `_synced_at`, the time the row was written.

## How the sync works

* **Daily refresh.** Each run reloads the **last 7 days**, because AI answers for recent days can still arrive. Older days don't change.
* **Atomic.** 3RD loads new rows into a staging table, then replaces the days it reloaded with one `INSERT … REPLACE WHERE`. A failed run leaves your tables as they were.
* **History.** The first sync goes back as far as your plan's Export API history allows, up to two years. See [Pagination and history](https://docs.get3rd.com/api-reference/pagination.md).
* **New columns.** When 3RD adds a field to the Export API, the column is added to your table. Existing columns are never renamed or dropped.
* **Sync now.** Click **Sync now** in settings to run a sync outside the daily schedule, or **Reload history** to load your whole history again.

Check freshness:

```sql theme={null}
SELECT dataset, MAX(finished_at) AS last_success
FROM main.third._3rd_sync_runs
WHERE status = 'success'
GROUP BY dataset;
```

## Example query

Weekly visibility per AI model for one brand:

```sql theme={null}
SELECT
  date_trunc('week', v.date) AS week,
  v.model_id,
  SUM(v.visible_count) / NULLIF(SUM(v.total_prompts), 0) * 100 AS visibility_rate
FROM main.third.visibility_daily v
JOIN main.third.brands b ON b.id = v.brand_id
WHERE b.name = 'Acme'
GROUP BY 1, 2
ORDER BY 1, 2;
```

Sum the counts and divide, rather than averaging `visibility_rate`: a day with more answers should weigh more.

## Manage the connection

* **Change details.** Update the secret, warehouse or schema in settings, then test the connection again. Service principal secrets expire; rotate before yours does.
* **Disconnect.** Click **Disconnect**. 3RD deletes its copy of the secret and stops syncing. Your tables stay. 3RD shows the REVOKE statements to remove its grants; then delete the secret in the workspace.
* **Plan changes.** If your plan no longer includes the Export API, syncing stops and your tables stay as they were.

## Troubleshooting

| Message in 3RD | What to check |
| - | - |
| Sign-in rejected | The application ID, and that the secret is current and pasted whole. |
| Workspace or warehouse not found | The workspace URL, and the warehouse's HTTP path from **Connection details**. |
| Missing a grant | The GRANT statements ran, the catalog and schema in 3RD match them, and the principal has **Can use** on the warehouse. |
| Blocked by an IP access list | 3RD has no fixed IP addresses yet. Contact support. |
| Warehouse couldn't run the query | The warehouse exists and isn't stopped by a quota or budget policy. |

## Related

* [Export API](https://docs.get3rd.com/api-reference/introduction.md) — the endpoints and fields behind the tables
* [Snowflake](https://docs.get3rd.com/integrations/snowflake.md) and [Microsoft Fabric](https://docs.get3rd.com/integrations/fabric.md) — the same data in other warehouses
* [Metrics at a glance](https://docs.get3rd.com/metrics/overview.md) — what each metric means


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