Skip to content
REST API v1JSON + PNG/JPEG/PDF

API documentation

Integrate ShotForge PNG/JPEG screenshots, Open Graph cards and PDFs with cURL, PHP and Python examples. This guide covers authentication, fields, quotas and errors, then separates operations that require a browser session.

Quickstart

Create an account, issue an API key, then make your first binary render request over HTTPS.

  1. 1. Create an account or sign in.
  2. 2. Create a key in Dashboard → API keys. Copy it immediately.
  3. 3. Send the key in X-API-Key and save the binary response.

First request

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/octet-stream', 'Content-Type': 'application/json', 'X-API-Key': header_value(required('SHOTFORGE_API_KEY', None))}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/api/v1/screenshot')
(workdir / 'body').write_text(json.dumps({'url': required('SHOTFORGE_TARGET_URL', 'https://example.com')}))
PY
endpoint=$(<"$workdir/endpoint")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request POST \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  --data-binary "@$workdir/body" \
  "$endpoint")
case "$http_status" in 200) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" shotforge-screenshot.png "$workdir/response_headers" <<'PY'
import json, os, sys
from pathlib import Path
source, target = Path(sys.argv[1]), Path(sys.argv[2])
types = [line.split(':', 1)[1].strip().split(';')[0] for line in Path(sys.argv[3]).read_text().splitlines() if line.lower().startswith('content-type:')]
media_type = types[-1] if types else ''
if media_type not in ('image/png',):
    raise SystemExit('Unexpected response media type')
with target.open('xb') as output:
    output.write(source.read_bytes())
target.chmod(0o600)
print(f'Saved private response to {target}')
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/api/v1/screenshot';
$headers = ['Accept: application/octet-stream', 'Content-Type: application/json', 'X-API-Key: ' . headerValue(required('SHOTFORGE_API_KEY', null))];
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_POSTFIELDS => json_encode(['url' => required('SHOTFORGE_TARGET_URL', 'https://example.com')], JSON_THROW_ON_ERROR),
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [200], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
if (!in_array($mediaType, ['image/png'], true)) {
    throw new RuntimeException('Unexpected response media type');
}
$target = 'shotforge-screenshot.png';
$output = fopen($target, 'xb');
if ($output === false) { throw new RuntimeException('Output already exists or cannot be created'); }
if (fwrite($output, $content) !== strlen($content)) {
    fclose($output); throw new RuntimeException('Incomplete output');
}
fclose($output);
chmod($target, 0600);
echo "Saved private response to " . $target . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/api/v1/screenshot'
headers = {'Accept': 'application/octet-stream', 'Content-Type': 'application/json', 'X-API-Key': header_value(required('SHOTFORGE_API_KEY', None))}
payload = {'url': required('SHOTFORGE_TARGET_URL', 'https://example.com')}
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False) as client:
    response = client.request('POST', base_url + path, headers=headers, json=payload)
    if response.status_code not in (200,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    if response.headers.get('content-type', '').split(';')[0] not in ('image/png',):
        raise SystemExit('Unexpected response media type')
    target = Path('shotforge-screenshot.png')
    with target.open('xb') as output:
        output.write(response.content)
    target.chmod(0o600)
    print(f'Saved private response to {target}')

Successful render endpoints return binary bytes, not JSON: image/png, image/jpeg, or application/pdf. Use --output with curl and verify the HTTP status before using the file. cURL examples require Bash and Python 3 to prepare private temporary header and body files, keeping credentials out of process arguments. No process substitution is required.

Load keys, tokens and passwords into SHOTFORGE_* environment variables from your secret manager. cURL examples require Bash, curl and Python 3; PHP requires the cURL extension; for Python, install httpx with pip install httpx. Connection and request timeouts are 10 and 90 seconds. Keep cookie files and sensitive responses private; never log their contents. Output files are not overwritten: move or remove the previous file before running the same example again.

Authentication

All render endpoints require either an API key or an access token. API keys are recommended for server-to-server integrations.

X-API-Key · Recommended

X-API-Key: sk_EXAMPLE_NOT_A_REAL_KEY

Long-lived server credential. ShotForge stores only a keyed fingerprint, never the raw key.

Bearer JWT

Authorization: Bearer ACCESS_TOKEN

Short-lived access token returned by register, login, or refresh.

  • Send credentials only in headers, never in a URL or query string.
  • An API key is displayed once when created. Store it in a secret manager or environment variable.
  • Each account can have up to 10 active API keys.
  • Revoke and replace a key immediately if it may have been exposed.
Manage API keys

Token authentication workflow

API registration and login return access_token and refresh_token, saved here in a private file. Load them into SHOTFORGE_ACCESS_TOKEN and SHOTFORGE_REFRESH_TOKEN for the next steps. Refresh replaces both values: keep the new pair and discard the old refresh token. These requests do not create a browser session or authorize account or key management.

POST /api/auth/register

Create an account. email; password 10–128 characters with a letter and digit; optional full_name. Returns access_token and refresh_token.

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/api/auth/register')
(workdir / 'body').write_text(json.dumps({'email': required('SHOTFORGE_ACCOUNT_EMAIL', None), 'password': required('SHOTFORGE_ACCOUNT_PASSWORD', None), 'full_name': required('SHOTFORGE_FULL_NAME', '')}))
PY
endpoint=$(<"$workdir/endpoint")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request POST \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  --data-binary "@$workdir/body" \
  "$endpoint")
case "$http_status" in 201) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" shotforge-register-tokens.json "$workdir/response_headers" <<'PY'
import json, os, sys
from pathlib import Path
source, target = Path(sys.argv[1]), Path(sys.argv[2])
json.loads(source.read_text())
with target.open('xb') as output:
    output.write(source.read_bytes())
target.chmod(0o600)
print(f'Saved private response to {target}')
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/api/auth/register';
$headers = ['Accept: application/json', 'Content-Type: application/json'];
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_POSTFIELDS => json_encode(['email' => required('SHOTFORGE_ACCOUNT_EMAIL', null), 'password' => required('SHOTFORGE_ACCOUNT_PASSWORD', null), 'full_name' => required('SHOTFORGE_FULL_NAME', '')], JSON_THROW_ON_ERROR),
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [201], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
json_decode($content, true, 512, JSON_THROW_ON_ERROR);
$target = 'shotforge-register-tokens.json';
$output = fopen($target, 'xb');
if ($output === false) { throw new RuntimeException('Output already exists or cannot be created'); }
if (fwrite($output, $content) !== strlen($content)) {
    fclose($output); throw new RuntimeException('Incomplete output');
}
fclose($output);
chmod($target, 0600);
echo "Saved private response to " . $target . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/api/auth/register'
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
payload = {'email': required('SHOTFORGE_ACCOUNT_EMAIL', None), 'password': required('SHOTFORGE_ACCOUNT_PASSWORD', None), 'full_name': required('SHOTFORGE_FULL_NAME', '')}
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False) as client:
    response = client.request('POST', base_url + path, headers=headers, json=payload)
    if response.status_code not in (201,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    response.json()
    target = Path('shotforge-register-tokens.json')
    with target.open('xb') as output:
        output.write(response.content)
    target.chmod(0o600)
    print(f'Saved private response to {target}')

POST /api/auth/login

Authenticate with email and password. Returns a new access/refresh pair.

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/api/auth/login')
(workdir / 'body').write_text(json.dumps({'email': required('SHOTFORGE_ACCOUNT_EMAIL', None), 'password': required('SHOTFORGE_ACCOUNT_PASSWORD', None)}))
PY
endpoint=$(<"$workdir/endpoint")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request POST \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  --data-binary "@$workdir/body" \
  "$endpoint")
case "$http_status" in 200) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" shotforge-login-tokens.json "$workdir/response_headers" <<'PY'
import json, os, sys
from pathlib import Path
source, target = Path(sys.argv[1]), Path(sys.argv[2])
json.loads(source.read_text())
with target.open('xb') as output:
    output.write(source.read_bytes())
target.chmod(0o600)
print(f'Saved private response to {target}')
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/api/auth/login';
$headers = ['Accept: application/json', 'Content-Type: application/json'];
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_POSTFIELDS => json_encode(['email' => required('SHOTFORGE_ACCOUNT_EMAIL', null), 'password' => required('SHOTFORGE_ACCOUNT_PASSWORD', null)], JSON_THROW_ON_ERROR),
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [200], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
json_decode($content, true, 512, JSON_THROW_ON_ERROR);
$target = 'shotforge-login-tokens.json';
$output = fopen($target, 'xb');
if ($output === false) { throw new RuntimeException('Output already exists or cannot be created'); }
if (fwrite($output, $content) !== strlen($content)) {
    fclose($output); throw new RuntimeException('Incomplete output');
}
fclose($output);
chmod($target, 0600);
echo "Saved private response to " . $target . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/api/auth/login'
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
payload = {'email': required('SHOTFORGE_ACCOUNT_EMAIL', None), 'password': required('SHOTFORGE_ACCOUNT_PASSWORD', None)}
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False) as client:
    response = client.request('POST', base_url + path, headers=headers, json=payload)
    if response.status_code not in (200,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    response.json()
    target = Path('shotforge-login-tokens.json')
    with target.open('xb') as output:
        output.write(response.content)
    target.chmod(0o600)
    print(f'Saved private response to {target}')

POST /api/auth/refresh

Rotate a refresh token. The submitted token becomes unusable; reuse revokes all refresh tokens for that account. Existing access tokens expire naturally within 30 minutes.

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/api/auth/refresh')
(workdir / 'body').write_text(json.dumps({'refresh_token': required('SHOTFORGE_REFRESH_TOKEN', None)}))
PY
endpoint=$(<"$workdir/endpoint")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request POST \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  --data-binary "@$workdir/body" \
  "$endpoint")
case "$http_status" in 200) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" shotforge-refreshed-tokens.json "$workdir/response_headers" <<'PY'
import json, os, sys
from pathlib import Path
source, target = Path(sys.argv[1]), Path(sys.argv[2])
json.loads(source.read_text())
with target.open('xb') as output:
    output.write(source.read_bytes())
target.chmod(0o600)
print(f'Saved private response to {target}')
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/api/auth/refresh';
$headers = ['Accept: application/json', 'Content-Type: application/json'];
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_POSTFIELDS => json_encode(['refresh_token' => required('SHOTFORGE_REFRESH_TOKEN', null)], JSON_THROW_ON_ERROR),
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [200], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
json_decode($content, true, 512, JSON_THROW_ON_ERROR);
$target = 'shotforge-refreshed-tokens.json';
$output = fopen($target, 'xb');
if ($output === false) { throw new RuntimeException('Output already exists or cannot be created'); }
if (fwrite($output, $content) !== strlen($content)) {
    fclose($output); throw new RuntimeException('Incomplete output');
}
fclose($output);
chmod($target, 0600);
echo "Saved private response to " . $target . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/api/auth/refresh'
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
payload = {'refresh_token': required('SHOTFORGE_REFRESH_TOKEN', None)}
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False) as client:
    response = client.request('POST', base_url + path, headers=headers, json=payload)
    if response.status_code not in (200,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    response.json()
    target = Path('shotforge-refreshed-tokens.json')
    with target.open('xb') as output:
        output.write(response.content)
    target.chmod(0o600)
    print(f'Saved private response to {target}')

POST /api/auth/logout

Revoke the refresh_token supplied in the JSON body. Returns 204.

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/api/auth/logout')
(workdir / 'body').write_text(json.dumps({'refresh_token': required('SHOTFORGE_REFRESH_TOKEN', None)}))
PY
endpoint=$(<"$workdir/endpoint")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request POST \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  --data-binary "@$workdir/body" \
  "$endpoint")
case "$http_status" in 204) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
printf 'HTTP %s\n' "$http_status"
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/api/auth/logout';
$headers = ['Accept: application/json', 'Content-Type: application/json'];
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_POSTFIELDS => json_encode(['refresh_token' => required('SHOTFORGE_REFRESH_TOKEN', null)], JSON_THROW_ON_ERROR),
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [204], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
echo "HTTP " . $status . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/api/auth/logout'
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
payload = {'refresh_token': required('SHOTFORGE_REFRESH_TOKEN', None)}
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False) as client:
    response = client.request('POST', base_url + path, headers=headers, json=payload)
    if response.status_code not in (204,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    print(f'HTTP {response.status_code}')

GET /api/auth/usage · Bearer

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/json', 'Authorization': header_value('Bearer ' + required('SHOTFORGE_ACCESS_TOKEN', None))}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/api/auth/usage')
PY
endpoint=$(<"$workdir/endpoint")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request GET \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  "$endpoint")
case "$http_status" in 200) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" <<'PY'
import json, sys
from pathlib import Path
print(json.dumps(json.loads(Path(sys.argv[1]).read_text()), indent=2))
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/api/auth/usage';
$headers = ['Accept: application/json', 'Authorization: ' . headerValue('Bearer ' . required('SHOTFORGE_ACCESS_TOKEN', null))];
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [200], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
echo json_encode(json_decode($content, true, 512, JSON_THROW_ON_ERROR), JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR) . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/api/auth/usage'
headers = {'Accept': 'application/json', 'Authorization': header_value('Bearer ' + required('SHOTFORGE_ACCESS_TOKEN', None))}
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False) as client:
    response = client.request('GET', base_url + path, headers=headers)
    if response.status_code not in (200,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    print(json.dumps(response.json(), indent=2))

Plans, quotas, and rate limits

The 14-day trial receives Pro capabilities. Plan limits are applied before Chromium starts.

PlanRenders / monthMaximum widthFull pageAuthenticated pagesPDFHistory
Free1001280 px———7 days
Starter50001920 px✓✓—30 days
Pro / Trial500002560 px✓✓✓30 days
Business5000003840 px✓✓✓90 days
Render rate limit

30 render requests per minute per API key (or per IP when using a Bearer token). A 429 response includes Retry-After: 60.

Quota accounting

Only successful renders consume monthly quota. Pending reservations prevent concurrent requests from exceeding the limit. Usage resets at 00:00 UTC on the first day of the month.

GET /api/auth/usage

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/json', 'X-API-Key': header_value(required('SHOTFORGE_API_KEY', None))}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/api/auth/usage')
PY
endpoint=$(<"$workdir/endpoint")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request GET \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  "$endpoint")
case "$http_status" in 200) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" <<'PY'
import json, sys
from pathlib import Path
print(json.dumps(json.loads(Path(sys.argv[1]).read_text()), indent=2))
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/api/auth/usage';
$headers = ['Accept: application/json', 'X-API-Key: ' . headerValue(required('SHOTFORGE_API_KEY', null))];
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [200], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
echo json_encode(json_decode($content, true, 512, JSON_THROW_ON_ERROR), JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR) . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/api/auth/usage'
headers = {'Accept': 'application/json', 'X-API-Key': header_value(required('SHOTFORGE_API_KEY', None))}
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False) as client:
    response = client.request('GET', base_url + path, headers=headers)
    if response.status_code not in (200,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    print(json.dumps(response.json(), indent=2))

Health checks and public plan catalog

These GET routes are public and do not consume render credits.

GET /health

Checks that the process responds. A 200 status does not prove that the database or storage is ready.

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/json'}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/health')
PY
endpoint=$(<"$workdir/endpoint")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request GET \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  "$endpoint")
case "$http_status" in 200) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" <<'PY'
import json, sys
from pathlib import Path
print(json.dumps(json.loads(Path(sys.argv[1]).read_text()), indent=2))
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/health';
$headers = ['Accept: application/json'];
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [200], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
echo json_encode(json_decode($content, true, 512, JSON_THROW_ON_ERROR), JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR) . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/health'
headers = {'Accept': 'application/json'}
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False) as client:
    response = client.request('GET', base_url + path, headers=headers)
    if response.status_code not in (200,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    print(json.dumps(response.json(), indent=2))

GET /ready

Checks the database connection and migration version. In production, also validates local storage configuration without testing the remote bucket. Returns 503 if these prerequisites are not met.

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/json'}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/ready')
PY
endpoint=$(<"$workdir/endpoint")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request GET \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  "$endpoint")
case "$http_status" in 200) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" <<'PY'
import json, sys
from pathlib import Path
print(json.dumps(json.loads(Path(sys.argv[1]).read_text()), indent=2))
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/ready';
$headers = ['Accept: application/json'];
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [200], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
echo json_encode(json_decode($content, true, 512, JSON_THROW_ON_ERROR), JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR) . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/ready'
headers = {'Accept': 'application/json'}
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False) as client:
    response = client.request('GET', base_url + path, headers=headers)
    if response.status_code not in (200,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    print(json.dumps(response.json(), indent=2))

GET /api/billing/plans

Returns plans with quotas, feature limits and history retention periods.

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/json'}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/api/billing/plans')
PY
endpoint=$(<"$workdir/endpoint")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request GET \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  "$endpoint")
case "$http_status" in 200) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" <<'PY'
import json, sys
from pathlib import Path
print(json.dumps(json.loads(Path(sys.argv[1]).read_text()), indent=2))
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/api/billing/plans';
$headers = ['Accept: application/json'];
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [200], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
echo json_encode(json_decode($content, true, 512, JSON_THROW_ON_ERROR), JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR) . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/api/billing/plans'
headers = {'Accept': 'application/json'}
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False) as client:
    response = client.request('GET', base_url + path, headers=headers)
    if response.status_code not in (200,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    print(json.dumps(response.json(), indent=2))

Anonymous demo endpoints

The public website demos accept form-encoded requests without an account. They are evaluation tools, not the versioned production API; use /api/v1 endpoints with authentication for integrations.

EndpointContent-TypeFieldsResponse
POST /tools/screenshotapplication/x-www-form-urlencodedurl, width (200–1920), height (200–2000)image/png
POST /tools/ogapplication/x-www-form-urlencodedurl, template, title, subtitle, brandimage/png · 1200×630
3 anonymous layouts · 41 base layouts · 72 with Pro

The anonymous OG tool accepts only the three IDs below. Authenticated Free and Starter accounts can use 41 layouts; Pro, Business and an active Pro trial can use all 72. The raw mode remains available independently.

ember-frame · ocean-split · paper-editorial

POST /tools/screenshot

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/octet-stream', 'Content-Type': 'application/x-www-form-urlencoded'}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/tools/screenshot')
(workdir / 'body').write_text(urlencode({'url': required('SHOTFORGE_TARGET_URL', 'https://example.com'), 'width': 1280, 'height': 720}))
PY
endpoint=$(<"$workdir/endpoint")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request POST \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  --data-binary "@$workdir/body" \
  "$endpoint")
case "$http_status" in 200) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" shotforge-anonymous.png "$workdir/response_headers" <<'PY'
import json, os, sys
from pathlib import Path
source, target = Path(sys.argv[1]), Path(sys.argv[2])
types = [line.split(':', 1)[1].strip().split(';')[0] for line in Path(sys.argv[3]).read_text().splitlines() if line.lower().startswith('content-type:')]
media_type = types[-1] if types else ''
if media_type not in ('image/png',):
    raise SystemExit('Unexpected response media type')
with target.open('xb') as output:
    output.write(source.read_bytes())
target.chmod(0o600)
print(f'Saved private response to {target}')
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/tools/screenshot';
$headers = ['Accept: application/octet-stream', 'Content-Type: application/x-www-form-urlencoded'];
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_POSTFIELDS => http_build_query(['url' => required('SHOTFORGE_TARGET_URL', 'https://example.com'), 'width' => 1280, 'height' => 720]),
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [200], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
if (!in_array($mediaType, ['image/png'], true)) {
    throw new RuntimeException('Unexpected response media type');
}
$target = 'shotforge-anonymous.png';
$output = fopen($target, 'xb');
if ($output === false) { throw new RuntimeException('Output already exists or cannot be created'); }
if (fwrite($output, $content) !== strlen($content)) {
    fclose($output); throw new RuntimeException('Incomplete output');
}
fclose($output);
chmod($target, 0600);
echo "Saved private response to " . $target . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/tools/screenshot'
headers = {'Accept': 'application/octet-stream', 'Content-Type': 'application/x-www-form-urlencoded'}
payload = {'url': required('SHOTFORGE_TARGET_URL', 'https://example.com'), 'width': 1280, 'height': 720}
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False) as client:
    response = client.request('POST', base_url + path, headers=headers, data=payload)
    if response.status_code not in (200,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    if response.headers.get('content-type', '').split(';')[0] not in ('image/png',):
        raise SystemExit('Unexpected response media type')
    target = Path('shotforge-anonymous.png')
    with target.open('xb') as output:
        output.write(response.content)
    target.chmod(0o600)
    print(f'Saved private response to {target}')

POST /tools/og

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/octet-stream', 'Content-Type': 'application/x-www-form-urlencoded'}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/tools/og')
(workdir / 'body').write_text(urlencode({'url': required('SHOTFORGE_TARGET_URL', 'https://example.com'), 'template': 'ember-frame', 'title': 'Your next idea', 'subtitle': 'A fresh view', 'brand': 'Your app'}))
PY
endpoint=$(<"$workdir/endpoint")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request POST \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  --data-binary "@$workdir/body" \
  "$endpoint")
case "$http_status" in 200) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" shotforge-anonymous-og.png "$workdir/response_headers" <<'PY'
import json, os, sys
from pathlib import Path
source, target = Path(sys.argv[1]), Path(sys.argv[2])
types = [line.split(':', 1)[1].strip().split(';')[0] for line in Path(sys.argv[3]).read_text().splitlines() if line.lower().startswith('content-type:')]
media_type = types[-1] if types else ''
if media_type not in ('image/png',):
    raise SystemExit('Unexpected response media type')
with target.open('xb') as output:
    output.write(source.read_bytes())
target.chmod(0o600)
print(f'Saved private response to {target}')
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/tools/og';
$headers = ['Accept: application/octet-stream', 'Content-Type: application/x-www-form-urlencoded'];
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_POSTFIELDS => http_build_query(['url' => required('SHOTFORGE_TARGET_URL', 'https://example.com'), 'template' => 'ember-frame', 'title' => 'Your next idea', 'subtitle' => 'A fresh view', 'brand' => 'Your app']),
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [200], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
if (!in_array($mediaType, ['image/png'], true)) {
    throw new RuntimeException('Unexpected response media type');
}
$target = 'shotforge-anonymous-og.png';
$output = fopen($target, 'xb');
if ($output === false) { throw new RuntimeException('Output already exists or cannot be created'); }
if (fwrite($output, $content) !== strlen($content)) {
    fclose($output); throw new RuntimeException('Incomplete output');
}
fclose($output);
chmod($target, 0600);
echo "Saved private response to " . $target . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/tools/og'
headers = {'Accept': 'application/octet-stream', 'Content-Type': 'application/x-www-form-urlencoded'}
payload = {'url': required('SHOTFORGE_TARGET_URL', 'https://example.com'), 'template': 'ember-frame', 'title': 'Your next idea', 'subtitle': 'A fresh view', 'brand': 'Your app'}
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False) as client:
    response = client.request('POST', base_url + path, headers=headers, data=payload)
    if response.status_code not in (200,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    if response.headers.get('content-type', '').split(';')[0] not in ('image/png',):
        raise SystemExit('Unexpected response media type')
    target = Path('shotforge-anonymous-og.png')
    with target.open('xb') as output:
        output.write(response.content)
    target.chmod(0o600)
    print(f'Saved private response to {target}')

Anonymous tools are limited to 10 requests per minute per IP and do not use account quota. They do not support JPEG, full-page capture, target authentication, PDF, or dimensions above the limits shown.

POST

/api/v1/screenshot

Render a webpage as PNG or JPEG. Fixed viewport and scrolling full-page modes are supported.

FieldTypeDefaultDescription
urlstring—Required absolute http:// or https:// URL. Private, loopback, link-local, reserved, and private-redirect destinations are blocked.
widthinteger1280200–3840 px, additionally capped by the active plan.
heightinteger800200–5000 px. Ignored as final height when full_page is true.
full_pagebooleanfalseStarter and above. Scrolls lazy-loaded content and captures the page with automatic height.
formatstringpngpng | jpeg
delay_msinteger0Extra delay after navigation: 0–10000 ms.
cleanbooleantrueDismiss common cookie, GDPR, and chat overlays before capture.
authobject | nullnullOptional one-time target-site credentials; Starter and above.

JPEG screenshot

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/octet-stream', 'Content-Type': 'application/json', 'X-API-Key': header_value(required('SHOTFORGE_API_KEY', None))}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/api/v1/screenshot')
(workdir / 'body').write_text(json.dumps({'url': required('SHOTFORGE_TARGET_URL', 'https://example.com'), 'width': 1280, 'height': 800, 'format': 'jpeg', 'clean': True}))
PY
endpoint=$(<"$workdir/endpoint")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request POST \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  --data-binary "@$workdir/body" \
  "$endpoint")
case "$http_status" in 200) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" shotforge-screenshot.jpeg "$workdir/response_headers" <<'PY'
import json, os, sys
from pathlib import Path
source, target = Path(sys.argv[1]), Path(sys.argv[2])
types = [line.split(':', 1)[1].strip().split(';')[0] for line in Path(sys.argv[3]).read_text().splitlines() if line.lower().startswith('content-type:')]
media_type = types[-1] if types else ''
if media_type not in ('image/jpeg',):
    raise SystemExit('Unexpected response media type')
with target.open('xb') as output:
    output.write(source.read_bytes())
target.chmod(0o600)
print(f'Saved private response to {target}')
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/api/v1/screenshot';
$headers = ['Accept: application/octet-stream', 'Content-Type: application/json', 'X-API-Key: ' . headerValue(required('SHOTFORGE_API_KEY', null))];
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_POSTFIELDS => json_encode(['url' => required('SHOTFORGE_TARGET_URL', 'https://example.com'), 'width' => 1280, 'height' => 800, 'format' => 'jpeg', 'clean' => true], JSON_THROW_ON_ERROR),
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [200], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
if (!in_array($mediaType, ['image/jpeg'], true)) {
    throw new RuntimeException('Unexpected response media type');
}
$target = 'shotforge-screenshot.jpeg';
$output = fopen($target, 'xb');
if ($output === false) { throw new RuntimeException('Output already exists or cannot be created'); }
if (fwrite($output, $content) !== strlen($content)) {
    fclose($output); throw new RuntimeException('Incomplete output');
}
fclose($output);
chmod($target, 0600);
echo "Saved private response to " . $target . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/api/v1/screenshot'
headers = {'Accept': 'application/octet-stream', 'Content-Type': 'application/json', 'X-API-Key': header_value(required('SHOTFORGE_API_KEY', None))}
payload = {'url': required('SHOTFORGE_TARGET_URL', 'https://example.com'), 'width': 1280, 'height': 800, 'format': 'jpeg', 'clean': True}
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False) as client:
    response = client.request('POST', base_url + path, headers=headers, json=payload)
    if response.status_code not in (200,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    if response.headers.get('content-type', '').split(';')[0] not in ('image/jpeg',):
        raise SystemExit('Unexpected response media type')
    target = Path('shotforge-screenshot.jpeg')
    with target.open('xb') as output:
        output.write(response.content)
    target.chmod(0o600)
    print(f'Saved private response to {target}')

Full-page screenshot example

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/octet-stream', 'Content-Type': 'application/json', 'X-API-Key': header_value(required('SHOTFORGE_API_KEY', None))}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/api/v1/screenshot')
(workdir / 'body').write_text(json.dumps({'url': required('SHOTFORGE_TARGET_URL', 'https://example.com'), 'width': 1280, 'height': 800, 'full_page': True, 'delay_ms': 1000, 'clean': True}))
PY
endpoint=$(<"$workdir/endpoint")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request POST \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  --data-binary "@$workdir/body" \
  "$endpoint")
case "$http_status" in 200) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" shotforge-fullpage.png "$workdir/response_headers" <<'PY'
import json, os, sys
from pathlib import Path
source, target = Path(sys.argv[1]), Path(sys.argv[2])
types = [line.split(':', 1)[1].strip().split(';')[0] for line in Path(sys.argv[3]).read_text().splitlines() if line.lower().startswith('content-type:')]
media_type = types[-1] if types else ''
if media_type not in ('image/png',):
    raise SystemExit('Unexpected response media type')
with target.open('xb') as output:
    output.write(source.read_bytes())
target.chmod(0o600)
print(f'Saved private response to {target}')
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/api/v1/screenshot';
$headers = ['Accept: application/octet-stream', 'Content-Type: application/json', 'X-API-Key: ' . headerValue(required('SHOTFORGE_API_KEY', null))];
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_POSTFIELDS => json_encode(['url' => required('SHOTFORGE_TARGET_URL', 'https://example.com'), 'width' => 1280, 'height' => 800, 'full_page' => true, 'delay_ms' => 1000, 'clean' => true], JSON_THROW_ON_ERROR),
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [200], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
if (!in_array($mediaType, ['image/png'], true)) {
    throw new RuntimeException('Unexpected response media type');
}
$target = 'shotforge-fullpage.png';
$output = fopen($target, 'xb');
if ($output === false) { throw new RuntimeException('Output already exists or cannot be created'); }
if (fwrite($output, $content) !== strlen($content)) {
    fclose($output); throw new RuntimeException('Incomplete output');
}
fclose($output);
chmod($target, 0600);
echo "Saved private response to " . $target . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/api/v1/screenshot'
headers = {'Accept': 'application/octet-stream', 'Content-Type': 'application/json', 'X-API-Key': header_value(required('SHOTFORGE_API_KEY', None))}
payload = {'url': required('SHOTFORGE_TARGET_URL', 'https://example.com'), 'width': 1280, 'height': 800, 'full_page': True, 'delay_ms': 1000, 'clean': True}
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False) as client:
    response = client.request('POST', base_url + path, headers=headers, json=payload)
    if response.status_code not in (200,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    if response.headers.get('content-type', '').split(';')[0] not in ('image/png',):
        raise SystemExit('Unexpected response media type')
    target = Path('shotforge-fullpage.png')
    with target.open('xb') as output:
        output.write(response.content)
    target.chmod(0o600)
    print(f'Saved private response to {target}')

🔒 Authenticated target pages

Capture a page behind HTTP Basic authentication or a login form by adding auth to the screenshot request. Available on Starter, Pro, Business, and the Pro trial.

FieldTypeDefaultDescription
auth.usernamestring—Target-site username or email, 1–200 characters.
auth.passwordstring—Target-site password, 1–200 characters. Send over HTTPS only.
auth.typestringbasicbasic for same-origin HTTP Basic auth; form to fill and submit a login form.
auth.selectorsobject | nullautoOptional CSS selectors named username, password, and submit. Automatic selectors are used when omitted.

Target-site HTTP Basic authentication

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/octet-stream', 'Content-Type': 'application/json', 'X-API-Key': header_value(required('SHOTFORGE_API_KEY', None))}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/api/v1/screenshot')
(workdir / 'body').write_text(json.dumps({'url': required('SHOTFORGE_TARGET_URL', 'https://example.com'), 'auth': {'username': required('SHOTFORGE_TARGET_USERNAME', None), 'password': required('SHOTFORGE_TARGET_PASSWORD', None), 'type': 'basic'}}))
PY
endpoint=$(<"$workdir/endpoint")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request POST \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  --data-binary "@$workdir/body" \
  "$endpoint")
case "$http_status" in 200) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" shotforge-basic.png "$workdir/response_headers" <<'PY'
import json, os, sys
from pathlib import Path
source, target = Path(sys.argv[1]), Path(sys.argv[2])
types = [line.split(':', 1)[1].strip().split(';')[0] for line in Path(sys.argv[3]).read_text().splitlines() if line.lower().startswith('content-type:')]
media_type = types[-1] if types else ''
if media_type not in ('image/png',):
    raise SystemExit('Unexpected response media type')
with target.open('xb') as output:
    output.write(source.read_bytes())
target.chmod(0o600)
print(f'Saved private response to {target}')
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/api/v1/screenshot';
$headers = ['Accept: application/octet-stream', 'Content-Type: application/json', 'X-API-Key: ' . headerValue(required('SHOTFORGE_API_KEY', null))];
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_POSTFIELDS => json_encode(['url' => required('SHOTFORGE_TARGET_URL', 'https://example.com'), 'auth' => ['username' => required('SHOTFORGE_TARGET_USERNAME', null), 'password' => required('SHOTFORGE_TARGET_PASSWORD', null), 'type' => 'basic']], JSON_THROW_ON_ERROR),
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [200], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
if (!in_array($mediaType, ['image/png'], true)) {
    throw new RuntimeException('Unexpected response media type');
}
$target = 'shotforge-basic.png';
$output = fopen($target, 'xb');
if ($output === false) { throw new RuntimeException('Output already exists or cannot be created'); }
if (fwrite($output, $content) !== strlen($content)) {
    fclose($output); throw new RuntimeException('Incomplete output');
}
fclose($output);
chmod($target, 0600);
echo "Saved private response to " . $target . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/api/v1/screenshot'
headers = {'Accept': 'application/octet-stream', 'Content-Type': 'application/json', 'X-API-Key': header_value(required('SHOTFORGE_API_KEY', None))}
payload = {'url': required('SHOTFORGE_TARGET_URL', 'https://example.com'), 'auth': {'username': required('SHOTFORGE_TARGET_USERNAME', None), 'password': required('SHOTFORGE_TARGET_PASSWORD', None), 'type': 'basic'}}
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False) as client:
    response = client.request('POST', base_url + path, headers=headers, json=payload)
    if response.status_code not in (200,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    if response.headers.get('content-type', '').split(';')[0] not in ('image/png',):
        raise SystemExit('Unexpected response media type')
    target = Path('shotforge-basic.png')
    with target.open('xb') as output:
        output.write(response.content)
    target.chmod(0o600)
    print(f'Saved private response to {target}')

Target-site login form

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/octet-stream', 'Content-Type': 'application/json', 'X-API-Key': header_value(required('SHOTFORGE_API_KEY', None))}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/api/v1/screenshot')
(workdir / 'body').write_text(json.dumps({'url': required('SHOTFORGE_TARGET_URL', 'https://example.com'), 'auth': {'username': required('SHOTFORGE_TARGET_USERNAME', None), 'password': required('SHOTFORGE_TARGET_PASSWORD', None), 'type': 'form', 'selectors': {'username': 'input[name=email]', 'password': 'input[name=password]', 'submit': 'button[type=submit]'}}}))
PY
endpoint=$(<"$workdir/endpoint")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request POST \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  --data-binary "@$workdir/body" \
  "$endpoint")
case "$http_status" in 200) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" shotforge-form.png "$workdir/response_headers" <<'PY'
import json, os, sys
from pathlib import Path
source, target = Path(sys.argv[1]), Path(sys.argv[2])
types = [line.split(':', 1)[1].strip().split(';')[0] for line in Path(sys.argv[3]).read_text().splitlines() if line.lower().startswith('content-type:')]
media_type = types[-1] if types else ''
if media_type not in ('image/png',):
    raise SystemExit('Unexpected response media type')
with target.open('xb') as output:
    output.write(source.read_bytes())
target.chmod(0o600)
print(f'Saved private response to {target}')
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/api/v1/screenshot';
$headers = ['Accept: application/octet-stream', 'Content-Type: application/json', 'X-API-Key: ' . headerValue(required('SHOTFORGE_API_KEY', null))];
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_POSTFIELDS => json_encode(['url' => required('SHOTFORGE_TARGET_URL', 'https://example.com'), 'auth' => ['username' => required('SHOTFORGE_TARGET_USERNAME', null), 'password' => required('SHOTFORGE_TARGET_PASSWORD', null), 'type' => 'form', 'selectors' => ['username' => 'input[name=email]', 'password' => 'input[name=password]', 'submit' => 'button[type=submit]']]], JSON_THROW_ON_ERROR),
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [200], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
if (!in_array($mediaType, ['image/png'], true)) {
    throw new RuntimeException('Unexpected response media type');
}
$target = 'shotforge-form.png';
$output = fopen($target, 'xb');
if ($output === false) { throw new RuntimeException('Output already exists or cannot be created'); }
if (fwrite($output, $content) !== strlen($content)) {
    fclose($output); throw new RuntimeException('Incomplete output');
}
fclose($output);
chmod($target, 0600);
echo "Saved private response to " . $target . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/api/v1/screenshot'
headers = {'Accept': 'application/octet-stream', 'Content-Type': 'application/json', 'X-API-Key': header_value(required('SHOTFORGE_API_KEY', None))}
payload = {'url': required('SHOTFORGE_TARGET_URL', 'https://example.com'), 'auth': {'username': required('SHOTFORGE_TARGET_USERNAME', None), 'password': required('SHOTFORGE_TARGET_PASSWORD', None), 'type': 'form', 'selectors': {'username': 'input[name=email]', 'password': 'input[name=password]', 'submit': 'button[type=submit]'}}}
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False) as client:
    response = client.request('POST', base_url + path, headers=headers, json=payload)
    if response.status_code not in (200,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    if response.headers.get('content-type', '').split(';')[0] not in ('image/png',):
        raise SystemExit('Unexpected response media type')
    target = Path('shotforge-form.png')
    with target.open('xb') as output:
        output.write(response.content)
    target.chmod(0o600)
    print(f'Saved private response to {target}')

Target credentials are used only in the isolated browser context for this request. They are never stored, logged, returned, or included in usage history.

GET

/api/v1/og-templates

Public discovery endpoint. lang accepts en or fr and returns all 72 IDs, localized names, visual metadata and required_plan (free or pro). Rendering enforces the effective plan before quota reservation.

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/json'}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/api/v1/og-templates?lang=fr')
PY
endpoint=$(<"$workdir/endpoint")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request GET \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  "$endpoint")
case "$http_status" in 200) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" <<'PY'
import json, sys
from pathlib import Path
print(json.dumps(json.loads(Path(sys.argv[1]).read_text()), indent=2))
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/api/v1/og-templates?lang=fr';
$headers = ['Accept: application/json'];
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [200], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
echo json_encode(json_decode($content, true, 512, JSON_THROW_ON_ERROR), JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR) . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/api/v1/og-templates?lang=fr'
headers = {'Accept': 'application/json'}
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False) as client:
    response = client.request('GET', base_url + path, headers=headers)
    if response.status_code not in (200,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    print(json.dumps(response.json(), indent=2))
POST

/api/v1/og-image

Return image/png. raw preserves the legacy viewport-capture contract; every named template composes a real target-page screenshot into a fixed 1200×630 card.

FieldTypeDefaultDescription
urlstring—Required absolute http:// or https:// URL. Private, loopback, link-local, reserved, and private-redirect destinations are blocked.
templatestringrawraw or an ID returned by GET /api/v1/og-templates.
widthinteger1200Raw mode only: 200–1200 px. Composed templates are always 1200 px.
heightinteger630Raw mode only: 200–630 px. Composed templates are always 630 px.
titlestring""Optional composed-card headline, maximum 120 characters.
subtitlestring""Optional composed-card subtitle, maximum 220 characters.
brandstring""Optional brand label, maximum 60 characters.

Open Graph capture without a template: raw mode

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/octet-stream', 'Content-Type': 'application/json', 'X-API-Key': header_value(required('SHOTFORGE_API_KEY', None))}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/api/v1/og-image')
(workdir / 'body').write_text(json.dumps({'url': required('SHOTFORGE_TARGET_URL', 'https://example.com'), 'template': 'raw', 'width': 1200, 'height': 630}))
PY
endpoint=$(<"$workdir/endpoint")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request POST \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  --data-binary "@$workdir/body" \
  "$endpoint")
case "$http_status" in 200) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" shotforge-og-raw.png "$workdir/response_headers" <<'PY'
import json, os, sys
from pathlib import Path
source, target = Path(sys.argv[1]), Path(sys.argv[2])
types = [line.split(':', 1)[1].strip().split(';')[0] for line in Path(sys.argv[3]).read_text().splitlines() if line.lower().startswith('content-type:')]
media_type = types[-1] if types else ''
if media_type not in ('image/png',):
    raise SystemExit('Unexpected response media type')
with target.open('xb') as output:
    output.write(source.read_bytes())
target.chmod(0o600)
print(f'Saved private response to {target}')
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/api/v1/og-image';
$headers = ['Accept: application/octet-stream', 'Content-Type: application/json', 'X-API-Key: ' . headerValue(required('SHOTFORGE_API_KEY', null))];
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_POSTFIELDS => json_encode(['url' => required('SHOTFORGE_TARGET_URL', 'https://example.com'), 'template' => 'raw', 'width' => 1200, 'height' => 630], JSON_THROW_ON_ERROR),
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [200], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
if (!in_array($mediaType, ['image/png'], true)) {
    throw new RuntimeException('Unexpected response media type');
}
$target = 'shotforge-og-raw.png';
$output = fopen($target, 'xb');
if ($output === false) { throw new RuntimeException('Output already exists or cannot be created'); }
if (fwrite($output, $content) !== strlen($content)) {
    fclose($output); throw new RuntimeException('Incomplete output');
}
fclose($output);
chmod($target, 0600);
echo "Saved private response to " . $target . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/api/v1/og-image'
headers = {'Accept': 'application/octet-stream', 'Content-Type': 'application/json', 'X-API-Key': header_value(required('SHOTFORGE_API_KEY', None))}
payload = {'url': required('SHOTFORGE_TARGET_URL', 'https://example.com'), 'template': 'raw', 'width': 1200, 'height': 630}
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False) as client:
    response = client.request('POST', base_url + path, headers=headers, json=payload)
    if response.status_code not in (200,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    if response.headers.get('content-type', '').split(';')[0] not in ('image/png',):
        raise SystemExit('Unexpected response media type')
    target = Path('shotforge-og-raw.png')
    with target.open('xb') as output:
        output.write(response.content)
    target.chmod(0o600)
    print(f'Saved private response to {target}')

Return image/png. raw preserves the legacy viewport-capture contract; every named template composes a real target-page screenshot into a fixed 1200×630 card.

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/octet-stream', 'Content-Type': 'application/json', 'X-API-Key': header_value(required('SHOTFORGE_API_KEY', None))}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/api/v1/og-image')
(workdir / 'body').write_text(json.dumps({'url': required('SHOTFORGE_TARGET_URL', 'https://example.com'), 'template': 'ember-frame', 'title': 'Your next idea', 'subtitle': 'A fresh view of your work', 'brand': 'Your app'}))
PY
endpoint=$(<"$workdir/endpoint")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request POST \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  --data-binary "@$workdir/body" \
  "$endpoint")
case "$http_status" in 200) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" shotforge-og-template.png "$workdir/response_headers" <<'PY'
import json, os, sys
from pathlib import Path
source, target = Path(sys.argv[1]), Path(sys.argv[2])
types = [line.split(':', 1)[1].strip().split(';')[0] for line in Path(sys.argv[3]).read_text().splitlines() if line.lower().startswith('content-type:')]
media_type = types[-1] if types else ''
if media_type not in ('image/png',):
    raise SystemExit('Unexpected response media type')
with target.open('xb') as output:
    output.write(source.read_bytes())
target.chmod(0o600)
print(f'Saved private response to {target}')
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/api/v1/og-image';
$headers = ['Accept: application/octet-stream', 'Content-Type: application/json', 'X-API-Key: ' . headerValue(required('SHOTFORGE_API_KEY', null))];
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_POSTFIELDS => json_encode(['url' => required('SHOTFORGE_TARGET_URL', 'https://example.com'), 'template' => 'ember-frame', 'title' => 'Your next idea', 'subtitle' => 'A fresh view of your work', 'brand' => 'Your app'], JSON_THROW_ON_ERROR),
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [200], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
if (!in_array($mediaType, ['image/png'], true)) {
    throw new RuntimeException('Unexpected response media type');
}
$target = 'shotforge-og-template.png';
$output = fopen($target, 'xb');
if ($output === false) { throw new RuntimeException('Output already exists or cannot be created'); }
if (fwrite($output, $content) !== strlen($content)) {
    fclose($output); throw new RuntimeException('Incomplete output');
}
fclose($output);
chmod($target, 0600);
echo "Saved private response to " . $target . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/api/v1/og-image'
headers = {'Accept': 'application/octet-stream', 'Content-Type': 'application/json', 'X-API-Key': header_value(required('SHOTFORGE_API_KEY', None))}
payload = {'url': required('SHOTFORGE_TARGET_URL', 'https://example.com'), 'template': 'ember-frame', 'title': 'Your next idea', 'subtitle': 'A fresh view of your work', 'brand': 'Your app'}
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False) as client:
    response = client.request('POST', base_url + path, headers=headers, json=payload)
    if response.status_code not in (200,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    if response.headers.get('content-type', '').split(';')[0] not in ('image/png',):
        raise SystemExit('Unexpected response media type')
    target = Path('shotforge-og-template.png')
    with target.open('xb') as output:
        output.write(response.content)
    target.chmod(0o600)
    print(f'Saved private response to {target}')
Available template IDs (72)
ember-framemidnight-browserpaper-editorialviolet-orbitlime-terminalocean-splitcoral-stackmono-brutalaurora-glasssunset-cardroyal-deviceblueprintrose-magazinesand-galleryneon-circuitforest-windowruby-postersilver-minimalgold-luxeindigo-focusmint-polaroidcharcoal-newspeach-friendlycyber-gridlavender-floatred-alertsky-dashboardcopper-angleplum-storyice-cleanobsidian-commandcream-serifemerald-sidebarcobalt-cascadetangerine-labelgraphite-gridlinefuchsia-collagealpine-cardnoir-cinemalemon-popteal-ticketbrick-reportpearl-productultraviolet-scanmoss-notebookcobalt-phonecrimson-covercyan-isometricclay-windowacid-zinenavy-statblush-lettertungsten-panelamber-quotejade-maplilac-appscarlet-ribbonarctic-doccoffee-stampspectrum-prismsonic-pulsevault-balanceatlas-ticketspectrum-mosaicjournal-spreadhorizon-deckporcelain-typeink-spotlightcitrus-cutoutcerulean-foldterracotta-indexchrome-stage
POST

/api/v1/pdf

Render a webpage as application/pdf. Available on Pro, Business, and the Pro trial.

FieldTypeDefaultDescription
urlstring—Required absolute http:// or https:// URL. Private, loopback, link-local, reserved, and private-redirect destinations are blocked.
formatstringA4A4 | A3 | Letter | Legal
landscapebooleanfalseUse landscape paper orientation.
print_backgroundbooleantrueInclude CSS backgrounds in the PDF.
cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/octet-stream', 'Content-Type': 'application/json', 'X-API-Key': header_value(required('SHOTFORGE_API_KEY', None))}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/api/v1/pdf')
(workdir / 'body').write_text(json.dumps({'url': required('SHOTFORGE_TARGET_URL', 'https://example.com'), 'format': 'A4', 'landscape': False, 'print_background': True}))
PY
endpoint=$(<"$workdir/endpoint")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request POST \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  --data-binary "@$workdir/body" \
  "$endpoint")
case "$http_status" in 200) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" shotforge.pdf "$workdir/response_headers" <<'PY'
import json, os, sys
from pathlib import Path
source, target = Path(sys.argv[1]), Path(sys.argv[2])
types = [line.split(':', 1)[1].strip().split(';')[0] for line in Path(sys.argv[3]).read_text().splitlines() if line.lower().startswith('content-type:')]
media_type = types[-1] if types else ''
if media_type not in ('application/pdf',):
    raise SystemExit('Unexpected response media type')
with target.open('xb') as output:
    output.write(source.read_bytes())
target.chmod(0o600)
print(f'Saved private response to {target}')
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/api/v1/pdf';
$headers = ['Accept: application/octet-stream', 'Content-Type: application/json', 'X-API-Key: ' . headerValue(required('SHOTFORGE_API_KEY', null))];
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_POSTFIELDS => json_encode(['url' => required('SHOTFORGE_TARGET_URL', 'https://example.com'), 'format' => 'A4', 'landscape' => false, 'print_background' => true], JSON_THROW_ON_ERROR),
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [200], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
if (!in_array($mediaType, ['application/pdf'], true)) {
    throw new RuntimeException('Unexpected response media type');
}
$target = 'shotforge.pdf';
$output = fopen($target, 'xb');
if ($output === false) { throw new RuntimeException('Output already exists or cannot be created'); }
if (fwrite($output, $content) !== strlen($content)) {
    fclose($output); throw new RuntimeException('Incomplete output');
}
fclose($output);
chmod($target, 0600);
echo "Saved private response to " . $target . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/api/v1/pdf'
headers = {'Accept': 'application/octet-stream', 'Content-Type': 'application/json', 'X-API-Key': header_value(required('SHOTFORGE_API_KEY', None))}
payload = {'url': required('SHOTFORGE_TARGET_URL', 'https://example.com'), 'format': 'A4', 'landscape': False, 'print_background': True}
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False) as client:
    response = client.request('POST', base_url + path, headers=headers, json=payload)
    if response.status_code not in (200,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    if response.headers.get('content-type', '').split(';')[0] not in ('application/pdf',):
        raise SystemExit('Unexpected response media type')
    target = Path('shotforge.pdf')
    with target.open('xb') as output:
        output.write(response.content)
    target.chmod(0o600)
    print(f'Saved private response to {target}')

Signed-in workspace history

GET /api/v1/history?page=1 returns at most 30 results, newest first. The response includes items, page, page_size, total, total_pages and retention_days. page starts at 1. GET /api/v1/history/{id}/download returns retained bytes without rendering again or spending another credit.

History and downloads require the shotforge_token browser-session cookie. API keys and Bearer tokens are rejected, even when a valid cookie accompanies the request. First establish the session with POST /app/login in the account-management workflow below.

Retention: Free 7 days, Starter 30 days, Pro 30 days, Business 90 days. An active Pro trial uses Pro retention. There is no 30-file cap: 30 is the page size. Expired files return 404 even while bucket deletion is pending.

GET /api/v1/history?page=1

{
  "items": [{
    "id": "0123456789abcdef0123456789abcdef",
    "kind": "screenshot", "media_type": "image/png",
    "filename": "screenshot.png", "byte_size": 48230,
    "created_at": "2026-09-29T12:00:00Z",
    "download_url": "/api/v1/history/0123456789abcdef0123456789abcdef/download"
  }],
  "page": 1, "page_size": 30, "total": 1,
  "total_pages": 1, "retention_days": 30
}

A plan change immediately adjusts the accessible window. Already deleted files are not restored. Projects and sources have independent retention. GET /api/billing/plans exposes history_retention_days for each plan. Anonymous generations are not added to an account history.

GET /api/v1/history?page=1

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/json'}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/api/v1/history?page=1')
cookie_file = Path(required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt'))
if cookie_file.exists() and cookie_file.stat().st_mode & 0o077:
    raise SystemExit('Cookie jar must have mode 600')
if not cookie_file.is_file():
    raise SystemExit('Run session_login first')
(workdir / 'cookie_path').write_text(str(cookie_file))
PY
endpoint=$(<"$workdir/endpoint")
cookie_file=$(<"$workdir/cookie_path")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request GET \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  --cookie "$cookie_file" \
  "$endpoint")
case "$http_status" in 200) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" <<'PY'
import json, sys
from pathlib import Path
print(json.dumps(json.loads(Path(sys.argv[1]).read_text()), indent=2))
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/api/v1/history?page=1';
$headers = ['Accept: application/json'];
$cookieFile = required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt');
if (file_exists($cookieFile) && (fileperms($cookieFile) & 0077)) {
    throw new RuntimeException('Cookie jar must have mode 600');
}
if (!is_file($cookieFile)) { throw new RuntimeException('Run session_login first'); }
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_COOKIEFILE => $cookieFile,
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [200], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
echo json_encode(json_decode($content, true, 512, JSON_THROW_ON_ERROR), JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR) . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/api/v1/history?page=1'
headers = {'Accept': 'application/json'}
cookie_file = Path(required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt'))
if cookie_file.exists() and cookie_file.stat().st_mode & 0o077:
    raise SystemExit('Cookie jar must have mode 600')
cookies = http.cookiejar.MozillaCookieJar(str(cookie_file))
if not cookie_file.is_file():
    raise SystemExit('Run session_login first')
cookies.load(ignore_discard=True, ignore_expires=False)
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False, cookies=cookies) as client:
    response = client.request('GET', base_url + path, headers=headers)
    if response.status_code not in (200,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    print(json.dumps(response.json(), indent=2))

GET /api/v1/history/{id}/download

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/octet-stream'}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/api/v1/history/{artifact_id}/download'.replace('{artifact_id}', quote(required('SHOTFORGE_ARTIFACT_ID', None), safe='')))
cookie_file = Path(required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt'))
if cookie_file.exists() and cookie_file.stat().st_mode & 0o077:
    raise SystemExit('Cookie jar must have mode 600')
if not cookie_file.is_file():
    raise SystemExit('Run session_login first')
(workdir / 'cookie_path').write_text(str(cookie_file))
PY
endpoint=$(<"$workdir/endpoint")
cookie_file=$(<"$workdir/cookie_path")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request GET \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  --cookie "$cookie_file" \
  "$endpoint")
case "$http_status" in 200) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" shotforge-artifact.bin "$workdir/response_headers" <<'PY'
import json, os, sys
from pathlib import Path
source, target = Path(sys.argv[1]), Path(sys.argv[2])
types = [line.split(':', 1)[1].strip().split(';')[0] for line in Path(sys.argv[3]).read_text().splitlines() if line.lower().startswith('content-type:')]
media_type = types[-1] if types else ''
if not media_type or media_type == 'application/json':
    raise SystemExit('Unexpected response media type')
with target.open('xb') as output:
    output.write(source.read_bytes())
target.chmod(0o600)
print(f'Saved private response to {target}')
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/api/v1/history/{artifact_id}/download';
$path = str_replace('{artifact_id}', rawurlencode(required('SHOTFORGE_ARTIFACT_ID', null)), $path);
$headers = ['Accept: application/octet-stream'];
$cookieFile = required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt');
if (file_exists($cookieFile) && (fileperms($cookieFile) & 0077)) {
    throw new RuntimeException('Cookie jar must have mode 600');
}
if (!is_file($cookieFile)) { throw new RuntimeException('Run session_login first'); }
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_COOKIEFILE => $cookieFile,
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [200], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
if ($mediaType === '' || $mediaType === 'application/json') {
    throw new RuntimeException('Unexpected response media type');
}
$target = 'shotforge-artifact.bin';
$output = fopen($target, 'xb');
if ($output === false) { throw new RuntimeException('Output already exists or cannot be created'); }
if (fwrite($output, $content) !== strlen($content)) {
    fclose($output); throw new RuntimeException('Incomplete output');
}
fclose($output);
chmod($target, 0600);
echo "Saved private response to " . $target . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/api/v1/history/{artifact_id}/download'.replace('{artifact_id}', quote(required('SHOTFORGE_ARTIFACT_ID', None), safe=''))
headers = {'Accept': 'application/octet-stream'}
cookie_file = Path(required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt'))
if cookie_file.exists() and cookie_file.stat().st_mode & 0o077:
    raise SystemExit('Cookie jar must have mode 600')
cookies = http.cookiejar.MozillaCookieJar(str(cookie_file))
if not cookie_file.is_file():
    raise SystemExit('Run session_login first')
cookies.load(ignore_discard=True, ignore_expires=False)
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False, cookies=cookies) as client:
    response = client.request('GET', base_url + path, headers=headers)
    if response.status_code not in (200,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    if not response.headers.get('content-type') or response.headers.get('content-type', '').split(';')[0] == 'application/json':
        raise SystemExit('Unexpected response media type')
    target = Path('shotforge-artifact.bin')
    with target.open('xb') as output:
        output.write(response.content)
    target.chmod(0o600)
    print(f'Saved private response to {target}')

Account and key endpoints

The table specifies authentication for each route. Registration and tokens are covered above; the management operations below require a browser session, separate from render credentials.

MethodEndpointAuthenticationDescription
POST/api/auth/register—Create an account. email; password 10–128 characters with a letter and digit; optional full_name. Returns access_token and refresh_token.
POST/api/auth/login—Authenticate with email and password. Returns a new access/refresh pair.
POST/api/auth/refreshRefresh tokenRotate a refresh token. The submitted token becomes unusable; reuse revokes all refresh tokens for that account. Existing access tokens expire naturally within 30 minutes.
POST/api/auth/logoutRefresh tokenRevoke the refresh_token supplied in the JSON body. Returns 204.
GET/api/auth/meBrowser sessionReturn account identity, effective plan, and subscription status.
GET/api/auth/usageAPI key / Bearer / Browser sessionReturn successful renders used this UTC month, limit, percentage, and effective plan.
GET/api/auth/keysBrowser sessionList key metadata only; raw keys and fingerprints are never returned.
POST/api/auth/keysBrowser sessionCreate a named key (name: 1–100 characters). The raw api_key is returned once.
DELETE/api/auth/keys/{id}Browser sessionRevoke a key owned by the authenticated account and immediately end its render access. Switch affected integrations to another key before revoking it. Returns 204.
GET/api/auth/exportBrowser sessionExport account, key metadata, sanitized usage history, and session metadata as JSON. Secrets and hashes are excluded.
POST/api/auth/delete-accountBrowser sessionPermanently delete the account after password verification. Body: email and password. Returns 204.
GET/api/billing/plans—Public live plan catalog with prices, quotas, widths, and feature flags.
GET/api/billing/statusBrowser sessionReturn the stored billing plan, subscription status, and whether Stripe is available.
POST/api/billing/checkoutBrowser sessionCreate an embedded payment session for starter, pro or business after tax validation. Returns session_id and client_secret; do not log the response. The request alone does not confirm payment.
POST/api/billing/portalBrowser sessionLocal compatibility route: returns portal_url with /app/billing to open the ShotForge billing workspace.

Access tokens expire after 30 minutes. Refresh tokens expire after 7 days and rotate on every refresh. Password changes and resets revoke active sessions. Register and login are limited to 20 attempts per minute per IP. An account is initially locked for 5 minutes after 5 consecutive failed logins; further failures apply exponential backoff up to 24 hours.

Management with a browser session

POST /app/login creates the session cookie saved in a private file. Reuse this file for account identity, keys, export and deletion. Do not send X-API-Key or Authorization headers with these operations; JSON login through /api/auth/login does not provide the required cookie.

POST /app/login

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/json', 'Content-Type': 'application/x-www-form-urlencoded'}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/app/login')
(workdir / 'body').write_text(urlencode({'email': required('SHOTFORGE_ACCOUNT_EMAIL', None), 'password': required('SHOTFORGE_ACCOUNT_PASSWORD', None), 'lang': 'fr'}))
cookie_file = Path(required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt'))
if cookie_file.exists() and cookie_file.stat().st_mode & 0o077:
    raise SystemExit('Cookie jar must have mode 600')
cookie_file.touch(mode=0o600, exist_ok=True)
(workdir / 'cookie_path').write_text(str(cookie_file))
PY
endpoint=$(<"$workdir/endpoint")
cookie_file=$(<"$workdir/cookie_path")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request POST \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  --cookie "$cookie_file" \
  --cookie-jar "$cookie_file" \
  --data-binary "@$workdir/body" \
  "$endpoint")
case "$http_status" in 302|303) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$cookie_file" <<'PY'
import http.cookiejar, sys
cookies = http.cookiejar.MozillaCookieJar(sys.argv[1])
cookies.load(ignore_discard=True, ignore_expires=False)
if not any(cookie.name == 'shotforge_token' and cookie.value for cookie in cookies):
    raise SystemExit('No browser session cookie received')
PY
printf 'Browser session cookie jar saved privately.\n'
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/app/login';
$headers = ['Accept: application/json', 'Content-Type: application/x-www-form-urlencoded'];
$cookieFile = required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt');
if (file_exists($cookieFile) && (fileperms($cookieFile) & 0077)) {
    throw new RuntimeException('Cookie jar must have mode 600');
}
if (!file_exists($cookieFile) && !touch($cookieFile)) {
    throw new RuntimeException('Cannot create cookie jar');
}
chmod($cookieFile, 0600);
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_COOKIEFILE => $cookieFile,
    CURLOPT_COOKIEJAR => $cookieFile,
    CURLOPT_POSTFIELDS => http_build_query(['email' => required('SHOTFORGE_ACCOUNT_EMAIL', null), 'password' => required('SHOTFORGE_ACCOUNT_PASSWORD', null), 'lang' => 'fr']),
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [302, 303], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
chmod($cookieFile, 0600);
if (!str_contains((string) file_get_contents($cookieFile), "\tshotforge_token\t")) {
    throw new RuntimeException('No browser session cookie received');
}
echo "Browser session cookie jar saved privately.\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/app/login'
headers = {'Accept': 'application/json', 'Content-Type': 'application/x-www-form-urlencoded'}
cookie_file = Path(required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt'))
if cookie_file.exists() and cookie_file.stat().st_mode & 0o077:
    raise SystemExit('Cookie jar must have mode 600')
cookies = http.cookiejar.MozillaCookieJar(str(cookie_file))
payload = {'email': required('SHOTFORGE_ACCOUNT_EMAIL', None), 'password': required('SHOTFORGE_ACCOUNT_PASSWORD', None), 'lang': 'fr'}
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False, cookies=cookies) as client:
    response = client.request('POST', base_url + path, headers=headers, data=payload)
    if response.status_code not in (302, 303):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    if not any(cookie.name == 'shotforge_token' and cookie.value for cookie in client.cookies.jar):
        raise SystemExit('No browser session cookie received')
    cookies.save(ignore_discard=True, ignore_expires=False)
    cookie_file.chmod(0o600)
    print('Browser session cookie jar saved privately.')

GET /api/auth/keys

List key metadata only; raw keys and fingerprints are never returned.

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/json'}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/api/auth/keys')
cookie_file = Path(required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt'))
if cookie_file.exists() and cookie_file.stat().st_mode & 0o077:
    raise SystemExit('Cookie jar must have mode 600')
if not cookie_file.is_file():
    raise SystemExit('Run session_login first')
(workdir / 'cookie_path').write_text(str(cookie_file))
PY
endpoint=$(<"$workdir/endpoint")
cookie_file=$(<"$workdir/cookie_path")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request GET \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  --cookie "$cookie_file" \
  "$endpoint")
case "$http_status" in 200) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" <<'PY'
import json, sys
from pathlib import Path
print(json.dumps(json.loads(Path(sys.argv[1]).read_text()), indent=2))
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/api/auth/keys';
$headers = ['Accept: application/json'];
$cookieFile = required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt');
if (file_exists($cookieFile) && (fileperms($cookieFile) & 0077)) {
    throw new RuntimeException('Cookie jar must have mode 600');
}
if (!is_file($cookieFile)) { throw new RuntimeException('Run session_login first'); }
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_COOKIEFILE => $cookieFile,
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [200], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
echo json_encode(json_decode($content, true, 512, JSON_THROW_ON_ERROR), JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR) . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/api/auth/keys'
headers = {'Accept': 'application/json'}
cookie_file = Path(required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt'))
if cookie_file.exists() and cookie_file.stat().st_mode & 0o077:
    raise SystemExit('Cookie jar must have mode 600')
cookies = http.cookiejar.MozillaCookieJar(str(cookie_file))
if not cookie_file.is_file():
    raise SystemExit('Run session_login first')
cookies.load(ignore_discard=True, ignore_expires=False)
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False, cookies=cookies) as client:
    response = client.request('GET', base_url + path, headers=headers)
    if response.status_code not in (200,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    print(json.dumps(response.json(), indent=2))

POST /api/auth/keys

Create a named key (name: 1–100 characters). The raw api_key is returned once.

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/api/auth/keys')
(workdir / 'body').write_text(json.dumps({'name': 'Documentation client'}))
cookie_file = Path(required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt'))
if cookie_file.exists() and cookie_file.stat().st_mode & 0o077:
    raise SystemExit('Cookie jar must have mode 600')
if not cookie_file.is_file():
    raise SystemExit('Run session_login first')
(workdir / 'cookie_path').write_text(str(cookie_file))
PY
endpoint=$(<"$workdir/endpoint")
cookie_file=$(<"$workdir/cookie_path")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request POST \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  --cookie "$cookie_file" \
  --data-binary "@$workdir/body" \
  "$endpoint")
case "$http_status" in 201) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" shotforge-created-key.json "$workdir/response_headers" <<'PY'
import json, os, sys
from pathlib import Path
source, target = Path(sys.argv[1]), Path(sys.argv[2])
json.loads(source.read_text())
with target.open('xb') as output:
    output.write(source.read_bytes())
target.chmod(0o600)
print(f'Saved private response to {target}')
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/api/auth/keys';
$headers = ['Accept: application/json', 'Content-Type: application/json'];
$cookieFile = required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt');
if (file_exists($cookieFile) && (fileperms($cookieFile) & 0077)) {
    throw new RuntimeException('Cookie jar must have mode 600');
}
if (!is_file($cookieFile)) { throw new RuntimeException('Run session_login first'); }
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_COOKIEFILE => $cookieFile,
    CURLOPT_POSTFIELDS => json_encode(['name' => 'Documentation client'], JSON_THROW_ON_ERROR),
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [201], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
json_decode($content, true, 512, JSON_THROW_ON_ERROR);
$target = 'shotforge-created-key.json';
$output = fopen($target, 'xb');
if ($output === false) { throw new RuntimeException('Output already exists or cannot be created'); }
if (fwrite($output, $content) !== strlen($content)) {
    fclose($output); throw new RuntimeException('Incomplete output');
}
fclose($output);
chmod($target, 0600);
echo "Saved private response to " . $target . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/api/auth/keys'
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
cookie_file = Path(required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt'))
if cookie_file.exists() and cookie_file.stat().st_mode & 0o077:
    raise SystemExit('Cookie jar must have mode 600')
cookies = http.cookiejar.MozillaCookieJar(str(cookie_file))
if not cookie_file.is_file():
    raise SystemExit('Run session_login first')
cookies.load(ignore_discard=True, ignore_expires=False)
payload = {'name': 'Documentation client'}
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False, cookies=cookies) as client:
    response = client.request('POST', base_url + path, headers=headers, json=payload)
    if response.status_code not in (201,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    response.json()
    target = Path('shotforge-created-key.json')
    with target.open('xb') as output:
        output.write(response.content)
    target.chmod(0o600)
    print(f'Saved private response to {target}')

DELETE /api/auth/keys/{id}

Revoke a key owned by the authenticated account and immediately end its render access. Switch affected integrations to another key before revoking it. Returns 204.

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/json'}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/api/auth/keys/{key_id}'.replace('{key_id}', quote(required('SHOTFORGE_KEY_ID', None), safe='')))
cookie_file = Path(required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt'))
if cookie_file.exists() and cookie_file.stat().st_mode & 0o077:
    raise SystemExit('Cookie jar must have mode 600')
if not cookie_file.is_file():
    raise SystemExit('Run session_login first')
(workdir / 'cookie_path').write_text(str(cookie_file))
PY
endpoint=$(<"$workdir/endpoint")
cookie_file=$(<"$workdir/cookie_path")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request DELETE \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  --cookie "$cookie_file" \
  "$endpoint")
case "$http_status" in 204) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
printf 'HTTP %s\n' "$http_status"
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/api/auth/keys/{key_id}';
$path = str_replace('{key_id}', rawurlencode(required('SHOTFORGE_KEY_ID', null)), $path);
$headers = ['Accept: application/json'];
$cookieFile = required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt');
if (file_exists($cookieFile) && (fileperms($cookieFile) & 0077)) {
    throw new RuntimeException('Cookie jar must have mode 600');
}
if (!is_file($cookieFile)) { throw new RuntimeException('Run session_login first'); }
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'DELETE',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_COOKIEFILE => $cookieFile,
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [204], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
echo "HTTP " . $status . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/api/auth/keys/{key_id}'.replace('{key_id}', quote(required('SHOTFORGE_KEY_ID', None), safe=''))
headers = {'Accept': 'application/json'}
cookie_file = Path(required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt'))
if cookie_file.exists() and cookie_file.stat().st_mode & 0o077:
    raise SystemExit('Cookie jar must have mode 600')
cookies = http.cookiejar.MozillaCookieJar(str(cookie_file))
if not cookie_file.is_file():
    raise SystemExit('Run session_login first')
cookies.load(ignore_discard=True, ignore_expires=False)
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False, cookies=cookies) as client:
    response = client.request('DELETE', base_url + path, headers=headers)
    if response.status_code not in (204,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    print(f'HTTP {response.status_code}')

GET /api/auth/me

Return account identity, effective plan, and subscription status.

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/json'}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/api/auth/me')
cookie_file = Path(required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt'))
if cookie_file.exists() and cookie_file.stat().st_mode & 0o077:
    raise SystemExit('Cookie jar must have mode 600')
if not cookie_file.is_file():
    raise SystemExit('Run session_login first')
(workdir / 'cookie_path').write_text(str(cookie_file))
PY
endpoint=$(<"$workdir/endpoint")
cookie_file=$(<"$workdir/cookie_path")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request GET \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  --cookie "$cookie_file" \
  "$endpoint")
case "$http_status" in 200) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" <<'PY'
import json, sys
from pathlib import Path
print(json.dumps(json.loads(Path(sys.argv[1]).read_text()), indent=2))
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/api/auth/me';
$headers = ['Accept: application/json'];
$cookieFile = required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt');
if (file_exists($cookieFile) && (fileperms($cookieFile) & 0077)) {
    throw new RuntimeException('Cookie jar must have mode 600');
}
if (!is_file($cookieFile)) { throw new RuntimeException('Run session_login first'); }
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_COOKIEFILE => $cookieFile,
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [200], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
echo json_encode(json_decode($content, true, 512, JSON_THROW_ON_ERROR), JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR) . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/api/auth/me'
headers = {'Accept': 'application/json'}
cookie_file = Path(required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt'))
if cookie_file.exists() and cookie_file.stat().st_mode & 0o077:
    raise SystemExit('Cookie jar must have mode 600')
cookies = http.cookiejar.MozillaCookieJar(str(cookie_file))
if not cookie_file.is_file():
    raise SystemExit('Run session_login first')
cookies.load(ignore_discard=True, ignore_expires=False)
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False, cookies=cookies) as client:
    response = client.request('GET', base_url + path, headers=headers)
    if response.status_code not in (200,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    print(json.dumps(response.json(), indent=2))

GET /api/auth/export

Export account, key metadata, sanitized usage history, and session metadata as JSON. Secrets and hashes are excluded.

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/json'}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/api/auth/export')
cookie_file = Path(required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt'))
if cookie_file.exists() and cookie_file.stat().st_mode & 0o077:
    raise SystemExit('Cookie jar must have mode 600')
if not cookie_file.is_file():
    raise SystemExit('Run session_login first')
(workdir / 'cookie_path').write_text(str(cookie_file))
PY
endpoint=$(<"$workdir/endpoint")
cookie_file=$(<"$workdir/cookie_path")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request GET \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  --cookie "$cookie_file" \
  "$endpoint")
case "$http_status" in 200) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" shotforge-account-export.json "$workdir/response_headers" <<'PY'
import json, os, sys
from pathlib import Path
source, target = Path(sys.argv[1]), Path(sys.argv[2])
json.loads(source.read_text())
with target.open('xb') as output:
    output.write(source.read_bytes())
target.chmod(0o600)
print(f'Saved private response to {target}')
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/api/auth/export';
$headers = ['Accept: application/json'];
$cookieFile = required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt');
if (file_exists($cookieFile) && (fileperms($cookieFile) & 0077)) {
    throw new RuntimeException('Cookie jar must have mode 600');
}
if (!is_file($cookieFile)) { throw new RuntimeException('Run session_login first'); }
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_COOKIEFILE => $cookieFile,
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [200], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
json_decode($content, true, 512, JSON_THROW_ON_ERROR);
$target = 'shotforge-account-export.json';
$output = fopen($target, 'xb');
if ($output === false) { throw new RuntimeException('Output already exists or cannot be created'); }
if (fwrite($output, $content) !== strlen($content)) {
    fclose($output); throw new RuntimeException('Incomplete output');
}
fclose($output);
chmod($target, 0600);
echo "Saved private response to " . $target . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/api/auth/export'
headers = {'Accept': 'application/json'}
cookie_file = Path(required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt'))
if cookie_file.exists() and cookie_file.stat().st_mode & 0o077:
    raise SystemExit('Cookie jar must have mode 600')
cookies = http.cookiejar.MozillaCookieJar(str(cookie_file))
if not cookie_file.is_file():
    raise SystemExit('Run session_login first')
cookies.load(ignore_discard=True, ignore_expires=False)
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False, cookies=cookies) as client:
    response = client.request('GET', base_url + path, headers=headers)
    if response.status_code not in (200,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    response.json()
    target = Path('shotforge-account-export.json')
    with target.open('xb') as output:
        output.write(response.content)
    target.chmod(0o600)
    print(f'Saved private response to {target}')

shotforge-created-key.json is private and contains the raw api_key returned once. Move the key to your secret manager, then remove the private file. Key-list responses return only metadata and the non-sensitive prefix.

POST /api/auth/delete-account

This request permanently deletes the account and its data after password verification and billing cleanup. Check the target account and export any data you need to keep before running it. Deletion cannot be undone.

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/api/auth/delete-account')
(workdir / 'body').write_text(json.dumps({'email': required('SHOTFORGE_ACCOUNT_EMAIL', None), 'password': required('SHOTFORGE_ACCOUNT_PASSWORD', None)}))
cookie_file = Path(required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt'))
if cookie_file.exists() and cookie_file.stat().st_mode & 0o077:
    raise SystemExit('Cookie jar must have mode 600')
if not cookie_file.is_file():
    raise SystemExit('Run session_login first')
(workdir / 'cookie_path').write_text(str(cookie_file))
PY
endpoint=$(<"$workdir/endpoint")
cookie_file=$(<"$workdir/cookie_path")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request POST \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  --cookie "$cookie_file" \
  --data-binary "@$workdir/body" \
  "$endpoint")
case "$http_status" in 204) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
printf 'HTTP %s\n' "$http_status"
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/api/auth/delete-account';
$headers = ['Accept: application/json', 'Content-Type: application/json'];
$cookieFile = required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt');
if (file_exists($cookieFile) && (fileperms($cookieFile) & 0077)) {
    throw new RuntimeException('Cookie jar must have mode 600');
}
if (!is_file($cookieFile)) { throw new RuntimeException('Run session_login first'); }
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_COOKIEFILE => $cookieFile,
    CURLOPT_POSTFIELDS => json_encode(['email' => required('SHOTFORGE_ACCOUNT_EMAIL', null), 'password' => required('SHOTFORGE_ACCOUNT_PASSWORD', null)], JSON_THROW_ON_ERROR),
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [204], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
echo "HTTP " . $status . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/api/auth/delete-account'
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
cookie_file = Path(required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt'))
if cookie_file.exists() and cookie_file.stat().st_mode & 0o077:
    raise SystemExit('Cookie jar must have mode 600')
cookies = http.cookiejar.MozillaCookieJar(str(cookie_file))
if not cookie_file.is_file():
    raise SystemExit('Run session_login first')
cookies.load(ignore_discard=True, ignore_expires=False)
payload = {'email': required('SHOTFORGE_ACCOUNT_EMAIL', None), 'password': required('SHOTFORGE_ACCOUNT_PASSWORD', None)}
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False, cookies=cookies) as client:
    response = client.request('POST', base_url + path, headers=headers, json=payload)
    if response.status_code not in (204,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    print(f'HTTP {response.status_code}')

Billing requires a browser session; mutations also require the exact ShotForge Origin. Checkout requires a complete tax profile and returns session_id and client_secret for embedded Stripe payment, not a hosted checkout URL. Keep this response private and finish payment in the billing interface. The compatibility portal points to /app/billing. Plan access is granted only after signed Stripe webhooks reconcile the authoritative subscription.

GET /api/billing/status

Return the stored billing plan, subscription status, and whether Stripe is available.

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/json'}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/api/billing/status')
cookie_file = Path(required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt'))
if cookie_file.exists() and cookie_file.stat().st_mode & 0o077:
    raise SystemExit('Cookie jar must have mode 600')
if not cookie_file.is_file():
    raise SystemExit('Run session_login first')
(workdir / 'cookie_path').write_text(str(cookie_file))
PY
endpoint=$(<"$workdir/endpoint")
cookie_file=$(<"$workdir/cookie_path")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request GET \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  --cookie "$cookie_file" \
  "$endpoint")
case "$http_status" in 200) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" <<'PY'
import json, sys
from pathlib import Path
print(json.dumps(json.loads(Path(sys.argv[1]).read_text()), indent=2))
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/api/billing/status';
$headers = ['Accept: application/json'];
$cookieFile = required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt');
if (file_exists($cookieFile) && (fileperms($cookieFile) & 0077)) {
    throw new RuntimeException('Cookie jar must have mode 600');
}
if (!is_file($cookieFile)) { throw new RuntimeException('Run session_login first'); }
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_COOKIEFILE => $cookieFile,
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [200], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
echo json_encode(json_decode($content, true, 512, JSON_THROW_ON_ERROR), JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR) . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/api/billing/status'
headers = {'Accept': 'application/json'}
cookie_file = Path(required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt'))
if cookie_file.exists() and cookie_file.stat().st_mode & 0o077:
    raise SystemExit('Cookie jar must have mode 600')
cookies = http.cookiejar.MozillaCookieJar(str(cookie_file))
if not cookie_file.is_file():
    raise SystemExit('Run session_login first')
cookies.load(ignore_discard=True, ignore_expires=False)
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False, cookies=cookies) as client:
    response = client.request('GET', base_url + path, headers=headers)
    if response.status_code not in (200,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    print(json.dumps(response.json(), indent=2))

POST /api/billing/checkout

Create an embedded payment session for starter, pro or business after tax validation. Returns session_id and client_secret; do not log the response. The request alone does not confirm payment.

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/json', 'Content-Type': 'application/json', 'Origin': 'https://shotforge.dev'}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/api/billing/checkout')
(workdir / 'body').write_text(json.dumps({'plan_name': 'pro', 'locale': 'fr'}))
cookie_file = Path(required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt'))
if cookie_file.exists() and cookie_file.stat().st_mode & 0o077:
    raise SystemExit('Cookie jar must have mode 600')
if not cookie_file.is_file():
    raise SystemExit('Run session_login first')
(workdir / 'cookie_path').write_text(str(cookie_file))
PY
endpoint=$(<"$workdir/endpoint")
cookie_file=$(<"$workdir/cookie_path")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request POST \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  --cookie "$cookie_file" \
  --data-binary "@$workdir/body" \
  "$endpoint")
case "$http_status" in 200) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" shotforge-checkout.json "$workdir/response_headers" <<'PY'
import json, os, sys
from pathlib import Path
source, target = Path(sys.argv[1]), Path(sys.argv[2])
json.loads(source.read_text())
with target.open('xb') as output:
    output.write(source.read_bytes())
target.chmod(0o600)
print(f'Saved private response to {target}')
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/api/billing/checkout';
$headers = ['Accept: application/json', 'Content-Type: application/json', 'Origin: https://shotforge.dev'];
$cookieFile = required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt');
if (file_exists($cookieFile) && (fileperms($cookieFile) & 0077)) {
    throw new RuntimeException('Cookie jar must have mode 600');
}
if (!is_file($cookieFile)) { throw new RuntimeException('Run session_login first'); }
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_COOKIEFILE => $cookieFile,
    CURLOPT_POSTFIELDS => json_encode(['plan_name' => 'pro', 'locale' => 'fr'], JSON_THROW_ON_ERROR),
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [200], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
json_decode($content, true, 512, JSON_THROW_ON_ERROR);
$target = 'shotforge-checkout.json';
$output = fopen($target, 'xb');
if ($output === false) { throw new RuntimeException('Output already exists or cannot be created'); }
if (fwrite($output, $content) !== strlen($content)) {
    fclose($output); throw new RuntimeException('Incomplete output');
}
fclose($output);
chmod($target, 0600);
echo "Saved private response to " . $target . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/api/billing/checkout'
headers = {'Accept': 'application/json', 'Content-Type': 'application/json', 'Origin': 'https://shotforge.dev'}
cookie_file = Path(required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt'))
if cookie_file.exists() and cookie_file.stat().st_mode & 0o077:
    raise SystemExit('Cookie jar must have mode 600')
cookies = http.cookiejar.MozillaCookieJar(str(cookie_file))
if not cookie_file.is_file():
    raise SystemExit('Run session_login first')
cookies.load(ignore_discard=True, ignore_expires=False)
payload = {'plan_name': 'pro', 'locale': 'fr'}
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False, cookies=cookies) as client:
    response = client.request('POST', base_url + path, headers=headers, json=payload)
    if response.status_code not in (200,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    response.json()
    target = Path('shotforge-checkout.json')
    with target.open('xb') as output:
        output.write(response.content)
    target.chmod(0o600)
    print(f'Saved private response to {target}')

POST /api/billing/portal

Local compatibility route: returns portal_url with /app/billing to open the ShotForge billing workspace.

cURL
#!/usr/bin/env bash
set -euo pipefail
set +x
umask 077
workdir=$(mktemp -d)
trap 'rm -rf "$workdir"' EXIT
python3 - "$workdir" <<'PY'
import json, os, sys
from pathlib import Path
from urllib.parse import quote, urlencode
def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value
workdir = Path(sys.argv[1])
headers = {'Accept': 'application/json', 'Origin': 'https://shotforge.dev'}
(workdir / "headers").write_text("".join(f"{key}: {value}\n" for key, value in headers.items()))
(workdir / 'endpoint').write_text('https://shotforge.dev' + '/api/billing/portal')
cookie_file = Path(required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt'))
if cookie_file.exists() and cookie_file.stat().st_mode & 0o077:
    raise SystemExit('Cookie jar must have mode 600')
if not cookie_file.is_file():
    raise SystemExit('Run session_login first')
(workdir / 'cookie_path').write_text(str(cookie_file))
PY
endpoint=$(<"$workdir/endpoint")
cookie_file=$(<"$workdir/cookie_path")
http_status=$(curl --silent --show-error --connect-timeout 10 --max-time 90 \
  --request POST \
  --header "@$workdir/headers" \
  --output "$workdir/response" --dump-header "$workdir/response_headers" --write-out '%{http_code}' \
  --cookie "$cookie_file" \
  "$endpoint")
case "$http_status" in 200) ;;
  *)
    python3 - "$http_status" "$workdir/response" <<'PY'
import json, re, sys
from pathlib import Path
def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'
raise SystemExit(f'HTTP {sys.argv[1]}: {error_code(Path(sys.argv[2]).read_bytes())}')
PY
    exit 1 ;;
esac
python3 - "$workdir/response" <<'PY'
import json, sys
from pathlib import Path
print(json.dumps(json.loads(Path(sys.argv[1]).read_text()), indent=2))
PY
PHP
<?php
declare(strict_types=1);
umask(0077);

function required(string $name, ?string $default = null): string {
    $value = getenv($name);
    if ($value === false) { $value = $default; }
    if ($value === null || ($default === null && trim($value) === '')) {
        throw new RuntimeException('Set ' . $name . ' in the environment');
    }
    return $value;
}

function headerValue(string $value): string {
    if (str_contains($value, "\r") || str_contains($value, "\n")) {
        throw new RuntimeException('Invalid header value');
    }
    return $value;
}

function errorCode(string $content): string {
    $body = json_decode($content, true);
    $detail = is_array($body) ? ($body['detail'] ?? null) : null;
    if (is_array($detail)) { return 'validation_error'; }
    if (is_string($detail) && preg_match('/^[a-zA-Z0-9_.-]{1,80}$/D', $detail)) {
        return $detail;
    }
    return 'request_failed';
}

$baseUrl = 'https://shotforge.dev';
$path = '/api/billing/portal';
$headers = ['Accept: application/json', 'Origin: https://shotforge.dev'];
$cookieFile = required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt');
if (file_exists($cookieFile) && (fileperms($cookieFile) & 0077)) {
    throw new RuntimeException('Cookie jar must have mode 600');
}
if (!is_file($cookieFile)) { throw new RuntimeException('Run session_login first'); }
$curl = curl_init($baseUrl . $path);
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_COOKIEFILE => $cookieFile,
]);
$content = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$mediaType = explode(';', (string) curl_getinfo($curl, CURLINFO_CONTENT_TYPE))[0];
if ($content === false) { curl_close($curl); throw new RuntimeException('Transport failed'); }
curl_close($curl);
$curl = null;
if (!in_array($status, [200], true)) {
    throw new RuntimeException('HTTP ' . $status . ': ' . errorCode($content));
}
echo json_encode(json_decode($content, true, 512, JSON_THROW_ON_ERROR), JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR) . "\n";
Python
import http.cookiejar
import json
import os
import re
from pathlib import Path
from urllib.parse import quote
import httpx

os.umask(0o077)

def required(name, default=None):
    value = os.environ.get(name, default)
    if value is None or (default is None and not value.strip()):
        raise SystemExit(f"Set {name} in the environment")
    return value

def header_value(value):
    if "\r" in value or "\n" in value:
        raise SystemExit("Invalid header value")
    return value

def error_code(content):
    try:
        detail = json.loads(content).get('detail')
    except (ValueError, AttributeError):
        return 'request_failed'
    if isinstance(detail, list):
        return 'validation_error'
    if isinstance(detail, str) and re.fullmatch(r'[a-zA-Z0-9_.-]{1,80}', detail):
        return detail
    return 'request_failed'

base_url = 'https://shotforge.dev'
path = '/api/billing/portal'
headers = {'Accept': 'application/json', 'Origin': 'https://shotforge.dev'}
cookie_file = Path(required('SHOTFORGE_COOKIE_FILE', './shotforge-cookies.txt'))
if cookie_file.exists() and cookie_file.stat().st_mode & 0o077:
    raise SystemExit('Cookie jar must have mode 600')
cookies = http.cookiejar.MozillaCookieJar(str(cookie_file))
if not cookie_file.is_file():
    raise SystemExit('Run session_login first')
cookies.load(ignore_discard=True, ignore_expires=False)
with httpx.Client(timeout=httpx.Timeout(90.0, connect=10.0), follow_redirects=False, cookies=cookies) as client:
    response = client.request('POST', base_url + path, headers=headers)
    if response.status_code not in (200,):
        raise SystemExit(f'HTTP {response.status_code}: {error_code(response.content)}')
    print(json.dumps(response.json(), indent=2))

Responses and errors

JSON failures use a stable detail code. Validation failures may return FastAPI’s structured detail array. Never parse human-facing text.

{"detail":"session_required"}
HTTPdetailDescription
400quota_exceededMonthly quota is exhausted. Wait for the UTC monthly reset or upgrade.
400width_exceeds_planRequested width exceeds the active plan maximum.
400unknown_og_templateThe named Open Graph template does not exist.
400url_must_be_http / invalid_dimensions / text_too_longAn anonymous demo field is invalid: URL scheme, dimensions, or text length.
400too_many_api_keysThe account has reached its API-key limit. Revoke an unused key before creating another.
401not_authenticated / session_required / invalid_api_key / invalid_token / token_revoked / invalid_credentialsCredential missing, invalid, expired, revoked, or inactive.
401invalid_refresh_token / refresh_token_expired / token_reuse_detectedRefresh token is invalid, expired, revoked, or reused. Authenticate again after reuse detection.
403invalid_password / free_og_template_not_availablePassword verification failed, or the requested anonymous Open Graph template requires authentication.
403pro_template_requiredThis Open Graph template requires Pro, Business or an active Pro trial. Free and Starter include the 41 base templates.
403origin_mismatchBrowser-session APIs reject third-party Origins. Billing mutations require the exact ShotForge Origin header, including server-to-server clients; do not omit it.
403full_page_not_in_planScrolling full-page capture is unavailable on the active plan.
403auth_render_not_in_planAuthenticated target-page rendering is unavailable on the active plan.
403pdf_not_in_plan / og_not_in_planThe requested output type is unavailable on the active plan.
404not_foundThe requested account resource does not exist or is not owned by this account.
404no_billing_account / billing_object_mismatch / no_active_subscriptionThe billing account or requested provider object is missing or does not belong to this account (404).
409email_already_registeredAn account already exists for this email address.
409billing_checkout_pending / billing_cleanup_staleBilling cleanup or checkout is still pending (409). Wait for completion and check the account's billing state before submitting again.
422url_not_allowed / navigation_failed / render_timeout / page_too_large / authentication_failed / render_failedSafe rendering failure: forbidden destination, navigation failure, timeout, oversized page, rejected target credentials, or browser failure.
422structured validation detail arrayA request field is missing, outside its range, or has an unsupported value.
422invalid_plan / billing_cancellation_invalid / billing_invoice_invalid / billing_invoice_cursor_invalid / billing_setup_invalid / billing_preview_invalidThe requested plan or billing payload is invalid (422). Correct the fields identified by the error code before submitting again.
423account_lockedThe account is temporarily locked after repeated failed logins.
429rate_limit_exceededRate limit exceeded. Wait for the Retry-After duration before retrying.
500internal_errorUnexpected server error. Retry with backoff; contact support if it persists.
502billing_unavailable / billing_tax_provider_unavailableThe billing provider could not complete the operation (502). Check the current billing state before considering another attempt.
503stripe_not_configured / plan_not_synced_to_stripe / billing_tax_configuration_requiredBilling configuration or Stripe availability prevents the operation (503). Contact support if the service remains unavailable.
502 / 503billing_cleanup_failed / billing_cleanup_unavailableThe external billing provider could not complete the requested cleanup. Retry later or contact support.

Production integration checklist

  • Use --fail-with-body or equivalent: an error body saved as .png is still JSON.
  • Retry 429, network failures, and transient 5xx responses with bounded exponential backoff; do not blindly retry 4xx validation or plan errors.
  • Set a client timeout above the server render window (at least 45 seconds; longer for full-page captures).
  • Keep API keys and target-site credentials server-side. Never embed them in browser JavaScript, mobile binaries, logs, URLs, shell history, or process arguments.
  • Stream binary responses directly to storage or the client instead of converting large files to JSON/base64.
  • A retry creates a new render and can consume quota after a successful response was lost. Retry only when the original outcome is unknown and necessary.
Screenshot preview