For the complete documentation index, see llms.txt. This page is also available as Markdown.

Mobile User-Agent

How the Kasada mobile SDK derives the user-agent and x-kpsdk-dv headers, and how to generate them with the Hyper Solutions SDKs.

On the native mobile app flow, the user-agent header Kasada sends to /tl and the protected endpoints is not a readable UA string. The Kasada 2.x mobile SDK replaces it with a 32-character hex hash derived from the device and app identity.

If you send a browser-style UA on a mobile Kasada flow, it will not match what the SDK produces, so generate the value instead of hardcoding one.

Background on how we confirmed this: Kasada mobile user agent. Product details: Kasada solver API.

How it is derived

The value is the lowercase hex MD5 of the string:

<osVersion> / <bundleId> <appVersion>

Note the spaces: / between the OS version and the bundle id, and a single space before the app version.

Component
iOS
Android

osVersion

UIDevice.systemVersion (e.g. 18.0.1)

Build.VERSION.SDK_INT (e.g. 34)

bundleId

CFBundleIdentifier (e.g. com.example.app)

application package name

appVersion

CFBundleShortVersionString (e.g. 9.15.0)

versionName

The hash is pure device and app identity, with no per-request nonce, so it is stable for a given osVersion + bundleId + appVersion. The dynamic challenge data lives in x-kpsdk-cd, x-kpsdk-ct and x-kpsdk-im, not in the user-agent.

For example, 18.0.1 / com.example.app 9.15.0 hashes to 7016adc4ba8d433533954ebad33be424.

Generating it with the SDKs

import "github.com/Hyper-Solutions/hyper-sdk-go/v4/kasada"

userAgent := kasada.GenerateUserAgent("18.0.1", "com.example.app", "9.15.0")
// userAgent == "7016adc4ba8d433533954ebad33be424"
from hyper_sdk import generate_kasada_user_agent

user_agent = generate_kasada_user_agent("18.0.1", "com.example.app", "9.15.0")
# user_agent == "7016adc4ba8d433533954ebad33be424"
import { generateKasadaUserAgent } from 'hyper-sdk-js';

const userAgent = generateKasadaUserAgent({
    osVersion: '18.0.1',
    bundleId: 'com.example.app',
    appVersion: '9.15.0',
});
// userAgent === "7016adc4ba8d433533954ebad33be424"

Available in hyper-sdk-go v3.1.0, hyper-sdk-js 4.1.0, and hyper_sdk (Python) 3.1.0.

Send the returned value as the user-agent header on the mobile Kasada requests. When the payload was generated with a mobile UA, remember to send only st on /cd (see KasadaPowInput).

The x-kpsdk-dv header

On iOS the Kasada SDK also sends an x-kpsdk-dv header, starting with the very first request to the protected site, before you call our API. It describes the device and the app: the iOS version, the model identifier, the bundle id and the app version.

How it is derived

The value is the base64 of a small JSON object, XORed byte by byte with a key fixed in the Kasada SDK:

Field
Source
Example

osVersion

UIDevice.systemVersion

18.0.1

hardwareId

the model identifier from utsname.machine, not the marketing name

iPhone13,2 (iPhone 12)

appId

the app's bundle id, the same one the hashed user-agent uses

com.example.app

appVersion

the app's version string, the same one the hashed user-agent uses

9.15.0

appId and appVersion are part of the header from Kasada SDK i-2.x (the x-kpsdk-v value) onward, and a site on that SDK rejects a header without them. If you captured the header from the app you are emulating, send that exact value; otherwise generate one.

Generating it with the SDKs

Build the user-agent and the header from the same values, so both describe the same app and device.

Pass it to the payload request

Send the same value as dv when you generate the payload. The API then builds the payload on a real iPhone with the screen of the model you named, running the iOS version you named, so the payload and the header you already sent describe the same device.

dv is optional and only read for a mobile app user-agent. Without it the API picks a device on the iOS version your user-agent names, or any recent iPhone when the user-agent names none (the hashed user-agent above names none), and that device may not be the model your header claims. A dv that does not decode is rejected with invalid dv.

Last updated