Screenshot API error ยท HTTP 422
Action failed
action_failed
actions, or the scripts, could not do what it says. The message names the step by its index and type (actions.2 (click)) and why it failed, and the X-Actions-Completed header says how many steps completed, for example 2/5.How to recognize it
The API answers with status 422 and a JSON body with the message and the error.code action_failed, for example:
HTTP/1.1 422
Content-Type: application/json
{
"error": {
"code": "action_failed",
"message": "The step actions.2 (click) failed: its element was not found, shown or ready within its timeout_ms. Mark it optional to go on without it."
},
"message": "The step actions.2 (click) failed: its element was not found, shown or ready within its timeout_ms. Mark it optional to go on without it."
}Common causes
- The step’s element was not found, not visible or not ready within its
timeout_ms(5 seconds by default): a changed selector, an element that appears later, or one behind a dialog. - A
wait_for_selectorstep whose selector did not match in time, or await_for_navigationstep for which no navigation came. - A
selectstep whose element is no<select>, or none of whose options has one of its values. - An
evaluatestep or thescriptsthrew an error or did not finish in time (The scripts threw an error.). - A
click_acceptstep that found no accept button of a cookie consent dialog.
How to fix it
- Mark a step that does not always apply as
"optional": true: it is skipped instead of failing the render. - Raise the step’s
timeout_ms, or put await_for_selectorstep before it. - Find the first step that fails:
X-Actions-Completedcounts the steps before it. Check its selector in the browser’s console on the same page. - Run the code of an
evaluatestep or ofscriptsin the browser’s console on the same page.
Billing
The first 25 failure conditions a day are free for each account (action_failed, selector_not_found, content_condition_failed and request_failed together, per UTC day); after that, each counts as one request, like a render. Once an evaluate step or the scripts ran in the page, any failure that is not ours is billed 1, without the free allowance, because that code could read the page. A 500 is ours and never billed. The steps themselves cost nothing extra.
Related parameters
actions, scripts, scripts_wait_until. Each is described in the take endpoint reference.
Every response carries an X-Request-Id header. If this page does not explain the error, write to support@screenshotbase.com with that id. All statuses: status codes.
Other API errors
Screenshot API
Take screenshots from your code
screenshotbase renders any website in a real browser and returns the image: full page or viewport, any device size, retina, from 100+ countries, with cookie banners and ads hidden.
/v1/take documentation Screenshot API All documentation
300 free screenshots every month. No credit card required.
GET https://api.screenshotbase.com/v1/take?url=https://example.com&full_page=true
# Response: the image (PNG, JPG, WebP, AVIF or GIF)
curl -G "https://api.screenshotbase.com/v1/take" \
--data-urlencode "url=https://example.com" \
-d viewport_width=1280 -d viewport_height=800 \
-d format=png \
-H "apikey: YOUR-API-KEY" \
-o screenshot.png