Sanity

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.

How it works

Get started in 4 steps

1

Add a URL field to your schema

Add a url type field to your Sanity document schema.

2

Set up a GROQ webhook

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

3

Capture the screenshot

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

4

Upload to Sanity

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

</>Code Example

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/screenshot',
18    {
19      method: 'POST',
20      headers: {
21        'Authorization': `Bearer ${process.env.SCREENSHOT_API_KEY}`,
22        'Content-Type': 'application/json',
23      },
24      body: JSON.stringify({ url: websiteUrl, fullPage: false }),
25    }
26  );
27  const { screenshotUrl } = await response.json();
28
29  // Download and upload to Sanity
30  const imageResponse = await fetch(screenshotUrl);
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}
Benefits

Why use Allscreenshots with 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.

Frequently asked questions

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

Pricing that scales with you

No hidden fees. No surprises. Just screenshots.

100 free screenshots on sign-up · 50 bonus for each friend you invite

Starter

$18/mo
  • 1,500 screenshots/mo
  • 50/min rate limit
  • $0.009 overage
  • All features included
Get Started
Most Popular

Pro

$45/mo
  • 7,500 screenshots/mo
  • 100/min rate limit
  • $0.009 overage
  • All features included
Get Started

Business

$149/mo
  • 30,000 screenshots/mo
  • 200/min rate limit
  • $0.0075 overage
  • All features included
Get Started

Enterprise

$329/mo
  • 100,000 screenshots/mo
  • 400/min rate limit
  • $0.005 overage
  • All features included
Get Started

Ready to integrate with Sanity?

Start with 100 free screenshots every month. No credit card required.