> ## Documentation Index
> Fetch the complete documentation index at: https://orwel-22af1265.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# HubSpot

> Send every converted lead to HubSpot as a contact.

When a visitor converts on your site, Orwel creates or updates a contact in your HubSpot account, so sales can follow up from the CRM they already use.

## Connect

HubSpot retired API keys, so Orwel uses a **Private App** token.

<Steps>
  <Step title="Create a Private App in HubSpot">
    In HubSpot open **Settings, Integrations, Private Apps** and create an app (for example "Orwel").
  </Step>

  <Step title="Grant the contact scopes">
    In **Scopes**, enable `crm.objects.contacts.write` and `crm.objects.contacts.read`.
  </Step>

  <Step title="Copy the token">
    Create the app and copy its access token (it starts with `pat-`).
  </Step>

  <Step title="Paste it in Orwel">
    In the Orwel dashboard go to **Integrations**, open **HubSpot**, click **Configure**, paste the token in **Private App token** and save.
  </Step>
</Steps>

## What is sent

Each new conversion creates a contact with these fields, taken from the conversion properties or the visitor's identify traits:

| HubSpot property | Orwel field |
| - | - |
| `email` | `email` (required) |
| `firstname` | `firstName`, or `name` |
| `lastname` | `lastName` |
| `phone` | `phone` |
| `company` | `company` |

If a contact with that email already exists, Orwel updates it instead of failing, so a returning lead does not create a duplicate.

## When it runs

* Once per conversion. The same conversion retried by the SDK has the same `conversionId` and is not sent twice.
* Only for conversions that carry an email. A conversion without one is stored in Orwel but skipped for HubSpot.
* Never for conversions sent with the [development key](/guides/dev-mode). Test leads stay in Orwel.

```ts theme={null}
await orwel.conversion('demo_request', {
  email: 'ada@acme.com',
  name: 'Ada Lovelace',
  phone: '+52 55 1234 5678',
  company: 'Acme'
})
```

## Troubleshooting

| Problem | What to do |
| - | - |
| No contacts arrive | Check that the conversions include `email` and were sent with the production API key, not the development key. |
| HubSpot rejects the token | The token is wrong or the Private App lacks the contact scopes. Create a new token with `crm.objects.contacts.write` and `crm.objects.contacts.read`, and paste it again. |
| Name lands in the wrong field | Send `firstName` and `lastName` separately. With only `name`, the full name goes to `firstname`. |


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