Overview
The HubSpot integration allows you to:- Connect your HubSpot portal via OAuth
- Sync website pages and blog posts
- Get SEO recommendations based on LatentGEO audits
- Apply fixes directly to HubSpot content
- Rollback changes if needed
OAuth Setup Workflow
Request Authorization URL
Call the Response:The
/api/hubspot/auth-url endpoint with your JWT bearer token:state parameter is a signed, time-limited token (valid for 10 minutes) that prevents CSRF attacks.Redirect User to HubSpot
Redirect your user to the returned
url. They’ll authorize your app to access their HubSpot portal.Handle OAuth Callback
HubSpot redirects back with a Response:
code and state. Post these to /api/hubspot/callback:OAuth Security Contract
Security Features
- User binding: State tokens are tied to the authenticated user
- Time-limited: Tokens expire after 10 minutes
- Signature verification: HMAC-SHA256 prevents tampering
- Cross-user protection: Callbacks validate the user matches the original requester
Connecting HubSpot Accounts
List Connections
Retrieve all active HubSpot connections for the authenticated user:Sync Pages
Pull the latest pages and blog posts from your HubSpot portal:- Website pages
- Blog posts
- Landing pages
- Meta information (title, description)
Get Pages
List all synced pages:Getting SEO Recommendations
LatentGEO generates actionable recommendations based on your audit results.Generate Recommendations
Get recommendations for all pages that match an audit:Recommendation Fields
field: The HubSpot field to update (e.g.,meta_description,html_title)current_value: The existing value in HubSpotrecommended_value: The AI-suggested improvementpriority: Importance level (high,medium,low)auto_fixable: Whether the fix can be applied automaticallyissue_type: The SEO issue being addressed
Applying SEO Recommendations
Batch Apply
Apply multiple recommendations at once:Single Change
Apply a single change to a page:All changes are tracked in the database, allowing you to see the history of modifications and rollback if needed.
Rollback Capabilities
If a change doesn’t work as expected, you can easily revert it.Rollback a Change
- LatentGEO retrieves the original value before the change
- Applies the old value back to HubSpot
- Creates a new change record marking the rollback
- Updates the original change status to
rolled_back
Change Tracking
Every modification to HubSpot content is recorded with:change_id: Unique identifierpage_id: The affected HubSpot pagefield: Which field was modifiedold_value: Value before the changenew_value: Value after the changestatus:applied,failed, orrolled_backaudit_id: The audit that triggered the changeapplied_at: Timestamp of the change
Webhook Events
LatentGEO can receive HubSpot webhooks to stay in sync with your portal. See the Webhooks page for setup details.
contact.creation: New contact addedcontact.propertyChange: Contact property updateddeal.creation: New deal created
Supported Fields
LatentGEO can modify the following HubSpot fields:| Field | Description | Example |
|---|---|---|
html_title | Page title (appears in browser tab) | “10 SEO Tips | Example” |
meta_description | Meta description for search results | ”Learn the top 10 SEO tips…” |
page_title | Internal page name in HubSpot | ”SEO Tips Blog Post” |
Support for additional fields (canonical URLs, schema markup, social meta tags) is coming soon.
Common Errors
401 Unauthorized
- Missing or invalid JWT token
- OAuth state token expired or tampered with
- User mismatch between OAuth start and callback
403 Forbidden
- Attempting to access another user’s connection
- Legacy ownerless connection in production mode
- Cross-portal access attempt
404 Not Found
- Connection, page, or change not found
- HubSpot page was deleted from portal
400 Bad Request
- Cannot rollback a change that isn’t in
appliedstatus - Invalid field name
- Portal ID mismatch
Best Practices
- Test recommendations first: Review AI suggestions before bulk applying
- Sync regularly: Keep your page data fresh with periodic syncs
- Monitor change history: Track which recommendations improved performance
- Use rollback wisely: Revert changes that don’t work, but give them time to take effect
- Match audit URLs: Ensure audit URLs match HubSpot page URLs for accurate recommendations
- Batch operations: Apply multiple changes at once for efficiency
Matching Audits to HubSpot Pages
For recommendations to work, LatentGEO matches audit results to HubSpot pages by URL:Next Steps
Webhooks
Set up webhook integrations for automation
GitHub Integration
Connect GitHub to audit blog content