
The other three task types in this series all make you wait. You create a task, you get a taskId, and you poll until somebody else finishes the work. AWS WAF does not work that way. The call that creates the task is also the call that returns the token.
This walkthrough uses Kaptra's captcha API and the AntiAwsWafTask type. It covers the one required field, the optional triple you should not split, and what to do with a token that comes back on the same response.
One call, not two
Kaptra's own introduction names this type as the current exception. AntiAwsWafTask returns status=ready from /createTask. Every other type returns status=processing and a taskId, and you poll /getTaskResult every 1 to 2 seconds, at most 120 times.
So the client you copied from the Turnstile or reCAPTCHA v2 article will not port. There is no second request, and there is no taskId worth saving. If errorId is 0 and status is ready, read solution and move on.
HTTP status stays 200 either way. The result lives in errorId (0 or 1) and errorCode.
What the page needs from you
Required:
-
websiteURL: the public URL of the page that served the AWS WAF challenge.
Optional, and the minimal request sends none of these:
-
referrer. It defaults fromwebsiteURL. Set it only when the challenge was issued by a different page than the one you are requesting. -
awsKey,awsIv, andawsContext. These three travel together. Send all of them, or send none. One or two is a malformed request.
There is no proxy field. The Cloudflare challenge task needs your proxy because its cookies are issued for one IP. This task returns a token, so that binding does not apply.
What you attach on the retry
A successful response has solution.token, a string shaped like aws-waf-token=.... Split on the first =, and set a cookie named aws-waf-token to the value on the right. Then retry the same page.
The documented solution has no expiresInMs and no userAgent. Use the token on that retry. Do not print it and come back later.
Full Python example
import requests BASE_URL = "https://api.kaptra.ai" API_KEY = "YOUR_KAPTRA_API_KEY" def solve_aws_waf(website_url: str) -> dict: # synchronous: createTask returns the result, no polling resp = requests.post( f"{BASE_URL}/createTask", json={ "clientKey": API_KEY, "task": { "type": "AntiAwsWafTask", "websiteURL": website_url, }, }, ).json() if resp.get("errorId"): raise RuntimeError(f"createTask failed: {resp.get('errorCode')}") if resp.get("status") != "ready": raise RuntimeError(f"unexpected status: {resp.get('status')}") return resp["solution"] # {"token": "aws-waf-token=..."} if __name__ == "__main__": page = "https://www.example.com/page" solution = solve_aws_waf(page) token = solution["token"] print(token) # retry the page with the token as a cookie value = token.split("=", 1)[1] session = requests.Session() session.cookies.set("aws-waf-token", value) page_resp = session.get(page) print(page_resp.status_code) If status comes back as anything other than ready, stop. Do not invent a poll loop for a type the docs say is synchronous.
The other AWS WAF task is a grid
AwsWafClassification is a different type, for the visual grid where the page asks you to pick the tiles that show a target. That one is asynchronous. You send nine base64 tiles and a question such as aws:grid:bag, you poll getTaskResult, and the solution is objects: tile indices from 0 to 8, top-left first.
Supported targets on that type are bag, bed, bucket, chair, clock, curtain, and hat. A target outside that list fails with ERROR_CAPTCHA_UNSOLVABLE and is not billed. If your page is a 3 by 3 image grid, you are on the wrong guide.
Before you wire it into the suite
Start with the minimal body. websiteURL alone is the documented minimal request. Add awsKey, awsIv, and awsContext only when you already have all three. A partial set is how you get ERROR_BAD_REQUEST.
A failure is a reason to look, not to hammer retry. Average time on the pricing page is under 3 seconds. ERROR_CAPTCHA_UNSOLVABLE means the solve failed. The error dictionary says not to charge-retry blindly: check the page and the fields, then create a new task. Failed and timed-out tasks are not billed.
Price. $0.60 per 1,000 successful solves, the same rate as the grid type. No monthly fee, and top-up credit does not expire. A new account includes $10 in test credit, which is 16,666 solves at this rate.
Other codes. ERROR_TASK_NOT_SUPPORTED means the type string is wrong or the type is disabled. ERROR_ZERO_BALANCE means stop and top up. None of these change the HTTP status. It stays 200.
Where this sits next to the other three
Turnstile and reCAPTCHA v2 are widgets: a site key goes in, a token comes out, and you poll. The Cloudflare challenge page is a wall: your HTTP proxy goes in, cookies come out, and you poll. AWS WAF is the short one. A page URL goes in, aws-waf-token comes out, and the function returns.
- Site: kaptra.ai
- AntiAwsWafTask docs: kaptra.ai/docs
- The polling widget this does not copy: How to solve Cloudflare Turnstile in Python
- The proxy-and-cookies case: How to solve the Cloudflare 5-second challenge in Python
- The other token that expires: How to solve reCAPTCHA v2 in Python