SERVERLESS GUIDE

Generate screenshots from Lambda without shipping a browser binary

Use the function as a secure orchestration boundary: authorize the event, resolve an approved target, call Snapshot Site, validate the result, and persist the artifact or job state before the invocation ends.

HTTPS client
No local browser
Secrets
Runtime configuration
Async option
Queue-backed jobs
Install:Lambda handler + fetch
Auth:SNAPSHOT_SITE_API_KEY
Get started for free
AWS Lambda screenshot workflow
Snapshot Site themed AWS Lambda screenshot API illustration
Good fits
Event-driven preview generation
Serverless post-deploy capture jobs
Queue-triggered screenshot workers
Applications avoiding Chromium Lambda layers

A hosted browser keeps Lambda focused on orchestration

The function still owns event validation, destination policy, time budget, response checks, artifact storage, concurrency, and safe retry.

1

Event contract

Accept an application entity or approved route rather than an unrestricted target.

2

Secret injection

Load the API key from protected function configuration or a secret service.

3

Execution budget

Leave time for provider response, validation, asset import, and state commit.

4

Async durability

Use a queue or event workflow for retries and capture jobs that should not depend on a caller connection.

Implementation workflow

Add a Lambda capture handler

1

Define an event with an authorized page identifier

2

Configure the provider key outside deployment code

3

Call Snapshot Site with an explicit abort budget

4

Validate and persist the result before acknowledging the event

AWS Lambda screenshot API example

Node.js

Call Snapshot Site from a Lambda handler

The handler resolves a known page and uses an explicit client abort budget rather than packaging a browser.

const pages = {
  pricing: "https://example.com/pricing",
  docs: "https://example.com/docs",
};

export const handler = async (event) => {
  const url = pages[event.pageId];
  if (!url) throw new Error("Unknown page");

  const response = await fetch(
    "https://api.prod.ss.snapshot-site.com/api/v1/screenshot",
    {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "x-snapshotsiteapi-key": process.env.SNAPSHOT_SITE_API_KEY,
      },
      body: JSON.stringify({
        url,
        format: "webp",
        width: 1440,
        height: 900,
        fullSize: true,
      }),
      signal: AbortSignal.timeout(45_000),
    },
  );

  if (!response.ok) {
    throw new Error(`Capture failed: ${response.status}`);
  }
  return await response.json();
};

Lambda does not need to become a browser host

A function that calls Snapshot Site sends a normal HTTPS request. It avoids browser layers, system fonts, sandbox flags, shared-memory tuning, and process cleanup. The function remains responsible for the application workflow around that request.

Validate the incoming event and resolve a known route. An open function that accepts any URL can expose network reach and account quota.

Nest the client timeout inside the invocation budget

The function needs time after the provider call to validate the response, download or import the artifact, and commit job status. Set the HTTP abort budget shorter than the total invocation limit. Distinguish a client abort from a page that failed to reach readiness.

For asynchronous events, expect redelivery. Use a stable job ID and idempotent storage so a duplicate invocation refers to the same logical capture.

Control concurrency before the provider

Queue and function concurrency can scale quickly. Configure a deliberate ceiling that respects account policy, target impact, and downstream storage. Handle rate responses with delayed retry rather than allowing every concurrent invocation to retry immediately.

Keep secrets in protected runtime configuration and redact signed target parameters. Persist screenshots under source-appropriate access and retention.

Use API timeout guidance for layered budgets and multiple URL capture for queue and progress design.

Screenshot API with AWS Lambda FAQ

Does Lambda need a Chromium layer for Snapshot Site?

No. A function calling the hosted API only needs an HTTPS client and its application dependencies.

Where should the API key be stored?

Use protected Lambda environment configuration or a secret-management service with least-privilege function access.

Should Lambda wait synchronously for the screenshot?

It can for a suitable low-volume job within the execution budget. Use a queue or asynchronous workflow for durable retries and larger workloads.

How should Lambda timeout be configured?

Leave enough function time for the HTTP attempt, response validation, artifact storage, and status commit. Use a shorter explicit client timeout inside that budget.

Can a timed-out invocation retry automatically?

Event sources can redeliver. Make the logical job and storage idempotent so duplicate invocation does not create conflicting artifacts.

How should concurrency be controlled?

Use reserved or event-source concurrency, queue settings, and application rate policy to prevent uncontrolled bursts.

Where should screenshot files be stored?

Import validated artifacts into storage governed by your application when durable ownership or private access is required.

Can a Lambda accept arbitrary URLs from API Gateway?

Authenticate the caller and enforce strict destination policy. Prefer server-resolved page identifiers to an open screenshot proxy.

Deploy one bounded serverless capture

Start with a known page identifier and verify timeout, idempotency, concurrency, and storage before connecting public events.