How to Integrate Surfer SEO with Your Headless CMS
Connect Surfer SEO to your headless CMS so every published article can create briefs, refresh SERP-driven guidelines, and send editors back a measurable content score.
What is Surfer SEO?
Surfer SEO is an SEO platform used by content, editorial, and growth teams to plan, write, and score search-focused pages. Its core workflow centers on keyword research, Content Editor briefs, SERP analysis, topic suggestions, and content scoring based on competing pages. Teams often use Surfer SEO when they need repeatable guidance for articles, landing pages, product guides, and content refreshes.
Why integrate Surfer SEO with a headless CMS?
If your editors write in one place and check Surfer SEO in another, SEO work turns into copy, paste, score, revise, and repeat. A 40-article refresh project can mean hundreds of manual checks across target keywords, URLs, meta titles, headings, and body copy. That slows down publishing, and it makes it easy for the Surfer SEO brief, the published page, and the source content to drift apart.
Architecture overview
A typical Sanity and Surfer SEO integration starts when an editor publishes or updates an article in Sanity Studio. A webhook fires on the publish event, or a Function runs directly from the content mutation. The handler receives the document ID, then uses @sanity/client and a GROQ query to fetch only the fields Surfer SEO needs, such as title, slug, targetKeyword, metaDescription, locale, canonical URL, and Portable Text body converted to plain text. The server-side handler calls Surfer SEO's REST API with your Surfer API key, usually to create or update a Content Editor brief for the target keyword, country, language, and device. The response can be written back to Sanity as fields like surferContentEditorId, surferShareUrl, and lastSurferSyncAt, so editors can open the exact Surfer SEO brief from Sanity Studio. From there, the same structured article powers the website, preview experience, Surfer SEO workflow, mobile app, and any AI agent that reads approved content through Agent Context.
Common use cases
Create Surfer Content Editor briefs from Sanity
When an editor adds a target keyword and publishes a draft, create a Surfer SEO brief and save the Surfer document link back to the article.
Run content refresh workflows
Trigger Surfer SEO checks when older pages are updated, so refresh projects track the current keyword, URL, title, and body copy.
Handle locale-specific SEO briefs
Send locale, country, language, and device settings from Sanity fields to Surfer SEO so US English, UK English, and German pages get separate guidance.
Show SEO status inside Sanity Studio
Store Surfer SEO brief IDs, share URLs, sync timestamps, and score fields next to editorial fields so writers don't hunt through separate tools.
Step-by-step integration
- 1
Set up Surfer SEO API access
Create or use an existing Surfer SEO workspace, confirm that API access is available on your plan, and generate an API key from your Surfer account settings or through your Surfer workspace admin. Keep the key server-side only.
- 2
Install the Sanity client and configure secrets
Install @sanity/client in your Function, webhook listener, or middleware project. Add SANITY_PROJECT_ID, SANITY_DATASET, SANITY_READ_TOKEN, SURFER_API_KEY, and SURFER_API_BASE_URL as environment variables.
- 3
Model SEO fields in Sanity Studio
Add fields such as targetKeyword, seoTitle, metaDescription, locale, canonicalUrl, surferContentEditorId, surferShareUrl, lastSurferSyncAt, and surferScore to your article schema. Keep the article body as Portable Text so you can query and convert it cleanly.
- 4
Create the sync trigger
Use a GROQ-filtered webhook for article publish events, or use Functions to run server-side sync logic on mutations without a separate worker. Filter out documents without a targetKeyword to avoid unnecessary Surfer SEO calls.
- 5
Call Surfer SEO from the server
Fetch the article with GROQ, build the Surfer SEO payload from structured fields, and call Surfer SEO's REST API with your API key. If your Surfer account uses different endpoint names or region-specific base URLs, follow the endpoint list in your Surfer API documentation.
- 6
Test the editor and frontend flow
Publish a test article with a target keyword, confirm that Surfer SEO creates the brief, verify that the Surfer URL appears in Sanity Studio, and render the SEO fields on your frontend with the same content that was sent to Surfer SEO.
How Sanity + Surfer SEO works
Build your Surfer SEO integration on Sanity
Sanity gives you the structured content foundation, real-time event system, and flexible APIs to connect Surfer SEO with the way your team publishes.
Start building free →CMS approaches to Surfer SEO
| Capability | Traditional CMS | Sanity |
|---|---|---|
| SEO fields available for Surfer SEO | SEO data often lives in plugin fields or rendered HTML, so integrations may need page scraping or custom exports. | GROQ can return article fields, referenced metadata, locale settings, and canonical URLs in one shaped response. |
| Sync on publish | Plugin hooks can work, but they are often tied to a specific theme, plugin stack, or server environment. | Webhooks can fire on publish events, and Functions can run the Surfer SEO sync logic without separate infrastructure. |
| Editor visibility | Editors may switch between the editing screen, Surfer SEO, spreadsheets, and browser tabs to track score and brief links. | Sanity Studio is React-based, so you can add Surfer SEO links, sync status, and score fields directly where editors work. |
| Content refresh projects | Bulk refreshes often rely on exports, manual keyword mapping, and reimported plugin fields. | Content Releases, Tasks, GROQ filters, and structured fields can support refresh batches by keyword, date, score, or page type. |
| Multi-channel publishing | The website is usually the primary target, and other channels often need separate feeds or plugins. | One structured back end can feed web, mobile, Surfer SEO, and AI agents through APIs and Agent Context. |
Keep building
Explore related integrations to complete your content stack.
Sanity + Google Search Console
Connect search performance data to structured content so teams can find pages with falling clicks, rising impressions, or keyword gaps.
Sanity + Semrush
Bring keyword research, ranking data, and competitive signals into editorial planning workflows built around Sanity content.
Sanity + Clearscope
Pair structured Sanity articles with Clearscope reports for topic coverage, content grading, and refresh planning.