Allscreenshots
Sign inGet an API key

Website screenshots in Sanity Studio

Auto-generate visual assets from URLs in your Sanity content

Integrate Allscreenshots with Sanity to automatically generate screenshots from URL fields in your documents. Build a custom input component that previews screenshots in Sanity Studio, or use webhooks for fully automated asset creation.

Connect in 4 steps

  1. 1

    Add a URL field to your schema

    Add a url type field to your Sanity document schema.

  2. 2

    Set up a GROQ webhook

    Create a webhook in Sanity that fires when documents with URL fields are published.

  3. 3

    Capture the screenshot

    Your webhook handler calls the Allscreenshots API to capture the URL.

  4. 4

    Upload to Sanity

    Upload the screenshot as a Sanity image asset and reference it in the document.

Sanity Webhook Handler

javascript
1import { createClient } from '@sanity/client'; 2 3const sanity = createClient({ 4 projectId: process.env.SANITY_PROJECT_ID, 5 dataset: 'production', 6 token: process.env.SANITY_TOKEN, 7 apiVersion: '2024-01-01', 8 useCdn: false, 9}); 10 11export async function POST(request) { 12 const { _id, websiteUrl } = await request.json(); 13 if (!websiteUrl) return Response.json({ skipped: true }); 14 15 // Capture screenshot 16 const response = await fetch( 17 'https://api.allscreenshots.com/v1/screenshots', 18 { 19 method: 'POST', 20 headers: { 21 'X-API-Key': process.env.SCREENSHOT_API_KEY, 22 'Content-Type': 'application/json', 23 }, 24 body: JSON.stringify({ url: websiteUrl, fullPage: false }), 25 } 26 ); 27 const { storageUrl } = await response.json(); 28 29 // Download and upload to Sanity 30 const imageResponse = await fetch(storageUrl); 31 const imageBuffer = await imageResponse.arrayBuffer(); 32 33 const asset = await sanity.assets.upload( 34 'image', 35 Buffer.from(imageBuffer), 36 { filename: `screenshot-${_id}.png` } 37 ); 38 39 // Update the document 40 await sanity.patch(_id) 41 .set({ screenshot: { _type: 'image', asset: { _ref: asset._id } } }) 42 .commit(); 43 44 return Response.json({ assetId: asset._id }); 45}

Built for Sanity

Native Sanity assets

Screenshots are uploaded as proper Sanity image assets with full CDN delivery and transforms.

Schema integration

Screenshot fields integrate naturally into your Sanity document schemas.

Real-time previews

Editors see screenshot previews directly in Sanity Studio while editing.

Questions

Can I build a custom input component for screenshots?

Yes. Create a custom Sanity Studio input component that calls the Allscreenshots API when an editor enters a URL and previews the result inline.

How do I set up Sanity webhooks?

Go to Manage > API > Webhooks in your Sanity project and create a webhook with a GROQ filter to trigger on document updates.

Are screenshots served through Sanity's CDN?

Yes. Once uploaded as a Sanity image asset, screenshots are served through Sanity's global CDN with automatic image transforms.

Keep exploring

Start with one request

Free plan: 100 screenshots. No credit card.

Get an API key
  • Full-page captures
  • Popups and repeated sticky bars removed
  • Markdown, JSON and PDF output
  • Crawl a site from one URL
  • Desktop, tablet and phone in one image
  • Works in n8n, Make and Zapier
  • MCP server for AI assistants