POST /session¶
POST
/v1/collect/sessionpublishable keyOpens a collection session and returns the collector config. The SDK calls it for you.
| Field | Type | Rules |
|---|---|---|
user_id |
string | Required; 1 to 128 characters. |
api_key |
string | Publishable key; up to 128 characters. |
consent |
object | Required with a key: training must be true; policy_version up to 64 characters. |
sdk_version |
string | Up to 32 characters. |
page |
string | Origin and path; up to 512 characters. |
device |
object | Device context, with the fingerprint under fp; up to 16,384 bytes as JSON. |
Request
POST /v1/collect/session HTTP/1.1
Host: api.behavlabs.com
Content-Type: application/json
Origin: https://app.example.com
{
"user_id": "h1:5d41402abc4b2a76...", // SHA-256 of your key + ":" + your account ID, computed by the SDK
"api_key": "pk_beta_your_key",
"consent": { "training": true, "policy_version": "acme-privacy-2026-11" },
"sdk_version": "2.4.0",
"page": "https://app.example.com/settings",
"device": { "screen_w": 1512, "screen_h": 982, "dpr": 2, "tz": "America/New_York", "lang": "en-US",
"fp": { "canvas": "1a70dc1c715c93", "gl_renderer": "ANGLE (Apple, Apple M2, OpenGL 4.1)",
"audio": "124.043477767", "fonts": "148eba6217c2d4" } }
}
Response
{
"session_id": "8649741cdcf3427eba8259d8b63e2bbb",
"config": {
"flush_interval_ms": 2000,
"max_batch_events": 2000,
"move_throttle_ms": 16,
"key_mode": "code",
"capture": { "keystroke": true, "mouse": true, "touch": true, "scroll": true, "field_len": true },
"sensitive_autocomplete": ["current-password", "new-password", "one-time-code", "cc-number", "cc-csc",
"cc-exp", "cc-exp-month", "cc-exp-year"]
}
}