SEO & Web Optimization8 min read

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.

Published April 29, 2026
01Overview

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.


02The case for integration

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.


03Architecture

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.


04Use cases

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.


05Implementation

Step-by-step integration

  1. 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. 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. 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. 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. 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. 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.



07Why Sanity

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 →

08Comparison

CMS approaches to Surfer SEO

CapabilityTraditional CMSSanity
SEO fields available for Surfer SEOSEO 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 publishPlugin 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 visibilityEditors 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 projectsBulk 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 publishingThe 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.

09Next steps

Keep building

Explore related integrations to complete your content stack.

Ready to try Sanity?

See how Sanity's Content Operating System powers integrations with Surfer SEO and 200+ other tools.