> ## Documentation Index
> Fetch the complete documentation index at: https://docs.screenshotly.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Scheduling captures

> Automate recurring screenshot captures using cron jobs, serverless functions, or workflow tools like GitHub Actions.

Screenshotly's API handles on-demand captures. To schedule recurring screenshots, combine it with an external scheduling mechanism.

## Cron jobs

Run a capture script on a schedule using cron (Linux/macOS):

```javascript theme={null}
// capture.js
import { Screenshotly } from 'screenshotly-js';

const client = new Screenshotly(process.env.SCREENSHOTLY_API_KEY);

async function capture() {
  const screenshot = await client.capture({
    url: 'https://example.com',
    format: 'jpeg',
    full_page: true,
    viewport_width: 1920,
    viewport_height: 1080
  });

  console.log(`[${new Date().toISOString()}] Captured successfully`);
}

capture();
```

Add a crontab entry to run daily at 2:00 AM:

```bash theme={null}
0 2 * * * /usr/bin/node /path/to/capture.js >> /path/to/cron.log 2>&1
```

## GitHub Actions

Create a scheduled workflow to capture screenshots automatically:

```yaml theme={null}
# .github/workflows/scheduled-screenshot.yml
name: Scheduled screenshot

on:
  schedule:
    - cron: '0 3 * * *' # daily at 03:00 UTC

jobs:
  capture:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
      - run: npm install screenshotly-js
      - run: node capture.js
        env:
          SCREENSHOTLY_API_KEY: ${{ secrets.SCREENSHOTLY_API_KEY }}
```

## AWS Lambda

Deploy your capture logic as a Lambda function triggered by EventBridge on a schedule:

```javascript theme={null}
import { Screenshotly } from 'screenshotly-js';

const client = new Screenshotly(process.env.SCREENSHOTLY_API_KEY);

export const handler = async (event) => {
  const screenshot = await client.capture({
    url: 'https://example.com',
    format: 'jpeg'
  });

  console.log('Captured successfully');
  return { statusCode: 200 };
};
```

Configure an EventBridge rule with a cron expression to trigger the Lambda function on your desired schedule.

## Workflow automation tools

You can also use no-code platforms to schedule captures:

* **Zapier** — create a Zap with a Schedule trigger and a Webhooks action calling the Screenshotly API
* **Make (Integromat)** — use the HTTP module with a scheduling trigger

See [no-code integrations](/integrations/no-code) for setup details.

## Best practices

* **Store API keys securely** — use environment variables or secrets managers, never hardcode keys in scripts
* **Log results** — capture timestamps, URLs, and outcomes for troubleshooting
* **Set up failure alerts** — send notifications via email or Slack if scheduled captures fail
* **Stagger schedules** — if running many scheduled captures, spread them out to avoid rate limit issues
* **Manage storage** — implement a retention policy for stored screenshots to control costs
