Skip to main content

Custom Cookies

Set custom cookies to capture screenshots of authenticated pages or specific user states.

Basic usage

bash
curl "https://api.domshot.com/shot?key=YOUR_API_KEY&url=https://example.com&customCookies=%5B%7B%22name%22%3A%22session%22%2C%22value%22%3A%22abc123%22%2C%22domain%22%3A%22example.com%22%7D%5D" \
  --output screenshot.png
const cookies = [
  {
    name: 'session',
    value: 'abc123',
    domain: 'example.com'
  }
];

const params = new URLSearchParams({
  key: 'YOUR_API_KEY',
  url: 'https://example.com',
  customCookies: JSON.stringify(cookies)
});

await fetch(`https://api.domshot.com/shot?${params}`)
  .then(res => res.blob())
  .then(blob => fs.writeFile('screenshot.png', blob));
$cookies = [
  [
    'name' => 'session',
    'value' => 'abc123',
    'domain' => 'example.com'
  ]
];

$params = [
  'key' => 'YOUR_API_KEY',
  'url' => 'https://example.com',
  'customCookies' => json_encode($cookies)
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.domshot.com/shot?' . http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$result = curl_exec($ch);
file_put_contents('screenshot.png', $result);
curl_close($ch);
package main

import (
    "encoding/json"
    "net/http"
    "net/url"
)

type Cookie struct {
    Name   string `json:"name"`
    Value  string `json:"value"`
    Domain string `json:"domain"`
}

func main() {
    cookies := []Cookie{
        {Name: "session", Value: "abc123", Domain: "example.com"},
    }

    params := url.Values{}
    params.Set("key", "YOUR_API_KEY")
    params.Set("url", "https://example.com")

    cookiesJSON, _ := json.Marshal(cookies)
    params.Set("customCookies", string(cookiesJSON))

    resp, _ := http.Get("https://api.domshot.com/shot?" + params.Encode())
    defer resp.Body.Close()

    // Save response to file
}
[
  {
    "name": "session",
    "value": "abc123",
    "domain": "example.com",
    "path": "/",
    "httpOnly": false,
    "secure": true,
    "sameSite": "Lax"
  }
]

Required fields

FieldTypeDescription
namestringCookie name
valuestringCookie value
domainstringCookie domain

Optional fields

FieldTypeDescription
pathstringCookie path (default: /)
httpOnlybooleanHTTP-only flag (default: false)
securebooleanSecure flag (default: false)
sameSitestringSameSite policy: Strict, Lax, or None

Multiple cookies

bash
curl "https://api.domshot.com/shot?key=YOUR_API_KEY&url=https://example.com&customCookies=%5B%7B%22name%22%3A%22session%22%2C%22value%22%3A%22abc123%22%7D%2C%7B%22name%22%3A%22theme%22%2C%22value%22%3A%22dark%22%7D%5D" \
  --output screenshot.png
const cookies = [
  {
    name: 'session',
    value: 'abc123',
    domain: 'example.com'
  },
  {
    name: 'theme',
    value: 'dark',
    domain: 'example.com'
  }
];

const params = new URLSearchParams({
  key: 'YOUR_API_KEY',
  url: 'https://example.com',
  customCookies: JSON.stringify(cookies)
});

await fetch(`https://api.domshot.com/shot?${params}`)
  .then(res => res.blob())
  .then(blob => fs.writeFile('screenshot.png', blob));
$cookies = [
  ['name' => 'session', 'value' => 'abc123', 'domain' => 'example.com'],
  ['name' => 'theme', 'value' => 'dark', 'domain' => 'example.com']
];

$params = [
  'key' => 'YOUR_API_KEY',
  'url' => 'https://example.com',
  'customCookies' => json_encode($cookies)
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.domshot.com/shot?' . http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$result = curl_exec($ch);
file_put_contents('screenshot.png', $result);
curl_close($ch);
package main

import (
    "encoding/json"
    "net/http"
    "net/url"
)

type Cookie struct {
    Name   string `json:"name"`
    Value  string `json:"value"`
    Domain string `json:"domain"`
}

func main() {
    cookies := []Cookie{
        {Name: "session", Value: "abc123", Domain: "example.com"},
        {Name: "theme", Value: "dark", Domain: "example.com"},
    }

    params := url.Values{}
    params.Set("key", "YOUR_API_KEY")
    params.Set("url", "https://example.com")

    cookiesJSON, _ := json.Marshal(cookies)
    params.Set("customCookies", string(cookiesJSON))

    resp, _ := http.Get("https://api.domshot.com/shot?" + params.Encode())
    defer resp.Body.Close()

    // Save response to file
}
Never expose sensitive authentication data in URLs that might be logged. Consider using environment variables for sensitive data.

Parameters

ParameterTypeDescription
customCookiesstringJSON array of cookie objects

See also