{
  "slug": "hubspot-api-client-proxy",
  "title": "Call Hubspot API from Client Side Web Application",
  "metaTitle": "Call Hubspot API from Client Side - RealComposer",
  "metaDescription": "Call hubspot api from client side web application. Keep HubSpot keys in RealComposer Vault; Frontend / Web uses rc_live_ tokens only.",
  "headline": "HubSpot secrets stay out of Frontend / Web bundles",
  "category": "security",
  "categoryLabel": "Security & Secret Vault",
  "urgency": 9,
  "clientPlatform": "Frontend / Web",
  "upstreamServices": [
    "HubSpot"
  ],
  "searchIntentQuery": "call hubspot api from client side web application",
  "directAnswerSummary": "Frontend / Web cannot safely store HubSpot production keys. Vault-bound headers reach https://api.hubapi.com/crm/v3/objects/contacts/{{query.contactId}} on Workers while apps call your hubspot-api-client-proxy edge URL.",
  "problem": {
    "title": "Why Frontend / Web leaks HubSpot credentials",
    "explanation": "Attackers routinely extract HubSpot secrets from Frontend / Web builds. Direct browser calls also expose internal error payloads with hostnames.",
    "risks": [
      "Production HubSpot keys copied from Frontend / Web bundles",
      "Compliance violations after credential leaks",
      "Attackers replaying vault-grade scopes from a laptop"
    ]
  },
  "solutionSteps": [
    {
      "stepNumber": 1,
      "title": "Store upstream credentials in Secret Vault",
      "description": "Add HUBSPOT_ACCESS_TOKEN to RealComposer Secret Vault. Values decrypt only inside the Cloudflare Worker that calls the upstream."
    },
    {
      "stepNumber": 2,
      "title": "Target the real upstream URL",
      "description": "Use GET against https://api.hubapi.com/crm/v3/objects/contacts/{{query.contactId}}. Allowed origins on the client token should match leave cache ttl at 0 when each response is user-specific (include userid or record id in query params before enabling cache)."
    },
    {
      "stepNumber": 3,
      "title": "Call from Frontend / Web",
      "description": "Allowed origins on the token should list every Frontend / Web host that calls this URL.",
      "codeSnippet": "const res = await fetch('https://realcomposer.com/v1/workspace/hubspot-api-client-proxy', {\n  headers: { Authorization: 'Bearer rc_live_your_token' }\n});"
    }
  ],
  "pipelineConfig": {
    "name": "Call Hubspot API from Client Side Web Application",
    "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"
        }
      ]
    }
  },
  "sampleBloatedInput": {
    "requestId": "req_hubspot-",
    "upstreamLatencyMs": 142,
    "audit": {
      "region": "edge",
      "trace": "hubspot-api-client-proxy"
    },
    "payload": {
      "id": "sample_id",
      "status": "active",
      "nested": {
        "tags": [
          "demo"
        ],
        "internal": true
      },
      "unused_blob": {
        "foo": "bar",
        "bar": "baz"
      }
    }
  },
  "sampleSlimmedOutput": {
    "contactId": "sample",
    "email": "sample"
  },
  "curlSnippet": "curl -X GET \"https://realcomposer.com/v1/workspace/hubspot-api-client-proxy\" \\\n  -H \"Authorization: Bearer rc_live_client_token\"",
  "faqs": [
    {
      "question": "Can Frontend / Web call HubSpot without holding the production key?",
      "answer": "Point Frontend / Web at /recipes/hubspot-api-client-proxy edge URL. RealComposer answers OPTIONS with Access-Control headers for allowed origins."
    },
    {
      "question": "Does POST traffic get cached?",
      "answer": "hubspot-api-client-proxy POST steps bypass caches.default even if cacheTtlSeconds is set in the dashboard."
    },
    {
      "question": "What happens if an upstream step times out?",
      "answer": "Upstream steps in hubspot-api-client-proxy honor timeoutMs and optional fallback JSON without leaking secrets."
    }
  ],
  "relatedRecipeSlugs": [
    "rest-api-mobile-network-optimization",
    "merge-linear-and-github-pr-api",
    "algolia-write-api-secure-proxy"
  ],
  "updatedAt": "2026-11-20",
  "links": {
    "page": "https://realcomposer.com/recipes/hubspot-api-client-proxy",
    "markdown": "https://realcomposer.com/recipes/hubspot-api-client-proxy.md",
    "json": "https://realcomposer.com/recipes/hubspot-api-client-proxy.json",
    "install": "https://realcomposer.com/dashboard/pipelines/new?recipe=hubspot-api-client-proxy&via=agent"
  }
}