VectoralDocsWebsite
API referenceView Markdown

Score a request

Pre-call risk score for an account, fused with the browser signal when a recent sensor event matches. Forward the signed sensor_token from /v1/sensor/collect for the trusted, unforgeable join, or pass a bare session_id for the legacy soft join. Call before invoking the LLM.

Only account_id is required. Internal failures fail open: if scoring itself fails you still get a 200 with tier low and reason scoring_unavailable, and malformed optional blocks (prompt_fingerprint, ip_hash, ip_country) are dropped rather than rejected. Manual blocks and spend caps are still enforced on a fail-open verdict.

Call this before invoking the LLM. To enable signal fusion, forward the signed sensor_token your browser received from /v1/sensor/collect (the trusted, unforgeable join) — or pass a bare session_id for the legacy soft join. When a recent browser event matches, its verdict is folded in and signals_fused is true.

Act on blocked, not just tier

blocked: true means the verdict was forced by a hard control rather than the behavioral score — a manual block from the dashboard, or a tripped spend cap. The tier is forced to high, the score to 1, and the responsible code is prepended to reasons:

Reason Cause
account_blocked An operator blocked the account from the dashboard.
spend_cap_exceeded:account The per-account spend cap tripped.
spend_cap_exceeded:org The org-wide spend cap tripped.

Highest precedence wins, in that order. The behavioral reasons still follow the block code in reasons, but score no longer reflects the behavioral assessment — it is 1.

js
const v = await res.json();
if (v.blocked || v.tier === "high") return deny();

Failing open

Only account_id is required, and our own failures never cost you a 4xx. If scoring itself fails you get a 200 with tier low and the single reason scoring_unavailable; manual blocks and spend caps are still enforced on top of it. Malformed optional input — a bad prompt_fingerprint, an over-long ip_hash, an ip_country that isn't two letters — is dropped and the request scores without it.

Provenance

algorithm names the scorer that actually produced the verdict — lightgbm for your trained model, otherwise the rule algorithm that ran — and algorithm_version its version. service_version is the Vectoral build that answered. Treat all three as opaque strings; quote them in support requests.

Sending ip_hash instead of ip

If you can't transmit raw client addresses, send ip_hash — a one-way token you key yourself. Credential-sharing and account-farming detection are unaffected, since those compare addresses for equality only. Datacenter-origin detection and geo enrichment need the address itself and become unavailable.

ip wins when both are present.

Account context

account.context carries what you already know about the user — plan, payment method, verification state, chargeback history. It's the cheapest accuracy win available to most integrations, because behavior alone can't tell a long-standing paying customer from a well-warmed farm account.

Send it inline here, or hydrate it once per account via POST /v1/accounts/{id}/context. Inline overlays stored.

Prompt fingerprints

request.prompt_fingerprint unlocks the prompt similarity signals — scripted repetition and account farms sharing one prompt template — without prompt text ever reaching Vectoral. Your SDK hashes locally under a per-tenant salt.

A malformed block is dropped and the request is still scored; you'll never get a 4xx for it. Nothing fingerprint-derived is echoed in the response.

Retries

Pass an event_id and a repeat returns the original verdict with duplicate: true, having scored and written nothing — see idempotency.

A replay carries the stored score, tier, reasons, and provenance.

OpenAPI

POST/v1/score

Request body

FieldTypeDescription
account_idRequiredstring

Your stable identifier for the end-user. The primary join key for all scoring history. Required and non-empty.

session_idOptionalstring

Your session id. Used as the legacy soft join for browser-signal fusion when no request.sensor_token is sent, and stored for correlation.

accountOptionalany

Facts about the account in your product. Optional.

requestOptionalany

Per-request context. Optional in the schema, but almost every signal reads from it — send it.

event_idOptionalstring

Optional idempotency key. Repeating the same (customer, event_id) returns the original verdict with duplicate: true and writes nothing. Make it stable across your own retries; do not derive it from a transport message id.

Response 200

Score computed. Also returned for blocked accounts (check blocked), event_id replays (duplicate: true), and fail-open verdicts.

FieldTypeDescription
scoreRequirednumber

Risk score in [0, 1], after browser fusion and any reputation discount. Forced to 1 when blocked is true; 0 on a fail-open verdict.

tierRequiredlow | medium | high

Banding of score by your scoring thresholds (default: low < 0.4, medium < 0.7, high ≥ 0.7). Forced to high when blocked is true.

reasonsRequiredstring[]

Short codes explaining the verdict. Scoring contributes up to three, ordered by impact; reputation_discount may be appended and a hard-control code (account_blocked, spend_cap_exceeded:account, spend_cap_exceeded:org) prepended, so treat it as variable-length. scoring_unavailable alone means scoring failed and the verdict failed open.

blockedRequiredboolean

The verdict was forced by a hard control rather than the behavioral score — a manual block from the dashboard, or a tripped spend cap. tier is forced to high, score to 1, and the responsible code is prepended to reasons (the behavioral reasons follow it). Deny the request when this is true.

shadow_modeRequiredboolean

True while your account is in the warm-up window. The real score is still returned.

baseline_readyRequiredboolean

False during the warm-up window, when the score is provisional; treat it as advisory until this is true.

deep_mode_activeRequiredboolean

True when Deep Mode is enabled for your account and the request carried prompt_text or prompt_embedding.

signals_fusedRequiredboolean

Whether a browser sensor signal was folded in.

browser_scoreOptionalnumber

Standalone browser bot-score for the joined session. Present only when signals_fused is true.

browser_decisionOptionalallow | challenge | deny

The browser sensor's own decision for the joined session. Present only when signals_fused is true.

duplicateOptionalboolean

Present and true only when this response replays a verdict already stored under the request's event_id. Nothing was scored and nothing was written. A replay carries the stored score, tier, reasons, and provenance fields. Omitted entirely otherwise.

algorithmOptionalstring

The scorer that actually produced this verdict: lightgbm for your trained model, otherwise the rule algorithm that ran (e.g. incumbent, bobcat). Treat as opaque — new names may appear without a version bump. Omitted when unknown (e.g. replays of rows scored before this field existed).

algorithm_versionOptionalstring

Version of algorithm — the model version for a trained scorer (e.g. v20260818-141233), the algorithm's own version otherwise. Opaque. Omitted when unknown, including on a fail-open verdict.

service_versionOptionalstring

The Vectoral build that answered — a release (e.g. 0.1.8) or a commit for an unreleased build. Independent of algorithm_version. Useful in support requests.

Response 400

Malformed request: body over 1 MiB (read body: …), invalid JSON or a field of the wrong type (decode: …), or missing account_id (account_id required).

FieldTypeDescription
errorRequiredstring

Human-readable message. Not stable — don't parse it.

Response 401

Missing, malformed, unknown, expired, or revoked API key.

FieldTypeDescription
errorRequiredstring

Human-readable message. Not stable — don't parse it.

Response 500

Server error. Scoring failures themselves fail open with a 200.

FieldTypeDescription
errorRequiredstring

Human-readable message. Not stable — don't parse it.

View complete OpenAPI definition
yaml
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/score:
    post:
      tags:
        - Scoring
      summary: Score a request
      description: >-
        Pre-call risk score for an account, fused with the browser signal when a
        recent sensor event matches. Forward the signed `sensor_token` from
        `/v1/sensor/collect` for the trusted, unforgeable join, or pass a bare
        `session_id` for the legacy soft join. Call before invoking the LLM.


        Only `account_id` is required. Internal failures fail **open**: if
        scoring itself fails you still get a `200` with tier `low` and reason
        `scoring_unavailable`, and malformed optional blocks
        (`prompt_fingerprint`, `ip_hash`, `ip_country`) are dropped rather than
        rejected. Manual blocks and spend caps are still enforced on a fail-open
        verdict.
      operationId: score
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ScoreRequest'
            example:
              account_id: user_abc123
              event_id: req_2f9c1a
              account:
                subscription_tier: pro
                first_seen: '2026-01-04T12:00:00Z'
                context:
                  plan_type: paid
                  has_payment_method: true
              request:
                ip: 203.0.113.9
                user_agent: Mozilla/5.0 …
                model_requested: gpt-4o
                estimated_prompt_tokens: 1247
                sensor_token: eyJ…
                session_signals:
                  ms_since_last_request: 320
                  ms_since_page_load: 45000
                  interaction_events_count: 12
                  is_first_request_in_session: false
      responses:
        '200':
          description: >-
            Score computed. Also returned for blocked accounts (check
            `blocked`), event_id replays (`duplicate: true`), and fail-open
            verdicts.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScoreResponse'
              example:
                score: 0.91
                tier: high
                reasons:
                  - webdriver_present
                  - ip_rotation
                  - sybil_ip_cluster
                deep_mode_active: false
                baseline_ready: true
                shadow_mode: false
                blocked: false
                signals_fused: true
                browser_score: 0.77
                browser_decision: deny
                algorithm: incumbent
                algorithm_version: '1.0'
                service_version: 0.1.8
        '400':
          description: >-
            Malformed request: body over 1 MiB (`read body: …`), invalid JSON or
            a field of the wrong type (`decode: …`), or missing `account_id`
            (`account_id required`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: account_id required
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          description: Server error. Scoring failures themselves fail open with a `200`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: 'auth: …'
components:
  schemas:
    ScoreRequest:
      type: object
      required:
        - account_id
      properties:
        account_id:
          type: string
          description: >-
            Your stable identifier for the end-user. The primary join key for
            all scoring history. Required and non-empty.
          example: user_abc123
        session_id:
          type: string
          description: >-
            Your session id. Used as the legacy soft join for browser-signal
            fusion when no `request.sensor_token` is sent, and stored for
            correlation.
          example: sess_xyz
        account:
          allOf:
            - $ref: '#/components/schemas/AccountBlock'
          description: Facts about the account in your product. Optional.
        request:
          allOf:
            - $ref: '#/components/schemas/RequestBlock'
          description: >-
            Per-request context. Optional in the schema, but almost every signal
            reads from it — send it.
        event_id:
          type: string
          description: >-
            Optional idempotency key. Repeating the same `(customer, event_id)`
            returns the **original** verdict with `duplicate: true` and writes
            nothing. Make it stable across your own retries; do not derive it
            from a transport message id.
          example: req_2f9c1a
    ScoreResponse:
      type: object
      properties:
        score:
          type: number
          description: >-
            Risk score in [0, 1], after browser fusion and any reputation
            discount. Forced to `1` when `blocked` is true; `0` on a fail-open
            verdict.
          example: 0.91
        tier:
          type: string
          enum:
            - low
            - medium
            - high
          example: high
          description: >-
            Banding of `score` by your scoring thresholds (default: `low` < 0.4,
            `medium` < 0.7, `high` ≥ 0.7). Forced to `high` when `blocked` is
            true.
        reasons:
          type: array
          items:
            type: string
          example:
            - webdriver_present
            - ip_rotation
            - sybil_ip_cluster
          description: >-
            Short codes explaining the verdict. Scoring contributes up to three,
            ordered by impact; `reputation_discount` may be appended and a
            hard-control code (`account_blocked`, `spend_cap_exceeded:account`,
            `spend_cap_exceeded:org`) prepended, so treat it as variable-length.
            `scoring_unavailable` alone means scoring failed and the verdict
            failed open.
        blocked:
          type: boolean
          description: >-
            The verdict was forced by a hard control rather than the behavioral
            score — a manual block from the dashboard, or a tripped spend cap.
            `tier` is forced to `high`, `score` to `1`, and the responsible code
            is prepended to `reasons` (the behavioral reasons follow it). **Deny
            the request when this is true.**
          example: false
        shadow_mode:
          type: boolean
          example: false
          description: >-
            True while your account is in the warm-up window. The real score is
            still returned.
        baseline_ready:
          type: boolean
          example: true
          description: >-
            False during the warm-up window, when the score is provisional;
            treat it as advisory until this is true.
        deep_mode_active:
          type: boolean
          example: false
          description: >-
            True when Deep Mode is enabled for your account **and** the request
            carried `prompt_text` or `prompt_embedding`.
        signals_fused:
          type: boolean
          description: Whether a browser sensor signal was folded in.
          example: true
        browser_score:
          type: number
          description: >-
            Standalone browser bot-score for the joined session. Present only
            when `signals_fused` is true.
          example: 0.77
        browser_decision:
          type: string
          enum:
            - allow
            - challenge
            - deny
          example: deny
          description: >-
            The browser sensor's own decision for the joined session. Present
            only when `signals_fused` is true.
        duplicate:
          type: boolean
          description: >-
            Present and `true` only when this response replays a verdict already
            stored under the request's `event_id`. Nothing was scored and
            nothing was written. A replay carries the stored `score`, `tier`,
            `reasons`, and provenance fields. Omitted entirely otherwise.
          example: true
        algorithm:
          type: string
          description: >-
            The scorer that actually produced this verdict: `lightgbm` for your
            trained model, otherwise the rule algorithm that ran (e.g.
            `incumbent`, `bobcat`). Treat as opaque — new names may appear
            without a version bump. Omitted when unknown (e.g. replays of rows
            scored before this field existed).
          example: bobcat
        algorithm_version:
          type: string
          description: >-
            Version of `algorithm` — the model version for a trained scorer
            (e.g. `v20260818-141233`), the algorithm's own version otherwise.
            Opaque. Omitted when unknown, including on a fail-open verdict.
          example: '0.1'
        service_version:
          type: string
          description: >-
            The Vectoral build that answered — a release (e.g. `0.1.8`) or a
            commit for an unreleased build. Independent of `algorithm_version`.
            Useful in support requests.
          example: 0.1.8
      required:
        - score
        - tier
        - reasons
        - deep_mode_active
        - baseline_ready
        - shadow_mode
        - blocked
        - signals_fused
    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.
    AccountBlock:
      type: object
      properties:
        subscription_tier:
          type: string
          example: free
          description: >-
            Free-form tier label from your product (`free`, `pro`, …). Stored on
            the account for filtering and review.
        first_seen:
          type: string
          format: date-time
          description: >-
            When the account was created in your system (RFC 3339).
            Informational only. A value that is not a valid RFC 3339 timestamp
            fails the request with a `400`.
          example: '2026-01-04T12:00:00Z'
        context:
          $ref: '#/components/schemas/AccountContext'
    RequestBlock:
      type: object
      properties:
        ip:
          type: string
          description: >-
            Client IP (IPv4 or IPv6) — strongly recommended. Send the **end
            user's** address, not your gateway's: a private or CGNAT egress
            address is shared by everyone behind it, so account-farming
            detection reports it as uncomputable rather than flagging your own
            users.
          example: 203.0.113.9
        ip_hash:
          type: string
          maxLength: 128
          description: >-
            A customer-keyed one-way token standing in for `ip`, for callers who
            cannot transmit raw addresses. Preserves credential-sharing and
            account-farming detection, which need only equality;
            datacenter-origin detection and geo enrichment need the address
            itself and become unavailable. Ignored when `ip` is also present; a
            value over 128 characters is dropped (not rejected). Use the **same
            form consistently** on `/v1/score` and `/v1/identity` — mixing raw
            IPs on one and tokens on the other splits your own sybil graph.
          example: 9f2c…
        asn:
          type: integer
          minimum: 0
          maximum: 4294967295
          description: >-
            Customer-resolved autonomous system number. Stored for investigation
            and review. `0` is treated as absent. A negative, fractional, or
            out-of-range value fails JSON decoding and returns `400`.
          example: 13335
        ip_country:
          type: string
          description: >-
            Customer-resolved ISO 3166-1 alpha-2 country (two letters,
            case-insensitive). Fills in `country` when no geo lookup succeeded.
            Anything else is dropped. Stored for investigation and review.
          example: US
        user_agent:
          type: string
          description: Client user agent. Stored for investigation.
        model_requested:
          type: string
          example: gpt-4o
          description: The LLM model you are about to invoke.
        estimated_prompt_tokens:
          type: integer
          example: 1247
          description: Your estimate of the prompt token count before invocation.
        session_signals:
          allOf:
            - $ref: '#/components/schemas/SessionSignals'
          description: >-
            Client-observed session timing. Sending the block at all — even `{}`
            — turns on the signals derived from it; omitting it (or `null`)
            leaves them gated off.
        sensor_token:
          type: string
          description: >-
            The signed token the browser received from `/v1/sensor/collect`,
            forwarded by your backend. The trusted, unforgeable way to join the
            browser bot verdict — its signed claims carry the real session id,
            so it supersedes `session_id` for fusion. A token that fails
            verification skips fusion (it does not fall back to `session_id`).
        prompt_text:
          type: string
          description: Only used when Deep Mode is enabled.
        prompt_embedding:
          type: array
          items:
            type: number
          description: >-
            Optional precomputed prompt embedding. Only used when Deep Mode is
            enabled; an alternative to `prompt_text`.
        prompt_fingerprint:
          allOf:
            - $ref: '#/components/schemas/PromptFingerprintBlock'
    AccountContext:
      type: object
      description: >-
        Optional, customer-attested account facts used as trust/risk priors.
        Every field is optional and an omitted field means **unknown** — it is
        gated off in scoring, never defaulted to a misleading value. Positive
        facts (paid, payment on file, verified) raise trust and can earn a
        bounded score discount; negative ones raise risk. Send it inline here
        per request, or hydrate it once per account with `POST
        /v1/accounts/{accountId}/context`; an inline block overlays the stored
        one.
      properties:
        plan_type:
          type: string
          enum:
            - paid
            - unpaid
            - trial
            - free
          description: >-
            Case-insensitive. `paid` is a trust signal; `unpaid`, `trial` and
            `free` are risk signals. Any other value is ignored (treated as
            unknown).
          example: paid
        has_payment_method:
          type: boolean
          description: >-
            A verified card or payment method on file. The strongest single
            trust signal — real identity plus a cost to replace the account.
            `false` is a risk signal.
          example: true
        email_verified:
          type: boolean
          example: true
          description: '`true` raises trust; `false` is a risk signal.'
        identity_verified:
          type: boolean
          description: KYC or equivalent identity verification. `true` raises trust.
          example: false
        prior_chargeback:
          type: boolean
          description: A prior chargeback or payment dispute. Strong risk signal.
          example: false
        billing_delinquent:
          type: boolean
          example: false
          description: Overdue or failed billing. `true` is a risk signal.
        trust_label:
          type: string
          enum:
            - vip
            - allowlisted
            - allowlist
            - trusted
          description: >-
            Case-insensitive. Any of these grants the maximal trust floor. Still
            bounded — this is not a hard allowlist and will not suppress an
            egregious score. Other values are ignored.
          example: vip
    SessionSignals:
      type: object
      properties:
        ms_since_last_request:
          type: integer
          description: Milliseconds since this user's previous request in the same session.
        ms_since_page_load:
          type: integer
          description: Milliseconds since the page that initiated this call loaded.
        interaction_events_count:
          type: integer
          example: 12
          description: >-
            Mouse / keyboard / focus events you observed in this session. `0` is
            meaningful: on a non-first request it fires `no_user_interaction`.
        is_first_request_in_session:
          type: boolean
          description: >-
            Whether this is the first request of the session. Interaction-based
            signals are skipped on the first request.
        ms_since_signup:
          type: integer
          description: >-
            Milliseconds since the account was created. Only read on the first
            score Vectoral sees for the account.
      description: >-
        All fields optional. Inside a sent block, an omitted field reads as
        `0`/`false`.
    PromptFingerprintBlock:
      type: object
      description: >-
        Optional client-computed prompt fingerprint, enabling the
        prompt-similarity signals **without prompt text ever reaching
        Vectoral**. Your SDK hashes the prompt locally under a per-tenant salt.
        64-bit values travel as strings because JSON cannot carry them safely. A
        malformed block is dropped with a logged reason and the request is still
        scored — never a 4xx. Nothing fingerprint-derived is echoed in the score
        response.
      required:
        - v
        - salt_id
        - simhash
        - exact_hash
      properties:
        v:
          type: integer
          enum:
            - 1
          description: Format version. Must be `1`.
          example: 1
        salt_id:
          type: string
          description: >-
            Identifies the tenant salt generation. Fingerprints only ever
            compare within one `salt_id`, so a change here starts a fresh
            corpus.
          example: live
        simhash:
          type: string
          pattern: ^[0-9a-f]{16}$
          description: 16 hex digits — 64-bit SimHash of the normalized prompt shingles.
          example: 3f2a91c40b7de815
        exact_hash:
          type: string
          pattern: ^[0-9a-f]{16}$
          description: >-
            16 hex digits — exact-form hash (digit collapse skipped), which
            separates verbatim repetition from template reuse.
          example: a91c40b7de8153f2
        conversation_key:
          type: string
          maxLength: 256
          description: >-
            Groups multi-turn context. Same-conversation rows are excluded from
            within-account comparison, since follow-up turns are expected to
            resemble each other.
          example: conv_88f1
        minhash:
          type: string
          description: >-
            Base64 (standard alphabet, padded) of the 128-byte MinHash signature
            (64 little-endian uint16 values). Present if and only if `band_keys`
            is.
          example: Zm9vYmFy…
        band_keys:
          type: array
          items:
            type: string
          minItems: 16
          maxItems: 16
          description: >-
            Exactly 16 LSH band keys as decimal int64 strings. Present if and
            only if `minhash` is. **The single highest-yield optional field
            here** — cross-account farm detection is unavailable without it.
          example:
            - '8123456789012345'
            - '8123456789117074'
            - '8123456789221803'
            - '8123456789326532'
            - '8123456789431261'
            - '8123456789535990'
            - '8123456789640719'
            - '8123456789745448'
            - '8123456789850177'
            - '8123456789954906'
            - '8123456790059635'
            - '8123456790164364'
            - '8123456790269093'
            - '8123456790373822'
            - '8123456790478551'
            - '8123456790583280'
        simhash_global:
          type: string
          pattern: ^[0-9a-f]{16}$
          description: >-
            16 hex digits — unsalted global-tier SimHash. Only sent by customers
            who opted into cross-customer sharing.
  responses:
    Unauthorized:
      description: Missing, malformed, unknown, expired, or revoked API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missing:
              summary: No or malformed Authorization header
              value:
                error: 'missing or malformed Authorization: Bearer <api key>'
            invalid:
              summary: Unknown, expired, or revoked key
              value:
                error: invalid, expired, or revoked api key
  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).

Search guides, concepts, and API endpoints.