Workflows
Bulk requests
POST /v1/bulk takes shared options and up to 100 requests, each overriding any option.
import { Shotsmith } from '@shotsmith/sdk';
const shotsmith = new Shotsmith({ accessKey: 'YOUR_ACCESS_KEY' });
const batch = await shotsmith.bulk(
[
{ url: 'https://shotsmith.dev/sample' },
{ url: 'https://shotsmith.dev', full_page: true },
],
{ options: { format: 'webp', block_cookie_banners: true }, execute: true },
);
console.log(batch);
<?php
require 'vendor/autoload.php';
use Shotsmith\Client;
$shotsmith = new Client('YOUR_ACCESS_KEY');
$batch = $shotsmith->bulk(
requests: [
['url' => 'https://shotsmith.dev/sample'],
[
'url' => 'https://shotsmith.dev',
'full_page' => true,
],
],
options: [
'format' => 'webp',
'block_cookie_banners' => true,
],
execute: true,
);
print_r($batch);
curl -X POST "https://shotsmith.dev/v1/bulk" \
-H "X-Access-Key: YOUR_ACCESS_KEY" \
-H "Content-Type: application/json" \
-d '{
"options": { "format": "webp", "block_cookie_banners": true },
"requests": [
{ "url": "https://shotsmith.dev/sample" },
{ "url": "https://shotsmith.dev", "full_page": true }
],
"execute": true
}'
const res = await fetch('https://shotsmith.dev/v1/bulk', {
method: 'POST',
headers: {
'X-Access-Key': 'YOUR_ACCESS_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
options: { format: 'webp', block_cookie_banners: true },
requests: [
{ url: 'https://shotsmith.dev/sample' },
{ url: 'https://shotsmith.dev', full_page: true },
],
execute: true,
}),
});
if (!res.ok) throw new Error((await res.json()).error_message);
console.log(await res.json());
import json
import urllib.request
body = {
"options": {"format": "webp", "block_cookie_banners": True},
"requests": [
{"url": "https://shotsmith.dev/sample"},
{
"url": "https://shotsmith.dev",
"full_page": True
}
],
"execute": True
}
req = urllib.request.Request(
"https://shotsmith.dev/v1/bulk",
data=json.dumps(body).encode(),
headers={"X-Access-Key": "YOUR_ACCESS_KEY", "Content-Type": "application/json"},
method="POST",
)
# Raises urllib.error.HTTPError on a 4xx/5xx response
with urllib.request.urlopen(req, timeout=60) as res:
print(json.load(res))
<?php
$ch = curl_init('https://shotsmith.dev/v1/bulk');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['X-Access-Key: YOUR_ACCESS_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'options' => [
'format' => 'webp',
'block_cookie_banners' => true,
],
'requests' => [
['url' => 'https://shotsmith.dev/sample'],
[
'url' => 'https://shotsmith.dev',
'full_page' => true,
],
],
'execute' => true,
]),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 60,
]);
$response = json_decode(curl_exec($ch), true);
if (curl_getinfo($ch, CURLINFO_RESPONSE_CODE) >= 400) {
throw new RuntimeException($response['error_message']);
}
print_r($response);
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
body := strings.NewReader(`{
"options": { "format": "webp", "block_cookie_banners": true },
"requests": [
{ "url": "https://shotsmith.dev/sample" },
{ "url": "https://shotsmith.dev", "full_page": true }
],
"execute": true
}`)
req, _ := http.NewRequest("POST", "https://shotsmith.dev/v1/bulk", body)
req.Header.Set("X-Access-Key", "YOUR_ACCESS_KEY")
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(string(out))
}
require "net/http"
require "json"
body = {
"options" => {
"format" => "webp",
"block_cookie_banners" => true
},
"requests" => [
{"url" => "https://shotsmith.dev/sample"},
{
"url" => "https://shotsmith.dev",
"full_page" => true
}
],
"execute" => true
}
res = Net::HTTP.post(
URI("https://shotsmith.dev/v1/bulk"),
body.to_json,
"X-Access-Key" => "YOUR_ACCESS_KEY",
"Content-Type" => "application/json"
)
raise res.body unless res.is_a?(Net::HTTPSuccess)
puts JSON.parse(res.body)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Request {
public static void main(String[] args) throws Exception {
var body = """
{
"options": { "format": "webp", "block_cookie_banners": true },
"requests": [
{ "url": "https://shotsmith.dev/sample" },
{ "url": "https://shotsmith.dev", "full_page": true }
],
"execute": true
}
""";
var request = HttpRequest.newBuilder(URI.create("https://shotsmith.dev/v1/bulk"))
.header("X-Access-Key", "YOUR_ACCESS_KEY")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
var res = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(res.body());
}
}
using System;
using System.Net.Http;
using System.Text;
using var http = new HttpClient();
http.DefaultRequestHeaders.Add("X-Access-Key", "YOUR_ACCESS_KEY");
var body = """
{
"options": { "format": "webp", "block_cookie_banners": true },
"requests": [
{ "url": "https://shotsmith.dev/sample" },
{ "url": "https://shotsmith.dev", "full_page": true }
],
"execute": true
}
""";
var res = await http.PostAsync(
"https://shotsmith.dev/v1/bulk",
new StringContent(body, Encoding.UTF8, "application/json")
);
res.EnsureSuccessStatusCode();
Console.WriteLine(await res.Content.ReadAsStringAsync());
Content-Type: application/json
{
"is_successful": true,
"batch_id": "01m8kvpkf9b2hvtxf4nnwrjz9k",
"responses": [
{
"index": 0,
"id": "01m8kvpkfar073f5psm0qk92en",
"status": "queued",
"status_url": "https://shotsmith.dev/v1/captures/01m8kvpkfar073f5psm0qk92en"
},
{
"index": 1,
"id": "01m8kvpkfb2q7bcmn7tdxj2gyz",
"status": "queued",
"status_url": "https://shotsmith.dev/v1/captures/01m8kvpkfb2q7bcmn7tdxj2gyz"
}
]
}
With execute: false (the default) you get back signed /v1/take URLs, ready to use in <img> tags or to fetch later. With execute: true every request is queued as an async render; poll each status_url, or list the batch with GET /v1/captures?batch_id=…. Invalid items return an error in place without stopping the batch.