October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

LambdaTest Screenshot API Authentication and API Key Setup

A practical guide to finding LambdaTest credentials, setting LT_USERNAME and LT_ACCESS_KEY, building a Basic-auth header, and sending the Screenshot API request.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To authenticate with the LambdaTest Automated Screenshot API, retrieve your account username and access key from the automation dashboard, then send them using HTTP Basic authentication in a JSON POST request to https://api.lambdatest.com/screenshots/v1/. The API uses the access key as the Basic-auth password. A successful start request returns a test_id for identifying the screenshot test.

Get your LambdaTest username and access key

  1. Sign in to the LambdaTest automation dashboard.
  2. Find the key control near the help button and retrieve your username and access key. The setup guide also identifies the HubURL among the authentication credentials; the screenshot-start request described here is sent to the endpoint shown below.
  3. Keep the access key private. Do not place real credentials in code examples, public repositories, or shared logs.

LambdaTest documents the environment variable names LT_USERNAME and LT_ACCESS_KEY for command-line configuration. The setup guide includes shell commands for Linux/macOS and Windows: Automated Screenshot API setup guide.

Set credentials on Linux or macOS

export LT_USERNAME="your_username"
export LT_ACCESS_KEY="your_access_key"

Set credentials on Windows Command Prompt

set LT_USERNAME=your_username
set LT_ACCESS_KEY=your_access_key

For production applications, load secrets from the environment or a suitable secret store rather than committing them to source control.

Send an authenticated screenshot request

The start-test operation accepts a JSON POST at https://api.lambdatest.com/screenshots/v1/. Its Authorization header uses the scheme Basic followed by the base64 encoding of username:password; for this account-credential workflow, use the LambdaTest username and access key as the username and password values. The request body is JSON and can carry the URL, browser and operating-system configurations, resolutions, and other test options. See the Start Screenshot Test API reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

cURL example

This example reads credentials from environment variables and constructs the Basic header without embedding a real key in the command. It requires a shell with base64.

AUTH="$(printf '%s' "$LT_USERNAME:$LT_ACCESS_KEY" | base64 | tr -d 'n')"
curl --request POST 
  --url 'https://api.lambdatest.com/screenshots/v1/' 
  --header "Authorization: Basic $AUTH" 
  --header 'Content-Type: application/json' 
  --data '{"url":"https://example.com","defer_time":0,"email":true,"configs":{}}'

On Windows PowerShell, set the variables in that session and form the header value with .NET:

$pair = "$env:LT_USERNAME`:$env:LT_ACCESS_KEY"
$encoded = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($pair))
$headers = @{ Authorization = "Basic $encoded" }
$body = '{"url":"https://example.com","defer_time":0,"email":true,"configs":{}}'
Invoke-RestMethod -Method Post `
  -Uri 'https://api.lambdatest.com/screenshots/v1/' `
  -Headers $headers `
  -ContentType 'application/json' `
  -Body $body

Python example

Install the HTTP client with python -m pip install requests, then run:

import os
import requests

username = os.environ["LT_USERNAME"]
access_key = os.environ["LT_ACCESS_KEY"]
response = requests.post(
    "https://api.lambdatest.com/screenshots/v1/",
    auth=(username, access_key),
    headers={"Content-Type": "application/json"},
    json={
        "url": "https://example.com",
        "defer_time": 0,
        "email": True,
        "configs": {},
    },
    timeout=90,
)
response.raise_for_status()
print(response.json())

With Requests, the auth=(username, access_key) argument generates HTTP Basic authentication. A successful start operation returns a test_id; retain it for subsequent retrieval or handling of that test.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Node.js example

This example uses the built-in fetch available in current Node.js releases. It creates the Basic header from environment variables and submits JSON.

const username = process.env.LT_USERNAME;
const accessKey = process.env.LT_ACCESS_KEY;
if (!username || !accessKey) {
  throw new Error('Set LT_USERNAME and LT_ACCESS_KEY first');
}

const authorization = Buffer.from(`${username}:${accessKey}`).toString('base64');
const response = await fetch('https://api.lambdatest.com/screenshots/v1/', {
  method: 'POST',
  headers: {
    Authorization: `Basic ${authorization}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    url: 'https://example.com',
    defer_time: 0,
    email: true,
    configs: {},
  }),
});

const result = await response.json();
if (!response.ok) {
  throw new Error(`HTTP ${response.status}: ${JSON.stringify(result)}`);
}
console.log(result);

Understand the response and errors

The start operation’s successful response includes a test_id. The API reference displays response examples for HTTP 200, 400, 401, and 403. It does not establish a definitive cause for each authorization error, so treat the status as a signal to inspect the request rather than proof of one specific credential problem.

  • 200: The start operation succeeded; capture the returned test_id.
  • 400: Check that the request body is valid JSON and includes the expected fields and supported values.
  • 401 or 403: Recheck that the username and access key belong to the intended account, that the header uses Basic authentication, and that the request is sent to the documented endpoint.

Troubleshoot authentication and setup

401 or 403 response

  • Confirm that LT_USERNAME and LT_ACCESS_KEY are set in the same shell or process that runs the request.
  • Check for accidental spaces, line breaks, or a copied placeholder in either value.
  • Ensure the header is exactly the Basic scheme plus a base64-encoded username:access_key pair—not the raw pair and not a bearer token.
  • Verify the endpoint and the Content-Type: application/json header.

Malformed or rejected request

  • Send a JSON object in the request body, not form-encoded fields.
  • Check quoting and escaping in shell commands; malformed JSON can produce a 400 response.
  • Use the start-test API reference to confirm the request fields and accepted configuration structure for the test you intend to run.

Environment variable appears empty

Environment variables are scoped to the shell or process where they are set. Set them again in the terminal that launches the script, or configure them in the runtime’s environment settings. Avoid printing the access key while debugging; check whether the variable exists without exposing its value.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your goal is simply to request a website screenshot, ScreenshotNeo offers a one-request alternative. Its API uses a GET request and accepts an access key and target URL. See the ScreenshotNeo API documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are never billed. It also provides an MCP server for AI agents, and its free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo’s free plan.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.