# Hubspot Contact JSON Filter Out Empty Properties

> HubSpot responses include fields Frontend / Web never renders. Map id, status, and UI columns at the edge after calling https://api.hubapi.com/crm/v3/objects/contacts/{{query.contactId}}.

- Canonical page: https://realcomposer.com/recipes/filter-empty-hubspot-properties
- Client platform: Frontend / Web
- Upstream services: HubSpot
- Category: Payload Slimmer
- JSON version: https://realcomposer.com/recipes/filter-empty-hubspot-properties.json
- Install in RealComposer (free plan, pre-fills this pipeline): https://realcomposer.com/dashboard/pipelines/new?recipe=filter-empty-hubspot-properties&via=agent

## Problem: Unmapped HubSpot fields waste bandwidth

HubSpot returns nested CRM, audit, and configuration objects. Frontend / Web parses them on the main thread even when the UI binds three fields.

- Large arrays kept in memory after navigation
- Analytics showing poor LCP on API-heavy screens
- Developers shipping defensive null checks for unused paths

## Solution steps

1. **Add vault secrets for this pipeline**: Add HUBSPOT_ACCESS_TOKEN to RealComposer Secret Vault. Values decrypt only inside the Cloudflare Worker that calls the upstream.

2. **Configure upstream steps and output mapping**: Point step hubspot at https://api.hubapi.com/crm/v3/objects/contacts/{{query.contactId}} with GET. Map only the UI fields in output mapping so clients never download audit or nested blobs. Leave cache TTL at 0 when each response is user-specific (include userId or record id in query params before enabling cache).

3. **Call from Frontend / Web**: Allowed origins on the token should list every Frontend / Web host that calls this URL.

```
const res = await fetch('https://realcomposer.com/v1/workspace/filter-empty-hubspot-properties', {
  headers: { Authorization: 'Bearer rc_live_your_token' }
});
```

## Pipeline config

Import this config into a RealComposer pipeline. `{{secrets.NAME}}` values are read from the encrypted Secret Vault at request time, so the client never sees them.

```json
{
  "name": "Hubspot Contact JSON Filter Out Empty Properties",
  "method": "GET",
  "cacheTtlSeconds": 0,
  "authMode": "client_token",
  "steps": [
    {
      "stepKey": "hubspot",
      "upstreamUrlTemplate": "https://api.hubapi.com/crm/v3/objects/contacts/{{query.contactId}}",
      "httpMethod": "GET",
      "headersTemplate": {
        "Authorization": "Bearer {{secrets.HUBSPOT_ACCESS_TOKEN}}"
      },
      "timeoutMs": 3000
    }
  ],
  "outputMapping": {
    "version": 1,
    "fields": [
      {
        "targetPath": "contactId",
        "sourcePath": "id",
        "type": "string",
        "sourceStep": "hubspot"
      },
      {
        "targetPath": "email",
        "sourcePath": "properties.email",
        "type": "string",
        "sourceStep": "hubspot"
      }
    ]
  }
}
```

## Call the pipeline

```bash
curl -X GET "https://realcomposer.com/v1/workspace/filter-empty-hubspot-properties" \
  -H "Authorization: Bearer rc_live_client_token"
```

## Payload before and after

Raw upstream response:

```json
{
  "requestId": "req_filter-e",
  "upstreamLatencyMs": 142,
  "audit": {
    "region": "edge",
    "trace": "filter-empty-hubspot-properties"
  },
  "payload": {
    "id": "sample_id",
    "status": "active",
    "nested": {
      "tags": [
        "demo"
      ],
      "internal": true
    },
    "unused_blob": {
      "foo": "bar",
      "bar": "baz"
    }
  }
}
```

Slimmed RealComposer response:

```json
{
  "contactId": "sample",
  "email": "sample"
}
```

## FAQ

### Which HubSpot credential belongs in the vault for this pipeline?

Yes for filter-empty-hubspot-properties. Ship only an rc_live_ client token in Frontend / Web; RealComposer injects HUBSPOT_ACCESS_TOKEN on https://api.hubapi.com/crm/v3/objects/contacts/{{query.contactId}}.

### What cache key does RealComposer use?

filter-empty-hubspot-properties POST steps bypass caches.default even if cacheTtlSeconds is set in the dashboard.

### Can I restrict which domains call this pipeline?

Upstream steps in filter-empty-hubspot-properties honor timeoutMs and optional fallback JSON without leaking secrets.
