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

# HubSpot

<div className="page-title-row">
  <img src="https://mintcdn.com/klef/xJ0kXbcegZOD2G3h/images/connectors/hubspot.svg?fit=max&auto=format&n=xJ0kXbcegZOD2G3h&q=85&s=5ad84ec33f49812011520d3c17e0a226" alt="" noZoom width="24" height="24" data-path="images/connectors/hubspot.svg" />

  <h1>HubSpot</h1>
</div>

## Connection

Connecting sends you to HubSpot to approve Klef's access.

### Permissions

Minimum permissions the connection requires.

| Capability                            | Required | Granted by (any one)                                                                               |
| ------------------------------------- | -------- | -------------------------------------------------------------------------------------------------- |
| Provision users                       | Yes      | `settings.users.read`, `settings.users.write`, `crm.objects.users.read`, `crm.objects.users.write` |
| Read teams                            | Yes      | `settings.users.teams.read`                                                                        |
| Assign seats and paid permission sets |          | `settings.billing.write`                                                                           |

## hubspot.user

### Fields

| Field                   | Type   | Required | Description                                                                                                               |
| ----------------------- | ------ | -------- | ------------------------------------------------------------------------------------------------------------------------- |
| `email`                 | string | Yes      | Email address the user signs in with. HubSpot does not change it once the user exists.                                    |
| `firstName`             | string |          | First name.                                                                                                               |
| `lastName`              | string |          | Last name.                                                                                                                |
| `role` (Permission set) | enum   |          | Permission set ID. One that carries a paid seat needs Klef's billing access.                                              |
| `primaryTeam`           | enum   |          | Team ID of the user's primary team.                                                                                       |
| `teams`                 | grant  |          | Teams the user belongs to besides their primary team. One row grants one team.                                            |
| `teams[]`               | string |          | Team ID.                                                                                                                  |
| `seats`                 | grant  |          | Paid seats assigned to the user, from those the account has bought. Needs Klef's billing access. One row grants one seat. |
| `seats[]`               | string |          | Seat name.                                                                                                                |
| `active`                | bool   |          | Whether the user is in the account. HubSpot has no inactive user, so switching this off removes the user.                 |

### Default Account Matching Rules

When Klef [adopts](/docs/adoption) an account that already exists in HubSpot, it works out whose it is by trying these in order. A connection can override them.

| Account field | Worker field            |
| ------------- | ----------------------- |
| `email`       | `worker.business_email` |

## Examples

### HubSpot users

A HubSpot user with the permission set and team their department maps to, removed when suspended or when they go.

```hcl theme={null}
stage active {
  target hubspot.user {
    email       = worker.business_email
    firstName   = worker.legal_name.given
    lastName    = worker.legal_name.family
    role        = lookup(table.hubspot_permission_sets, worker.department.name)
    primaryTeam = lookup(table.hubspot_teams, worker.department.name)
    active      = true
  }
}
```
