# Collect sensor signals

> Public, browser-facing endpoint. Authenticates with the publishable `pk_live_` site key in the request body (not the secret bearer) and is CORS-enabled. Normally called by the sensor script, not directly.

Credentials are not allowed, so send the request with `credentials: "omit"`.

The returned token is valid for 120 seconds by default (`VECTORAL_SENSOR_TOKEN_TTL_SECONDS` on self-hosted deployments).

The public, browser-facing endpoint — authenticated by your `pk_live_` site key in the
body, not the secret bearer, and CORS-enabled. Normally called by the
[sensor script](https://docs.vectoral.si/guides/browser-sensor.md), not directly. Returns a signed verdict token;
the `decision` is advisory only — never enforce on the client.

A missing, malformed, or revoked site key returns `401`. Credentials aren't allowed, so
send the request with `credentials: "omit"` (the sensor does).

The returned token is valid for **120 seconds** by default; self-hosted deployments
can change it with `VECTORAL_SENSOR_TOKEN_TTL_SECONDS`. Bodies are capped at 1 MiB.


## OpenAPI

````yaml openapi.json POST /v1/sensor/collect
openapi: 3.1.0
info:
  title: Vectoral API
  version: 1.0.0
  description: >-
    Fraud and abuse detection for AI app builders. Score the accounts hitting
    your AI features and catch the abuse draining your inference budget.
servers:
  - url: https://api.vectoral.cloud
    description: Hosted
  - url: http://localhost:8080
    description: Self-hosted (default bind)
security:
  - bearerAuth: []
paths:
  /v1/sensor/collect:
    post:
      tags:
        - Sensor
      summary: Collect sensor signals
      description: >-
        Public, browser-facing endpoint. Authenticates with the publishable
        `pk_live_` site key in the request body (not the secret bearer) and is
        CORS-enabled. Normally called by the sensor script, not directly.


        Credentials are not allowed, so send the request with `credentials:
        "omit"`.


        The returned token is valid for 120 seconds by default
        (`VECTORAL_SENSOR_TOKEN_TTL_SECONDS` on self-hosted deployments).
      operationId: sensorCollect
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CollectRequest'
            example:
              v: 3
              siteKey: pk_live_xxxxxxxxxxxxxxxx
              sessionId: 7d3c9e1a-4b2f-4c8e-9a51-2f6b0d8e1c47
              action: generate
              fingerprint: a1b2c3d4
              loadedEpoch: 1759400000000
              collectedAtMs: 5230
              url: https://app.example.com/chat
              referrer: null
              environment:
                ua: >-
                  Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)
                  AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0
                  Safari/537.36
                languages:
                  - en-US
                  - en
                platform: MacIntel
                hardwareConcurrency: 8
                deviceMemory: 8
                timezone: America/New_York
                canvasHash: 9f86d081
                webgl:
                  vendor: Google Inc. (Apple)
                  renderer: ANGLE (Apple, Apple M2, OpenGL 4.1)
              automation:
                tells: []
                webdriver: false
                languages:
                  - en-US
                  - en
                hasLanguages: true
                plugins: 5
                hasChromeObj: true
                permissionsQuirk: object
              behavior:
                firstInteractionMs: 840
                mouseMoves: 112
                mouseDistance: 3410
                clicks: 2
                keys: 14
                scrolls: 3
                touches: 0
                pointerTypes:
                  - mouse
                maxSpeed: 2.4
      responses:
        '200':
          description: Signed verdict token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CollectResponse'
              example:
                token: eyJjaWQiOi….Zk3q…
                decision: allow
        '400':
          description: >-
            The body couldn't be read (over 1 MiB: `read: …`) or isn't valid
            JSON for this shape (`decode: …`), e.g. a non-integer
            `collectedAtMs`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: 'decode: unexpected end of JSON input'
        '401':
          description: >-
            `siteKey` is missing or doesn't look like a `pk_live_` key (`missing
            or malformed siteKey`), or isn't a live key (`invalid or revoked
            siteKey`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: invalid or revoked siteKey
        '500':
          description: Internal error resolving the site key or signing the token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: 'sign: <error>'
      security: []
components:
  schemas:
    CollectRequest:
      type: object
      required:
        - siteKey
      properties:
        v:
          type: integer
          description: Sensor payload version.
          example: 3
        siteKey:
          type: string
          description: Your `pk_live_` publishable key.
          example: pk_live_xxxxxxxxxxxxxxxx
        sessionId:
          type: string
          description: >-
            Per-tab session id generated by the sensor. Carried in the token and
            used as the fusion join key.
          example: 7d3c9e1a-4b2f-4c8e-9a51-2f6b0d8e1c47
        action:
          type:
            - string
            - 'null'
          description: >-
            The protected action this token is for (the `action` passed to
            `getToken`).
          example: generate
        fingerprint:
          type: string
          description: Device fingerprint hash.
        loadedEpoch:
          type: integer
          format: int64
          description: Page load time, Unix milliseconds.
        collectedAtMs:
          type: integer
          description: Milliseconds on the page before collection. Must be an integer.
        url:
          type: string
        referrer:
          type:
            - string
            - 'null'
        environment:
          type: object
          description: >-
            Device environment. Additional keys the sensor sends (screen,
            timezone offset, etc.) are accepted and stored.
          properties:
            ua:
              type: string
            languages:
              type: array
              items:
                type: string
            platform:
              type: string
            hardwareConcurrency:
              type:
                - integer
                - 'null'
            deviceMemory:
              type:
                - number
                - 'null'
            timezone:
              type:
                - string
                - 'null'
            canvasHash:
              type:
                - string
                - 'null'
            webgl:
              type:
                - object
                - 'null'
              properties:
                vendor:
                  type:
                    - string
                    - 'null'
                renderer:
                  type:
                    - string
                    - 'null'
        automation:
          type: object
          description: Automation tells.
          properties:
            tells:
              type: array
              items:
                type: string
              description: >-
                Detected automation markers, e.g. `webdriver`, `__playwright`,
                `cdc_`, `headless-ua`, `missing-window.chrome`.
            webdriver:
              type: boolean
            languages:
              type: array
              items:
                type: string
            hasLanguages:
              type: boolean
            plugins:
              type: integer
              description: '`navigator.plugins.length`, or `-1` if unreadable.'
            hasChromeObj:
              type: boolean
            permissionsQuirk:
              type: string
        behavior:
          type: object
          description: Interaction counts since page load.
          properties:
            firstInteractionMs:
              type:
                - integer
                - 'null'
              description: '`null` when no interaction was observed.'
            mouseMoves:
              type: integer
            mouseDistance:
              type: integer
            clicks:
              type: integer
            keys:
              type: integer
            scrolls:
              type: integer
            touches:
              type: integer
            pointerTypes:
              type: array
              items:
                type: string
            maxSpeed:
              type: number
              description: Peak pointer speed, px/ms.
      description: >-
        The payload the sensor script posts. Only `siteKey` is required; unknown
        fields are ignored, and the whole body is stored with the event.
    CollectResponse:
      type: object
      properties:
        token:
          type: string
          description: >-
            Signed verdict token, valid for 120 seconds by default. Pass it to
            your backend for `/v1/sensor/verify`, or as `request.sensor_token`
            on `/v1/score`.
        decision:
          type: string
          enum:
            - allow
            - challenge
            - deny
          description: Soft verdict — advisory only, never enforce on the client.
      required:
        - token
        - decision
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          example: account_id required
          description: Human-readable message. Not stable — don't parse it.
      required:
        - error
      description: >-
        Uniform error envelope. The message is for humans and is not stable;
        branch on the HTTP status.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Your secret API key: `vg_live_` followed by 43 base64url characters.
        Send it as `Authorization: Bearer vg_live_…` on every `/v1` request
        (except `POST /v1/sensor/collect`, which uses a publishable site key in
        the body).

````
