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

# HubDB

> Easily sync data and publish tables to always keep your website or landing page up to date.

## Overview

With Hightouch's HubDB integration, you no longer need to rely on others to build and maintain databases. Push and store data to tables that you can embed within websites and landing pages. Integrated into HubSpot, data is easily accessible, editable and shareable across multiple tables. You can even publish table updates in one sync.

## Supported syncing

| Sync Type | Description | Supported Sync Modes |
| - | - | - |
| **Tables** | Sync data to create or update tables in a HubDB. | Upsert, Update |

## Connect to HubDB

You must have one of the following HubSpot account types to use the Hightouch integration:

* CMS Hub Professional
* Enterprise
* Marketing Hub Professional
* Enterprise with Website Add-on

Go to the [**Destinations** overview page](https://app.hightouch.com/destinations?from=docs) and click the **Add destination** button. Select **HubDB**. You can then authenticate Hightouch to HubDB via **OAuth**.

### Authenticate with OAuth

Click **Log in to HubDB** and log into your HubSpot account.

Once successful, you will be redirected back to Hightouch to enter a descriptive name for your destination and complete setup.

## Sync configuration

Once you've set up your HubDB destination and have a [model](https://docs.hightouch.com/getting-started/concepts.md#models) to pull data from, you can set up your sync configuration to begin syncing data. Go to the [**Syncs** overview page](https://app.hightouch.com/syncs?from=docs) and click the **Add sync** button to begin. Then, select the relevant model and the HubDB destination you want to sync to.

In the HubDB sync configuration form, select the HubDB table you want to sync to.

#### Record matching

Hightouch requires choosing one column to define how rows in your source should be matched to records in HubDB. The field to match should be unique and the data type of the field should match the data type of the corresponding column in your model.

#### Field mapping

You can choose which specific fields you want to sync to your HubDB table. Only the fields that you map will be exported. All other columns from your results are ignored. If you don't have a HubDB field to sync data to, you can add a new field to the table directly within HubDB. Then, refresh the HubDB fields and the new field should be available to map.

![Field mapping in the Hightouch UI](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/destinations/destination-hubdb-field-mapping.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=ccf7d2c8a2f7fc037cb705e2502b7fe9)

#### Delete behavior

You can choose how to handle data points in HubDB when the corresponding rows are deleted in your source.

| Behavior | Description |
| - | - |
| **Do nothing** | Keep the data in HubDB |
| **Clear Fields** | Clear the mapped fields but keep the record in the HubDB table |
| **Delete Destination Record** | Delete the record from the HubDB table completely |

## Tips and troubleshooting

To see the exact API requests and responses from each sync run, use the [live debugger](https://docs.hightouch.com/syncs/debugger.md). To get notified by Slack, PagerDuty, SMS, or email when a sync fails, set up [sync alerts](https://docs.hightouch.com/syncs/alerting.md). If you run into an issue this page doesn't cover, [contact support](#pylon-chat).

## Common errors

### 400 - the value for column date was of type STRING, but we're expecting NUMERIC

The full error message looks something like this:

```json theme={null}
{
    "message":"Error when batch creating datatable rows in table 6058806 for portal 2661677: the value {type=string, value=2021/03/20 13:30} for column date was of type STRING, but we're expecting NUMERIC",
}
```

One possible cause for this error is sending incorrectly formatted date values to HubDB.

[HubDB's `date`](https://developers.hubspot.com/docs/api/cms/hubdb) data type must be a millisecond timestamp set to midnight UTC.
A millisecond timestamp is numerical value with 13 digits, for example `1620170285617`, as compared to a traditional [Unix timestamp](https://en.wikipedia.org/wiki/Unix_time) which has ten.

A convenient way to convert your date values to Unix millisecond timestamps is to use the `to_unix` function in the [template mapper](https://docs.hightouch.com/syncs/mapping-data.md#template-mapping).

![Field mapping in the Hightouch UI](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/mapping-data/mapping-data-template-map-to-unix.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=bfbbd7a126655eb59e551f0cd27097ed)

The `to_unix` function throws an error if the input row's value is `null`. To avoid this, you can enter this [Liquid](https://shopify.dev/docs/api/liquid) into the template mapper:

```liquid theme={null}
{%- if row['column_name'] == null -%}
{{null}}
{%- else -%}
{{row['column_name'] | to_unix}}
{%- endif -%}
```

Be sure to replace `column_name` with the name of your model column.
