Joint session with Vercel: How to build intelligent storefronts (May 15th)

Syncing external database tags to Sanity one-way with additional fields

7 repliesLast updated: Nov 29, 2025

Hello! I have a high-level, architectural approach question for folks who have tied Sanity pretty closely to existing / external systems.
Imagine a platform that has several existing pieces of data in a database. For example, let's say that they're `tags`: they have a
label
and a
slug
.
These tags are in use, and already managed through a few admin forms. The intent is to keep them managed through these forms.

I'd love to keep these tags in sync, one-way, in Sanity, with the addition of an
image
to their schema.
A few questions:

1. Is this possible?
◦ It seems straight-forward enough to add or update a tag in Sanity from the existing system. The main unknown for me is the slight mutation of schema with the additional
image
. Are there traps there?2. Is this advisable?
◦ I know it introduces complexity to the system, but allows editorial additions to a schema that the external system doesn't care about. Different roles are managing tags and content, and editorial shouldn't be in control of these particular tags.
Any additional info that'd help? Are there variables I'm not considering? Thanks for any insight you can provide!
AI Update

This is absolutely possible and a pretty common pattern! You're essentially looking to create a one-way sync from your existing system to Sanity, where Sanity acts as an "enrichment layer" for your tags. Let me break down your questions:

1. Is this possible?

Yes, very straightforward. The schema mutation you're describing (adding an image field in Sanity that doesn't exist in your source system) is actually one of the main benefits of this pattern. Here's how it works:

Your Sanity schema would look something like:

{
  name: 'tag',
  type: 'document',
  fields: [
    {name: 'label', type: 'string', readOnly: true},
    {name: 'slug', type: 'slug', readOnly: true},
    {name: 'image', type: 'image'} // Editorial addition
  ]
}

The sync process from your external system would only touch label and slug, leaving image completely under editorial control. You can use the Sanity client to create or update documents.

Key trap to avoid: Use createOrReplace() carefully or use patch() instead. With createOrReplace(), you'll completely replace the document, which would wipe out the image if editors added one. Better approach:

await client
  .patch(externalTag.id)
  .set({label: externalTag.label, slug: {current: externalTag.slug}})
  .commit()

This way, only the fields you explicitly set are updated, preserving the editorial image field.

2. Is this advisable?

Yes, this is a well-established pattern at Sanity. In fact, Sanity Connect for Shopify works exactly this way - syncing product data from Shopify while allowing editors to enrich it with additional fields in Sanity.

Benefits of this approach:

Implementation recommendations:

Additional variables to consider:

This pattern is battle-tested and gives you the best of both worlds - operational control where it matters and editorial flexibility where you need it. The guide on integrating external data sources provides more detailed examples of sync implementations if you need them!

Show original thread
7 replies

Was this answer helpful?

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Related contributions