---
title: "Connect HubSpot"
description: "Saves the workspace's HubSpot service key (or a legacy private app's access token) in token, checked with HubSpot first: the account it's for and the scopes…"
canonical_url: https://docs.markdrop.in/api/hubspot/connect-hubspot
last_updated: 2026-11-20
site: "Markdrop Docs"
index: https://docs.markdrop.in/llms.txt
---

# Connect HubSpot

`PUT https://api.markdrop.in/api/v1/hubspot/connection`

Saves the workspace's HubSpot service key (or a legacy private app's access token) in `token`, checked with HubSpot first: the account it's for and the scopes it has. A blank `token` checks the saved one again. Optional `team_id`: the team whose calls go to HubSpot. One HubSpot account connects to one workspace (409 otherwise); 400 when HubSpot doesn't accept the key. Admins and owners.

- **Authentication:** API token required: `Authorization: Bearer mdk_…`.
- **Rate limit:** 20 per minute per IP address.
- **Guide:** [HubSpot](https://docs.markdrop.in/integrations/hubspot#set-up-hubspot)

## Request body

`application/json`, required.

- `workspace_id` (string, required): Matches `^[0-9a-f]{24}$`.
- `token` (string): A HubSpot service key or private app access token. Blank: keep the saved one. Up to 600 characters.
- `team_id` (string): Matches `^([0-9a-f]{24})?$`.

## Responses

- `200`: OK.
- `401`: No token, or the token is revoked or mistyped.
- `422`: The request didn't validate. `detail` lists each problem, with where it is (`loc`) and why (`msg`).
- `429`: Too many requests from your IP address. Wait the seconds in `Retry-After`.

## Examples

**curl**

```bash
curl -X PUT https://api.markdrop.in/api/v1/hubspot/connection \
  -H "Authorization: Bearer $MARKDROP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"workspace_id":"WORKSPACE_ID"}'
```

**JavaScript**

```javascript
const res = await fetch("https://api.markdrop.in/api/v1/hubspot/connection", {
  method: "PUT",
  headers: {
    Authorization: `Bearer ${process.env.MARKDROP_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "workspace_id": "WORKSPACE_ID"
  }),
});
const data = await res.json();
```

**Python**

```python
import os

import requests

r = requests.put(
    "https://api.markdrop.in/api/v1/hubspot/connection",
    headers={"Authorization": f"Bearer {os.environ['MARKDROP_TOKEN']}"},
    json={"workspace_id": "WORKSPACE_ID"},
)
r.raise_for_status()
print(r.json())
```
