x-kpsdk-ct is Kasada's client token: an opaque value the site issues after Kasada's p.js script has fingerprinted the browser and posted the result to the /tl endpoint, and which the client then sends on every request to a protected endpoint. x-kpsdk-cd is its companion proof-of-work header: in most deployments a small JSON payload with the answers to a SHA-256, hashcash-style puzzle plus timing data, recomputed for every request, so it cannot be copied from one call to the next.
Together with x-kpsdk-v (the SDK version), these are the headers Kasada checks before letting an API call through. A missing, expired or reused value typically gets an HTTP 429 instead of the response you wanted. This page explains where each header comes from, how to recognise a Kasada deployment, what x-kpsdk-cd contains, why Kasada reverse engineering is expensive to keep working, and how to get a valid set of headers from a single API call instead.
Short version: you do not have to reverse engineer Kasada's VM to get valid headers. The NSLSolver Kasada API returns x-kpsdk-ct, x-kpsdk-cd, x-kpsdk-v and x-kpsdk-h from one POST, typically in 3 to 10 seconds, for $1.50 per 1,000 successful solves.
Related reading: for an end-to-end Python walkthrough, see the Kasada bypass guide; for parameters, pricing and live samples, see the Kasada solver API page; for the equivalent cookie on Akamai, see the Akamai _abck cookie explained. This page is about the x-kpsdk headers themselves.
This error has an entry in our anti-bot error-code reference, next to every other Cloudflare, Turnstile, Kasada, Akamai and reCAPTCHA error.
The x-kpsdk headers at a glance
Kasada does not publish its protocol, so the descriptions below reflect what is commonly observed on Kasada-protected sites. Treat every value as opaque and replay it exactly as you received it.
| Header | Where it comes from | What it carries | Reusable? |
|---|---|---|---|
| x-kpsdk-ct | Response to the POST /tl request, after the fingerprint has been accepted | The client token that says "this session passed the challenge" | Within its session, until the server stops accepting it |
| x-kpsdk-cd | Computed client-side right before each protected request | Proof of work: puzzle answers, timing data, server time | No, it is computed per request |
| x-kpsdk-v | Set by the Kasada SDK on the page | The SDK version string | Yes, it only changes when the script changes |
| x-kpsdk-h | Set alongside the others on some deployments | An additional hash value | Replay it as returned with the same ct |
Not every site checks every header. Send all the x-kpsdk-* headers you get back; extra ones do no harm.
How to recognise Kasada on a site
Open DevTools on the page, tick "Preserve log" in the Network tab and reload. A Kasada deployment usually shows several of these signals at once, and the same requests give you the three values NSLSolver needs.
| Signal | Where to look | What it gives you |
|---|---|---|
| p.js under two UUIDs | A script such as /149e9513-01fa-4fb0-aad4-566afd725d1b/2d206a39-8ed7-437e-a3be-862e0f06eea3/p.js | That path is p_js_path. It is specific to each site |
| /fp fingerprint page | A request to the same UUID prefix ending in /fp, often loaded in a hidden iframe | The host serving it is fp_host |
| POST /tl | A POST to the same UUID prefix ending in /tl; its response carries x-kpsdk-ct | The host receiving it is tl_host (often an API host, not the page host) |
| x-kpsdk-* request headers | Request headers of the site's own XHR / fetch calls to its API | Which endpoints are protected |
| HTTP 429 with x-kpsdk-* headers | A blocked API call or page load | Confirms the block comes from Kasada, not from a plain rate limit |
| A KPSDK object | Type KPSDK in the console; many sites call KPSDK.configure(...) with a list of protected endpoints | The SDK is loaded on this page |
How the Kasada token flow works, step by step
The exact details change between script builds, but in most deployments the sequence looks like this:
- 1. The page loads p.js from the two-UUID path. This loader sets up the KPSDK object and opens the /fp fingerprint page.
- 2. The /fp page loads the main challenge script (often referred to as ips.js). Its logic does not run as readable JavaScript: it runs as bytecode inside an obfuscated, custom virtual machine.
- 3. The script collects browser signals (navigator properties, rendering and timing behaviour, automation markers and more) and checks that they are consistent with each other.
- 4. It packs and encrypts the result and POSTs it to /tl on tl_host.
- 5. If the server accepts the payload, the /tl response carries x-kpsdk-ct and, typically, the server time and the parameters the client needs for proof of work.
- 6. For each call to an endpoint registered with KPSDK.configure, the SDK computes a fresh proof of work and attaches x-kpsdk-ct, x-kpsdk-cd and x-kpsdk-v (plus x-kpsdk-h on some sites) by hooking fetch / XMLHttpRequest.
- 7. The server checks the headers. If ct is missing or no longer valid, or cd is wrong, stale or already used, it answers 429 and the SDK runs the flow again.
What is inside x-kpsdk-cd?
x-kpsdk-cd is a client-side proof of work. In most deployments it is a JSON object, sent as a string in the header. The client has to find values that, hashed with SHA-256 together with the challenge data, meet a target set by a difficulty level. Finding them costs CPU time; checking them costs the server almost nothing. That asymmetry is the point: it makes every protected request cost the client a little work.
Typically the payload carries:
- The answers to the puzzle: a short list of values that satisfy the difficulty.
- Timing information, such as how long the work took, and the server time it was computed against, so a stale cd can be detected.
- Data that links it to the current challenge and session.
- On some sites, a site-specific constant mixed into the computation. That is what NSLSolver's optional cd_constant parameter is for; most sites do not need it.
Why x-kpsdk-cd changes on every request
The puzzle input includes time and fresh challenge data, and the server can remember answers it has already accepted. A cd computed for one request is therefore usually rejected on the next one, even when x-kpsdk-ct is still valid. That is the most common reason a scraper works for exactly one request and then gets 429s: the headers were captured once from a browser and replayed.
The practical rule: cache nothing about cd. With NSLSolver, the reliable pattern is one solve per protected call, replayed with the same User-Agent you passed to /solve. Only endpoints the site registered with Kasada need the headers; page HTML, static assets and unprotected endpoints usually do not, so you rarely need a solve for every request you make.
Why Kasada reverse engineering is costly
People do reverse engineer Kasada, and you will find write-ups for older script builds. The problem is not getting it to work once; it is keeping it working. The main costs:
- Bytecode VM: the logic lives in bytecode run by a custom interpreter. You have to understand the interpreter before you can read anything, and the opcodes, bytecode and string tables change when the script is rebuilt.
- Script rotation: new builds ship regularly. A deobfuscator or a pure re-implementation that works today can break without warning, usually when you are not watching.
- Encrypted /tl payload: you have to reproduce the exact payload format and its encryption, not just plausible fingerprint values.
- Fingerprint consistency: the signals have to agree with each other and with what the server sees on the protected call: the User-Agent, the Chrome major version, and the TLS and HTTP/2 fingerprint of your HTTP client.
- Session binding and per-request work: ct belongs to the session that earned it and cd has to be computed for each request, so what you build is a pipeline you run continuously, not a token you fetch once.
- Per-site configuration: each site has its own UUID path, hosts and, sometimes, its own constant.
Common failure symptoms and what they mean
| Symptom | Likely cause | What to do |
|---|---|---|
| 429 on the protected call, no x-kpsdk-ct sent | The endpoint is registered with Kasada and the headers are missing | Get a solve and send every returned x-kpsdk-* header |
| 429 right after a fresh solve | User-Agent differs from the user_agent passed to /solve, or ua_version does not match it | Replay with the exact same UA; set ua_version to its Chrome major version |
| First call works, the same headers fail on the second | x-kpsdk-cd reused; it is single-use on most deployments | Get a new solve (fresh cd) for each protected call |
| Headers worked earlier, now 429 | x-kpsdk-ct expired or the session was invalidated; the lifetime is set server-side | Solve again; do not hard-code a lifetime |
| 429 with an x-kpsdk-r header or a reload instruction | Kasada is telling the SDK to run the challenge again | Treat it as "re-solve"; if it repeats, check UA, client fingerprint and proxy |
| Fresh headers fail from your client but work in a browser | TLS / HTTP/2 fingerprint or header set does not look like the UA you claim | Use a browser-impersonating HTTP client (for example curl_cffi) on the protected call |
| /solve returns 400 | Missing or invalid url, p_js_path, fp_host or tl_host | Copy the three values from the Network tab, as shown above |
Kasada does not document its error responses; the causes above are the ones most commonly observed.
Get the x-kpsdk headers with one API call
The NSLSolver Kasada solver API runs the whole flow on its side (p.js, the fingerprint page, the /tl exchange and the proof of work) and returns the headers. POST to https://api.nslsolver.com/solve with your key in the X-API-Key header, type "kasada", the page URL and a kasada_config object with p_js_path, fp_host and tl_host. Add cd_constant only if the site needs one. Pass the user_agent you will replay with and its Chrome major version as ua_version; proxy is optional (protocol://user:pass@host:port).
The response contains x-kpsdk-ct, x-kpsdk-cd, x-kpsdk-v and x-kpsdk-h. Send them on the protected request with the same User-Agent. It costs $1.50 per 1,000 successful solves, failed solves are not billed, and a solve typically takes 3 to 10 seconds. Sign up with Google, Gmail or Proton for $0.10 of free credit (about 125 Turnstile solves), no card required.
Use it only on sites you own or are authorised to automate.
# Ask NSLSolver for a full set of Kasada headers.
# kasada_config values are placeholders: copy the target's real p.js path
# (/<uuid>/<uuid>/p.js from its script tag), /fp host and /tl host from DevTools > Network.
curl -s --max-time 180 https://api.nslsolver.com/solve \
-H "X-API-Key: nsl_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "kasada",
"url": "https://www.example.com/login",
"kasada_config": {
"p_js_path": "/<uuid-1>/<uuid-2>/p.js",
"fp_host": "www.example.com",
"tl_host": "api.example.com"
},
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36",
"ua_version": 145
}'
# Response (200 OK)
# {
# "success": true,
# "type": "kasada",
# "headers": {
# "x-kpsdk-ct": "...",
# "x-kpsdk-cd": "...",
# "x-kpsdk-v": "...",
# "x-kpsdk-h": "..."
# },
# "cost": 0.0015
# }Python example with requests
The same request in Python, followed by the protected call. The headers dict from the response is merged as-is, so any x-kpsdk-* header the site expects is included.
# kasada_headers.py (pip install requests)
import requests
API_KEY = "nsl_YOUR_API_KEY"
USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36"
def get_kasada_headers() -> dict:
r = requests.post(
"https://api.nslsolver.com/solve",
headers={"X-API-Key": API_KEY},
json={
"type": "kasada",
"url": "https://www.example.com/login",
"kasada_config": {
"p_js_path": "/<uuid-1>/<uuid-2>/p.js", # the target's real p.js path (Network tab)
"fp_host": "www.example.com", # host serving /fp
"tl_host": "api.example.com", # host receiving POST /tl
# "cd_constant": "<hex>", # only if the site needs one
},
"user_agent": USER_AGENT, # the exact UA you will replay with
"ua_version": 145, # Chrome major version of that UA
# "proxy": "http://user:pass@host:port", # optional
},
timeout=180, # a solve can take up to 120 s: never time out sooner
)
data = r.json()
if r.status_code != 200 or not data.get("success"):
raise RuntimeError(f"solve failed: {r.status_code} {data}")
return data["headers"] # x-kpsdk-ct, x-kpsdk-cd, x-kpsdk-v, x-kpsdk-h
# x-kpsdk-cd is single-use on most deployments: one solve per protected call.
kasada = get_kasada_headers()
resp = requests.post(
"https://api.example.com/v1/search",
headers={**kasada, "User-Agent": USER_AGENT, "Content-Type": "application/json"},
json={"q": "..."},
timeout=30,
)
print(resp.status_code) # 429 here usually means a header was rejectedPython example with the official SDK
The nslsolver package wraps the same call in solve_kasada(...) with a KasadaConfig object, retries 429 and 503 responses for you and raises typed errors. This example uses Twitch's public Kasada configuration.
# pip install nslsolver
import requests
from nslsolver import NSLSolver, KasadaConfig
solver = NSLSolver("nsl_YOUR_API_KEY")
result = solver.solve_kasada(
url="https://www.example.com/login",
user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36",
ua_version=145,
kasada_config=KasadaConfig(
# Placeholders: copy the target's real values from DevTools > Network
p_js_path="/<uuid-1>/<uuid-2>/p.js", # path of the target's p.js script tag
fp_host="www.example.com", # host that serves /fp
tl_host="api.example.com", # host that receives POST /tl
),
)
# result.headers holds the x-kpsdk-* headers; result.ct / result.cd are shortcuts
resp = requests.post(
"https://api.example.com/v1/search",
headers={**result.headers, "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36"},
json={"query": "..."},
)
print(resp.status_code)Node.js example with fetch
Node 18+ has fetch built in. Node's TLS fingerprint is not a browser's; if fresh headers are still rejected with the right User-Agent, make the protected call from a browser-impersonating client instead.
// kasada.mjs (Node 18+, built-in fetch)
const API_KEY = "nsl_YOUR_API_KEY";
const USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36";
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: "kasada",
url: "https://www.example.com/login",
kasada_config: {
p_js_path: "/<uuid-1>/<uuid-2>/p.js", // the target's real p.js path (Network tab)
fp_host: "www.example.com", // host serving /fp
tl_host: "api.example.com", // host receiving POST /tl
},
user_agent: USER_AGENT,
ua_version: 145,
}),
signal: AbortSignal.timeout(180_000), // a solve can take up to 120 s: never time out sooner
});
const data = await res.json();
if (!res.ok || !data.success) {
throw new Error("solve failed: " + res.status + " " + JSON.stringify(data));
}
// Replay every returned x-kpsdk-* header with the SAME User-Agent
const api = await fetch("https://api.example.com/v1/search", {
method: "POST",
headers: { ...data.headers, "User-Agent": USER_AGENT, "Content-Type": "application/json" },
body: JSON.stringify({ q: "..." }),
});
console.log(api.status);NSLSolver API errors
| Status | Meaning | What to do |
|---|---|---|
| 400 | Validation error: a required field is missing or malformed | Check url and kasada_config (p_js_path, fp_host, tl_host) |
| 401 | Missing or invalid API key | Send your key in the X-API-Key header |
| 402 | Insufficient balance | Top up your balance |
| 429 | NSLSolver rate limit (not Kasada's) | Back off and retry |
| 503 | Temporarily unavailable | Retry; it is not billed |
Only successful solves are billed, so retrying a failed solve does not cost extra.