Skip to content
Guide

Akamai Bot Manager and the _abck Cookie: How to Get Past "Access Denied" in Python and Node.js

NSLSolver TeamPublished 8 min read

Akamai Bot Manager protects many retail, airline, banking and ticketing sites. It runs a JavaScript sensor in the browser, sends what it collects back to Akamai, and keeps the verdict in a cookie called _abck. Requests that arrive without a valid _abck (or with one earned from a different client) are answered by the Akamai edge with 403 Access Denied, a 428 or a silent failure on the API call you actually wanted.

A plain HTTP client never runs that sensor, which is why python requests, Node fetch and curl get blocked on Akamai sites that work fine in Chrome. This guide shows how to recognise Akamai, which cookies matter, how to get valid ones from the NSLSolver API and how to replay and refresh them in Python and Node.js.

Short version: send the page URL, the exact user agent you will use and a sticky proxy to the API, replay every returned cookie with that same user agent through that same proxy, and solve again when the Akamai edge answers 403 Access Denied. The NSLSolver Akamai API (beta) returns validated _abck and session cookies in one call, for $2.00 per 1,000 successful solves.

Related reading: for the other big sensor-based protection, see the Kasada x-kpsdk headers guide. The cookie-reuse pattern below is the same one we describe for Cloudflare in the cf_clearance cookie explained.

How do you know a site uses Akamai Bot Manager?

Akamai rarely announces itself on the page, but a few signals are reliable. Check them in your browser DevTools (Application and Network tabs) before you write any code:

  • Cookies named _abck and bm_sz are set on the site domain, often together with ak_bmsc and bm_sv. _abck is the one Bot Manager checks.
  • A blocked request returns a short "Access Denied" page that says you do not have permission to access the resource and ends with a "Reference #" id. The response Server header is usually AkamaiGHost.
  • The page loads a first-party script from an unusual, random-looking path on the same domain, and the browser POSTs data back to that same path shortly after the page loads. That is the sensor.
  • The HTML works in a browser, but the JSON endpoint behind it (search, prices, login, add to cart) fails from your script even with the same headers.

What do the _abck and bm_sz cookies do?

Akamai documents these cookies as part of Bot Manager, but not their internal format. What matters in practice:

CookieRoleWhat it means for your code
_abckHolds the Bot Manager verdict for this client; updated after each sensor submissionThe cookie that gates protected endpoints. It must be in a validated state and sent on every request
bm_szSession cookie set on the first visit and used alongside _abckSend it together with _abck; a mismatched pair is treated as a new, untrusted client
ak_bmscBot Manager session cookie set by the edgeSend it back if the site sets it; it does not replace _abck
bm_svSet later in the session on some sitesKeep whatever the site sets; a cookie jar handles this for you

Treat every value as opaque. These cookies are not tokens you can decode, edit or generate by hand, and their exact behaviour varies by site configuration.

Why do python requests and curl get 403 on Akamai?

Bot Manager scores more than the cookie. A request is typically judged on:

  • Whether a valid _abck is present, which requires the sensor to have run and been accepted.
  • Whether the client identity matches the one that earned the cookie: same exit IP, same User-Agent, consistent headers.
  • The TLS and HTTP/2 fingerprint of the client. Default Python, Node and Go clients look nothing like Chrome.
  • The reputation of the IP address. Datacenter ranges are scored more harshly than residential or mobile ones.
  • Behaviour over time: request rate, endpoint order, and requests that skip the pages a real visitor would load first.

How do you get a valid _abck cookie programmatically?

You need a client that runs the sensor and gets it accepted, then you hand the resulting cookies to your HTTP client. NSLSolver does that step: POST the URL of a page that loads the Akamai script, the user agent you will replay with, and your proxy to /solve with type "akamai". You get back the cookies (_abck, bm_sz and any others the site set). Akamai support is in beta: the average solve takes about 15 seconds, it costs $2.00 per 1,000 successful solves, and failed solves are not billed.

All three fields are required. The proxy matters because the cookies are earned from its exit IP, and the user agent matters because Akamai checks it on every later request. Use a sticky (session) proxy so the IP does not change between the solve and your requests.

Use this on your own sites, on staging and QA environments, and on sites whose terms allow automated access.

get-akamai-cookies.sh
# 1) Ask NSLSolver for Akamai cookies minted through YOUR proxy and user agent
curl -s https://api.nslsolver.com/solve \
  -H "X-API-Key: nsl_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "akamai",
    "url": "https://protected-site.example.com/login",
    "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36",
    "proxy": "http://user:pass@sticky-proxy.example.com:8080"
  }'

# Response (200 OK)
# {
#   "success": true,
#   "type": "akamai",
#   "cookies": { "_abck": "7A12...", "bm_sz": "D41F..." },
#   "cost": 0.002
# }

# 2) Replay ALL returned cookies with the SAME proxy and the SAME user agent
curl -s https://protected-site.example.com/api/products \
  -x "http://user:pass@sticky-proxy.example.com:8080" \
  -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36" \
  -b "_abck=7A12...; bm_sz=D41F..."

Replay Akamai cookies in Python (curl_cffi)

One proxy IP, one solve, many requests. The session below sets the user agent once, loads every returned cookie into the cookie jar, and solves again only when the Akamai edge blocks a request. curl_cffi reproduces a Chrome TLS and HTTP/2 fingerprint; keep the user agent on the same Chrome version as the impersonation target so the two do not contradict each other.

Note the two URLs: solve on a page that loads the Akamai script (often the home or login page), then call the endpoint you need. Letting the cookie jar keep any cookies the site updates during the session is better than resending a frozen copy.

akamai_session.py
# akamai_session.py  (pip install curl_cffi)
# Solve once per proxy IP, replay the cookies, re-solve only when Akamai blocks.
import threading
from curl_cffi import requests

API_KEY = "nsl_YOUR_API_KEY"
PROXY = "http://user:pass@sticky-proxy.example.com:8080"  # sticky exit IP
# Must be the exact UA you send afterwards; keep it on the same Chrome
# version as the curl_cffi impersonation target.
USER_AGENT = (
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
    "(KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36"
)


def is_akamai_block(resp) -> bool:
    """True when the Akamai edge denied the request instead of serving it."""
    if resp.status_code not in (403, 428, 429):
        return False
    server = resp.headers.get("server", "")
    body = resp.text[:3000]
    return "AkamaiGHost" in server or ("Access Denied" in body and "Reference #" in body)


class AkamaiSession:
    def __init__(self, proxy: str, user_agent: str):
        self.proxy = proxy
        self.generation = 0
        self.lock = threading.Lock()
        self.s = requests.Session(impersonate="chrome")
        self.s.proxies = {"http": proxy, "https": proxy}
        self.s.headers["User-Agent"] = user_agent
        self.user_agent = user_agent

    def solve(self, url: str) -> None:
        r = requests.post(
            "https://api.nslsolver.com/solve",
            headers={"X-API-Key": API_KEY},
            json={"type": "akamai", "url": url, "user_agent": self.user_agent, "proxy": self.proxy},
            timeout=120,
        )
        data = r.json()
        if r.status_code != 200 or not data.get("success"):
            raise RuntimeError(f"solve failed: {r.status_code} {data}")
        for name, value in data["cookies"].items():  # _abck, bm_sz, ...
            self.s.cookies.set(name, value)
        self.generation += 1

    def get(self, url: str, solve_url: str):
        seen = self.generation
        resp = self.s.get(url, timeout=30)
        if is_akamai_block(resp):
            with self.lock:  # one solve per proxy IP, not one per thread
                if self.generation == seen:
                    self.solve(solve_url)
            resp = self.s.get(url, timeout=30)
        return resp


ak = AkamaiSession(PROXY, USER_AGENT)
for page in range(1, 21):
    r = ak.get(
        f"https://protected-site.example.com/api/products?page={page}",
        solve_url="https://protected-site.example.com/login",  # page that loads the Akamai script
    )
    print(page, r.status_code)

Replay Akamai cookies in Node.js

The same flow in Node.js uses undici's ProxyAgent so the solve and every request leave through the same IP. Node's TLS fingerprint is not a browser's, so if valid cookies are still rejected with the right IP and user agent, move those calls to a browser-impersonating client.

akamai-session.mjs
// akamai-session.mjs  (Node 18+, npm i undici)
import { fetch, ProxyAgent } from "undici";

const API_KEY = "nsl_YOUR_API_KEY";
const PROXY = "http://user:pass@sticky-proxy.example.com:8080";
const USER_AGENT =
  "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36";
const dispatcher = new ProxyAgent(PROXY); // same exit IP for the solve and every request

let cookieHeader = "";

async function solve(url) {
  const res = await fetch("https://api.nslsolver.com/solve", {
    method: "POST",
    headers: { "X-API-Key": API_KEY, "Content-Type": "application/json" },
    body: JSON.stringify({ type: "akamai", url, user_agent: USER_AGENT, proxy: PROXY }),
  });
  const data = await res.json();
  if (!res.ok || !data.success) {
    throw new Error("solve failed: " + res.status + " " + JSON.stringify(data));
  }
  cookieHeader = Object.entries(data.cookies).map(([k, v]) => k + "=" + v).join("; ");
}

function isAkamaiBlock(res, body) {
  if (![403, 428, 429].includes(res.status)) return false;
  return (res.headers.get("server") || "").includes("AkamaiGHost") ||
    (body.includes("Access Denied") && body.includes("Reference #"));
}

async function fetchOnce(url) {
  const headers = { "User-Agent": USER_AGENT, ...(cookieHeader ? { Cookie: cookieHeader } : {}) };
  const res = await fetch(url, { dispatcher, headers });
  return { res, body: await res.text() };
}

export async function get(url, solveUrl) {
  let { res, body } = await fetchOnce(url);
  if (isAkamaiBlock(res, body)) {
    await solve(solveUrl);
    ({ res, body } = await fetchOnce(url));
  }
  return { status: res.status, body };
}

const { status } = await get(
  "https://protected-site.example.com/api/products",
  "https://protected-site.example.com/login",
);
console.log(status);

Full API reference

When do Akamai cookies stop working?

Akamai does not publish a fixed lifetime, and it varies by site. Plan for re-solving rather than predicting expiry:

  • Detect the block on each response: a 403 (sometimes 428 or 429) with Server: AkamaiGHost or an "Access Denied ... Reference #" body.
  • On a block, solve once and retry once. If the retry is blocked too, stop and check the proxy, user agent and client fingerprint instead of looping.
  • Keep one cookie set per proxy IP and share it across workers behind a lock, so ten threads hitting a block trigger one solve.
  • A change of exit IP or user agent invalidates the session in practice. Rotate both together and solve again for the new identity.
  • Very high request rates on one cookie set get flagged even when the cookie is valid. Spread load across several proxy identities.

Troubleshooting Akamai blocks

SymptomLikely causeFix
403 Access Denied right after a successful solveRequest sent through a different IP, or without the proxySend every request through the proxy you passed to /solve
Blocked although _abck is setUser-Agent differs from the one sent to /solve, or bm_sz was not sentReuse the exact user_agent and send every returned cookie
Works in curl_cffi, fails in requests or NodeTLS / HTTP/2 fingerprint does not look like a browserUse curl_cffi with a Chrome target matching the user agent
Works for a while, then 403 againThe site refreshed or invalidated the sessionDetect the block and solve again
Random 403s on a rotating proxyExit IP changes between requestsUse a sticky session, one cookie set per IP
HTML loads but the JSON API failsThe API endpoint is protected more strictly than the pageSolve on the page that loads the script, then call the API with the same session
/solve returns 400Missing or invalid url, user_agent or proxyAll three are required for akamai; check the protocol://user:pass@host:port proxy format
/solve returns 503The solver could not complete this requestRetry; 503 responses are not billed. Akamai support is in beta

Only successful solves are billed, so retrying a failed solve does not cost extra.

Frequently asked questions

What is the Akamai _abck cookie?

_abck is the cookie Akamai Bot Manager uses to store its verdict on a client. It is updated after the Akamai sensor script reports back, and protected endpoints only let requests through when a valid _abck is sent with the same client identity that earned it.

How do I know if a site uses Akamai Bot Manager?

Look for _abck and bm_sz cookies on the site, a blocked response that says "Access Denied" with a "Reference #" id and a Server header of AkamaiGHost, and a first-party script on a random-looking path that the page POSTs data back to.

Can I reuse an _abck cookie on another IP or user agent?

Not reliably. In practice the cookies only keep working with the same exit IP, the same user agent and a consistent client fingerprint. Use a sticky proxy and send the exact user agent you passed when the cookies were generated.

Why does python requests get 403 on an Akamai site?

requests does not run JavaScript, so the Akamai sensor never runs and no valid _abck is earned. Its TLS fingerprint also differs from a browser. Get valid cookies first, then replay them through a browser-impersonating client such as curl_cffi with the same proxy and user agent.

How long do Akamai cookies last?

Akamai does not publish a fixed lifetime and it varies by site. Detect blocks (403 with AkamaiGHost or "Access Denied") and solve again when you see one, rather than trying to predict expiry.

How much does the NSLSolver Akamai API cost?

$2.00 per 1,000 successful solves, with an average solve time of about 15 seconds. Akamai support is in beta, a proxy and a user agent are required, failed solves are not billed, and new accounts get 100 free solves with no card required.

Get valid Akamai cookies with one API call

Send the URL, your user agent and a proxy, and get back _abck and the cookies that go with it. Beta, $2.00 per 1,000 successful solves, 100 free solves on signup, no card required.