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

# HubDB CLI commands

> Learn about HubDB CLI commands.

export const Tag = ({children, type = 'default', className = ''}) => {
  return <span className={`tag tag-${type} ${className}`.trim()}>
      {children}
    </span>;
};

The commands below are available for interacting with [HubDB](/api-reference/legacy/cms/hubdb/guide) using the HubSpot CLI.

Use these commands to create, delete, fetch, and clear all rows of a HubDB table. The HubSpot account must have access to HubDB to use these commands.

## Create HubDB table

Create a new HubDB table in the HubSpot account.

```shell theme={null}
hs hubdb create --path [path] --account [account]
```

**Flags**

| Flag                                      | Description                                                                                                                                  |
| ----------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `--path` <Tag type="error">Required</Tag> | The local [JSON file](#hubdb-table-json) to use to generate the HubDB table.                                                                 |
| `--account`                               | Specify a `accountId` or name to create HubDB in. Supports an alias of `--portal` for backward compatibility with older versions of the CLI. |

## Fetch HubDB Table

Download a HubDB table's data to your local machine.

```shell theme={null}
hs hubdb fetch <table-id> <dest>
```

**Arguments**

| Argument                                    | Description                                                                     |
| ------------------------------------------- | ------------------------------------------------------------------------------- |
| `table-id` <Tag type="error">Required</Tag> | HubDB table id found in the HubDB dashboard.                                    |
| `dest`                                      | The local path destination to store the [`hubdb.json`](#hubdb-table-json) file. |

When you fetch a HubDB the data is stored as `tablename.hubdb.json`. When you create a new table you must specify a source JSON file. Below is an example of a table in JSON format.

```json theme={null}
{
  "name": "store_locations",
  "useForPages": true,
  "label": "Store locations",
  "allowChildTables": false,
  "allowPublicApiAccess": true,
  "dynamicMetaTags": { "DESCRIPTION": 3, "FEATURED_IMAGE_URL": 7 },
  "enableChildTablePages": false,
  "columns": [
    { "name": "name", "label": "Name", "type": "TEXT" },
    {
      "name": "physical_location",
      "label": "Physical Location",
      "type": "LOCATION"
    },
    { "name": "street_address", "label": "Street address", "type": "TEXT" },
    { "name": "city", "label": "City", "type": "TEXT" },
    {
      "name": "state",
      "label": "State",
      "options": [
        { "id": 1, "name": "Wisconsin", "type": "option", "order": null },
        { "id": 2, "name": "Minnesota", "type": "option", "order": null },
        { "id": 3, "name": "Maine", "type": "option", "order": null },
        { "id": 4, "name": "New York", "type": "option", "order": null },
        { "id": 5, "name": "Massachusetts ", "type": "option", "order": null },
        { "id": 6, "name": "Mississippi", "type": "option", "order": null },
        { "id": 7, "name": "Arkansas", "type": "option", "order": null },
        { "id": 8, "name": "Texas", "type": "option", "order": null },
        { "id": 9, "name": "Florida", "type": "option", "order": null },
        { "id": 10, "name": "South Dakota", "type": "option", "order": null },
        { "id": 11, "name": "North Dakota", "type": "option", "order": null },
        { "id": 12, "name": "n/a", "type": "option", "order": null }
      ],
      "type": "SELECT",
      "optionCount": 12
    },
    { "name": "phone_number", "label": "Phone Number", "type": "TEXT" },
    { "name": "photo", "label": "Store Photo", "type": "IMAGE" }
  ],
  "rows": [
    {
      "path": "super_store",
      "name": "Super Store",
      "isSoftEditable": false,
      "values": {
        "name": "Super Store",
        "physical_location": {
          "lat": 43.01667,
          "long": -88.00608,
          "type": "location"
        },
        "street_address": "1400 75th Greenfield Ave",
        "city": "West Allis",
        "state": { "id": 1, "name": "Wisconsin", "type": "option", "order": 0 },
        "phone_number": "(123) 456-7890"
      }
    },
    {
      "path": "store_123",
      "name": "Store #123",
      "isSoftEditable": false,
      "values": {
        "name": "Store #123",
        "physical_location": {
          "lat": 32.094803,
          "long": -166.85889,
          "type": "location"
        },
        "street_address": "Pacific Ocean",
        "city": "at sea",
        "state": { "id": 12, "name": "n/a", "type": "option", "order": 11 },
        "phone_number": "(123) 456-7891"
      }
    }
  ]
}
```

## Clear rows in a HubDB table

Clear all of the rows in a HubDB table.

```shell theme={null}
hs hubdb clear <tableId>
```

**Arguments**

| Argument                                   | Description                                  |
| ------------------------------------------ | -------------------------------------------- |
| `tableId` <Tag type="error">Required</Tag> | HubDB table id found in the HubDB dashboard. |

**Flags**

| Flag        | Description                                                                                                                                       |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--account` | Specify a `accountId` or name to clear HubDB rows from.Supports an alias of `--portal` for backward compatibility with older versions of the CLI. |

## Delete HubDB table

Deletes the specified HubDB table from the account. You will be prompted to confirm the deletion before proceeding. You can use the `--force` flag to bypass this confirmation.

```shell theme={null}
hs hubdb delete <table-id>
```

**Arguments**

| Argument                                    | Description                                  |
| ------------------------------------------- | -------------------------------------------- |
| `table-id` <Tag type="error">Required</Tag> | HubDB table ID found in the HubDB dashboard. |

**Flags**

| Flag        | Description                                                                                                                                    |
| ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `--account` | Specify a `accountId` or name to delete HubDB from. Supports an alias of `--portal` for backward compatibility with older versions of the CLI. |
| `--force`   | Bypass the confirmation prompt and immediately delete the table once the command is executed.                                                  |
