# Preview CRM import

Preview counts and sample labels for the connected HubSpot CRM before importing. This reads the available object types without creating or updating Brigg records.

POST https://api.brigg.app/v1/operations/customers.PreviewCrmImport

## Access & visibility

Allow `customers.PreviewCrmImport` on your API key.

**Workspace access by default.** Private member data requires [approved member delegation](https://developer.brigg.app/authentication#member-delegation) through `Brigg-Act-As`; the key supplies permissions while private ownership and project boundaries remain enforced.

[Set up authentication](https://developer.brigg.app/authentication) · [Choose permissions](https://developer.brigg.app/permissions)

## Request

No parameters. Send an empty JSON object (`{}`).

## Import from a connected CRM

Use [Get CRM import status](https://developer.brigg.app/reference/customers/GetCrmImportStatus) to inspect the HubSpot connection, supported objects and the most recent run. [Preview CRM import](https://developer.brigg.app/reference/customers/PreviewCrmImport) reads a sample without writing contacts. A missing provider scope requires reconnecting in Brigg; an API grant cannot supply missing provider consent.

Start the connected-CRM import in Brigg. [Get CRM import run](https://developer.brigg.app/reference/customers/GetCrmImportRun) reads its progress and detailed report. Review created, updated, skipped and not-imported counts; a finished run does not mean every source object was supported.

To import through the public API, use [Start record import](https://developer.brigg.app/reference/integrations/StartRecordImport) with a file and permanent external references. That workflow keeps the credential’s approved operation and resource permissions throughout background processing.

## Response

Returns **200 OK** with a JSON body.

This operation has no continuation cursor. An empty `items` array means no matching visible results were returned.

A preview can partially succeed. Check every row's missing_scope before selecting categories. A zero count without missing_scope may mean no records or a per-category provider read failure; the preview is advisory, not proof that the CRM is empty. Only open tasks are candidates. No Brigg records are changed.
| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `items` | array of [CRM import preview](#crm-import-preview-response-items) | Yes | Source records available for preview from the connected CRM. This does not import them. This operation has no cursor pagination. |

### CRM import preview · response.items[]

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `object` | string | Yes | HubSpot object category: companies, contacts, deals, notes or tasks. Choose the categories to import later when starting the run. |
| `total` | number | Yes | Estimated importable count for this category. Known skipped records in the fetched preview page are deducted, so larger sets may still overestimate; use the completed run report for actual counts. Zero can also accompany a per-category provider failure. |
| `samples` | array of string | Yes | Up to three human-readable labels from candidate records, not record IDs or full objects. These help recognize the source data, not address individual import items. |
| `missing_scope` | string | No | When present, this category could not be previewed because the connection lacks this provider scope. Its total is zero and samples is empty; this does not prove the source category has no data. Other categories can still be available. |

## Errors & retries

Set `BRIGG_REQUEST_ID` once for each logical action. The samples send it as `Idempotency-Key`. Reuse the same value and body on retries, including after a timeout; a missing response does not prove the action failed.

For rate limits, follow the server’s retry guidance and back off. See [HTTP errors](https://developer.brigg.app/http#errors) and [safe retries and limits](https://developer.brigg.app/reliability).

| HTTP status | Code | What to do |
| --- | --- | --- |
| 400 | `invalid_json` | Send a JSON object with Content-Type: application/json. |
| 400 | `invalid_input` | Check the request fields and types. Supply a stable Idempotency-Key containing 1–200 characters. |
| 401 | `invalid_key` | The workspace API key is missing, invalid or revoked. |
| 403 | `forbidden` | Check the key’s operation and resource grants. If Brigg-Act-As is supplied, the key must be authorized to delegate to that member. |
| 404 | `not_found` | The requested operation or resource is not available to this credential. |
| 429 | `rate_limited` | Wait for Retry-After before retrying. Reuse the original Idempotency-Key. |
| 409 | `not_connected` | Connect the workspace HubSpot account in Brigg first. |
| 409 | `auth_expired` | Renew the HubSpot connection before previewing again. |

## Next steps

- [Get CRM import status](https://developer.brigg.app/reference/customers/GetCrmImportStatus)
- [Get CRM import run](https://developer.brigg.app/reference/customers/GetCrmImportRun)

[Download OpenAPI](https://developer.brigg.app/openapi.json) · [Versioning & retirement](https://developer.brigg.app/versioning)

## Examples

### Some categories need more provider access

Use available rows to plan the import. Reconnect with the needed provider scopes before selecting a blocked category.
#### cURL


```sh
curl 'https://api.brigg.app/v1/operations/customers.PreviewCrmImport' \
  -H "Authorization: Bearer $BRIGG_API_KEY" \
  -H 'Content-Type: application/json' \
  -H "Idempotency-Key: $BRIGG_REQUEST_ID" \
  --data-raw '{}'
```

#### TypeScript


```typescript
const requestId = process.env.BRIGG_REQUEST_ID;
if (!requestId) throw new Error("Set BRIGG_REQUEST_ID once per action and reuse it on retries.");

const response = await fetch("https://api.brigg.app/v1/operations/customers.PreviewCrmImport", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BRIGG_API_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": requestId, // Create once per action; reuse on retries.
  },
  body: JSON.stringify({}),
});
const result = await response.json();
if (!response.ok) throw new Error(`${response.status}: ${result.error} — ${result.message}`);
console.log(result);
```

#### Python


```python
import json
import os
from urllib.request import Request, urlopen
from urllib.error import HTTPError

request_id = os.environ["BRIGG_REQUEST_ID"]  # Reuse for retries of this action.
payload = {}
request = Request(
    "https://api.brigg.app/v1/operations/customers.PreviewCrmImport",
    data=json.dumps(payload).encode("utf-8"),
    headers={
        "Authorization": f"Bearer {os.environ['BRIGG_API_KEY']}",
        "Content-Type": "application/json",
        "Idempotency-Key": request_id,  # Create once per action; reuse on retries.
    },
    method="POST",
)
try:
    with urlopen(request) as response:
        print(json.load(response))
except HTTPError as error:
    print(error.code, json.load(error))
    raise
```

#### Response example


```json
{
  "items": [
    {
      "object": "companies",
      "total": 42,
      "samples": [
        "Northstar Ltd",
        "Harbor Studio"
      ]
    },
    {
      "object": "contacts",
      "total": 86,
      "samples": [
        "Alex Morgan",
        "Sam Lee"
      ]
    },
    {
      "object": "deals",
      "total": 0,
      "samples": [],
      "missing_scope": "crm.objects.deals.read"
    },
    {
      "object": "notes",
      "total": 12,
      "samples": [
        "Pilot planning notes"
      ]
    },
    {
      "object": "tasks",
      "total": 8,
      "samples": [
        "Confirm kickoff date"
      ]
    }
  ]
}
```

## JSON schemas


```json-schema-request
{
  "type": "object",
  "properties": {},
  "additionalProperties": false,
  "examples": [
    {}
  ]
}
```


```json-schema-response
{
  "type": "object",
  "properties": {
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string",
            "description": "HubSpot object category: companies, contacts, deals, notes or tasks. Choose the categories to import later when starting the run.",
            "examples": [
              "companies"
            ]
          },
          "total": {
            "type": "number",
            "description": "Estimated importable count for this category. Known skipped records in the fetched preview page are deducted, so larger sets may still overestimate; use the completed run report for actual counts. Zero can also accompany a per-category provider failure.",
            "examples": [
              12
            ]
          },
          "samples": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Up to three human-readable labels from candidate records, not record IDs or full objects. These help recognize the source data, not address individual import items.",
            "examples": [
              [
                "Northwind Consulting AS"
              ]
            ]
          },
          "missing_scope": {
            "type": "string",
            "description": "When present, this category could not be previewed because the connection lacks this provider scope. Its total is zero and samples is empty; this does not prove the source category has no data. Other categories can still be available.",
            "examples": [
              "crm.objects.companies.read"
            ]
          }
        },
        "required": [
          "object",
          "total",
          "samples"
        ],
        "additionalProperties": false,
        "title": "CRM import preview"
      },
      "description": "Source records available for preview from the connected CRM. This does not import them. This operation has no cursor pagination."
    }
  },
  "required": [
    "items"
  ],
  "additionalProperties": false,
  "examples": [
    {
      "items": [
        {
          "object": "companies",
          "total": 42,
          "samples": [
            "Northstar Ltd",
            "Harbor Studio"
          ]
        },
        {
          "object": "contacts",
          "total": 86,
          "samples": [
            "Alex Morgan",
            "Sam Lee"
          ]
        },
        {
          "object": "deals",
          "total": 0,
          "samples": [],
          "missing_scope": "crm.objects.deals.read"
        },
        {
          "object": "notes",
          "total": 12,
          "samples": [
            "Pilot planning notes"
          ]
        },
        {
          "object": "tasks",
          "total": 8,
          "samples": [
            "Confirm kickoff date"
          ]
        }
      ]
    }
  ]
}
```

