DEV Community

Cover image for I Turned Sanity Into a Social Content Operating System That Publishes to Instagram
Leandro Barbosa
Leandro Barbosa

Posted on

I Turned Sanity Into a Social Content Operating System That Publishes to Instagram

Sanity Challenge Path Two Submission

This is a submission for the Sanity Challenge, Path Two: Vibe-Code Something Strange

What I Built

I built Sanity Social, a social content operating system for agencies.
Instead of using Sanity only as a CMS, I used it to manage the complete lifecycle of social content: client brand guidelines, campaigns, AI-assisted drafting, editorial review, approval, scheduling, and finally publishing directly to Instagram.
A post moves through:
Idea → Draft → Internal Review → Client Review → Approved → Instagram
The final version isn't a mock integration. I connected a real Instagram Business account through Meta OAuth and successfully published an approved post from the Sanity application directly to Instagram.

Demo

Code

Social Studio

An agency workspace for planning, approving, scheduling and publishing social content, built as a Sanity App SDK application. It runs inside the Sanity Dashboard, uses Sanity UI and the Content Lake for all content and workflow state, and publishes to Instagram through a small Next.js backend that is the only place secrets live.

Sanity models the whole editorial process here, not just the posts: client → brand guidelines → campaign → social post → review workflow (Sanity Workflows) → human approval → publishing to Instagram, orchestrated by Sanity Functions. AI caption drafts and an assistant run on Sanity Content Agent and read the structured brand and campaign context. AI never approves or publishes anything.

Sanity Challenge 2026

Built for the DEV + Sanity Challenge 2026, Path Two ("Vibe-Code Something Strange"), with Claude Code.

Sanity project 8btwn23g, dataset production
App (Sanity Dashboard) "Social Studio" App SDK
…

My Build Process

I built the project with Claude Code, using it as an implementation partner rather than a one-shot code generator.
The initial idea was simple: turn Sanity into a social content operating system for agencies, with structured client data, brand guidelines, campaigns, review states, AI-assisted drafting, and Instagram publishing.
One early direction was to turn the whole project into a full multi-tenant SaaS with custom authentication, tenant provisioning and Supabase RLS. That architecture still makes sense commercially, but it was too large for the challenge and distracted from the most interesting Sanity features.
So I changed direction and focused on a deeper Sanity-native experience using App SDK, Workflows, structured content and external API publishing.
The final editorial flow became:
Idea → Draft → Internal Review → Client Review → Approved → Instagram
Claude Code helped implement the custom App SDK interface, schemas, workflow synchronization, Instagram OAuth, encrypted token storage, publishing validation, duplicate-publish protection, AI drafting and tests.
Where things got interesting
Not everything worked on the first attempt.
The Content Agent integration looked correct locally but failed against the real API until I deployed the required Studio and fixed issues that only appeared in production.
Instagram was the biggest reality check. Mock publishing worked, but I wanted the submission to prove a real end-to-end flow. That meant configuring Meta OAuth, Instagram professional account access, Supabase, secure token storage and the deployed backend.
At one point the Sanity App reported “Backend unavailable” even though the backend health endpoint was fully healthy. That led to another debugging pass around the frontend/backend connection instead of assuming the deployment itself was broken.
The final test was real: I connected the @1367.studio Instagram Business account and successfully published an approved post from Social Studio directly to Instagram.
AI and structured content
I also wanted the AI feature to use Sanity for more than simple storage.
“Draft with AI” reads structured context including:

  • brand voice
  • target audience
  • content pillars
  • preferred and forbidden vocabulary
  • CTA preferences
  • campaign objective
  • key messages This produced much more relevant drafts than a generic caption prompt. Testing The final project has 72 passing tests, covering workflow behavior, publishing validation, Meta API errors, OAuth protection and duplicate publishing prevention. pnpm check passes typechecking, linting, tests and all builds. What I learned The biggest lesson was that Sanity became much more interesting once I stopped thinking of it only as a CMS. The same structured content can drive AI context, review workflows, scheduling and real external actions like publishing to Instagram.

Sanity Project Details

Sanity Project ID: 8btwn23g
Dataset: production
The project uses structured documents for:

  • clients
  • brand guidelines
  • campaigns
  • social posts
  • workflow and publishing state Sanity Workflows manage the editorial review process, while the custom App SDK interface provides the calendar, content views, post editor, Instagram preview, AI-assisted drafting, and publishing controls. The structured relationships between client, brand guidelines, campaign, and social post are also used as context for AI-generated content.

Some Images

Instagram post:
Instagram post

Sanity schemas:

Sanity schemas

Sanity schemas

Top comments (0)