# Score a registration

> Score a signup **before the account exists** — at form submit, so you can decide whether to let it through, challenge it, or demand a payment instrument. Synchronous, called once per signup. A different question from `/v1/score`, answered by a separate algorithm: there is no account behaviour yet, so this reads the arrival instead — the email, the network origin, the client, and how this registration relates to every other registration you have sent. Internal failures fail open with `tier: 0`.

Call this at form submit, **before the account exists**, to decide whether to let a
signup through, challenge it, or demand a payment instrument. It answers a different
question from [`/v1/score`](https://docs.vectoral.si/api-reference/score): there is no account behaviour yet, so
it reads the arrival instead — the email, the network origin, the client, and how this
registration relates to every other registration you've sent.


## OpenAPI

````yaml openapi.json POST /v1/registrations/score
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/registrations/score:
    post:
      tags:
        - Scoring
      summary: Score a registration
      description: >-
        Score a signup **before the account exists** — at form submit, so you
        can decide whether to let it through, challenge it, or demand a payment
        instrument. Synchronous, called once per signup. A different question
        from `/v1/score`, answered by a separate algorithm: there is no account
        behaviour yet, so this reads the arrival instead — the email, the
        network origin, the client, and how this registration relates to every
        other registration you have sent. Internal failures fail open with
        `tier: 0`.
      operationId: scoreRegistration
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RegistrationRequest'
            example:
              email: john.smith+signup@gmail.com
              event_id: signup_7f3a91
              ip: 203.0.113.47
              user_agent: Mozilla/5.0 ...
              device_fingerprint: fp_9c1e...
              deadline_ms: 400
      responses:
        '200':
          description: >-
            Scored, or replayed on a repeated `event_id`. Also returned on every
            internal failure, with `tier: 0` — your signup flow is never blocked
            by our problems.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RegistrationResponse'
              examples:
                scored:
                  summary: Challenge
                  value:
                    registration_id: reg_4k2m9xqv7...
                    tier: 1
                    score: 0.61
                    reasons:
                      - fresh_domain
                      - device_reuse
                degraded:
                  summary: A reputation lookup we own failed
                  value:
                    registration_id: reg_4k2m9xqv7...
                    tier: 0
                    score: 0.105
                    reasons:
                      - origin_risk
                    degraded:
                      - email_reputation
        '400':
          description: >-
            Malformed JSON or body over 1 MiB (`decode: …`), or a
            missing/unparseable `email` (`a valid email is required`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: a valid email is required
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          description: >-
            Only when no `registration_id` could be minted. Every other internal
            failure fails open with a `200` and `tier: 0`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: internal error
components:
  schemas:
    RegistrationRequest:
      type: object
      required:
        - email
      description: >-
        Every optional field is gated: a field you do not send produces an
        **absent** signal, never a favourable one. No `device_fingerprint` does
        not mean "no device reuse", and no `form` does not mean "a human typed
        it".
      properties:
        email:
          type: string
          description: >-
            The submitted address. The only required field; an unparseable value
            is a `400`.
          example: john.smith+signup@gmail.com
        event_id:
          type: string
          description: >-
            Idempotency key. A repeat of the same `(customer, event_id)` returns
            the **original** `registration_id` and verdict with `duplicate:
            true` and writes nothing. Strongly recommended: without it, a
            response lost in transit makes your retry mint a second registration
            for one real signup.
          example: signup_7f3a91
        ip:
          type: string
          description: The user's browser IP (IPv4 or IPv6) at submit.
          example: 203.0.113.47
        ip_hash:
          type: string
          description: >-
            Customer-keyed token instead of `ip`, same semantics as on
            `/v1/score`. Per-subnet velocity cannot be derived from a token, so
            those signals gate off.
        asn:
          type: integer
          minimum: 0
          maximum: 4294967295
          description: Customer-resolved autonomous system number. `0` means not provided.
          example: 13335
        ip_country:
          type: string
          minLength: 2
          maxLength: 2
          description: Customer-resolved ISO 3166-1 alpha-2 country.
          example: US
        declared_country:
          type: string
          description: >-
            The country the user claimed, if your form collects one. Compared
            against the observed origin.
          example: US
        user_agent:
          type: string
        device_fingerprint:
          type: string
          description: >-
            Your client-side device fingerprint. **The single highest-value
            optional field** — one device across many registrations is the
            strongest farm signal available.
          example: fp_9c1e...
        sensor_token:
          type: string
          description: A token from the browser sensor (`/v1/sensor/collect`), if deployed.
        client:
          $ref: '#/components/schemas/RegistrationClient'
        form:
          $ref: '#/components/schemas/RegistrationForm'
        phone:
          type: string
          description: Optional context, stored and correlated.
        username:
          type: string
          description: Optional context, stored and correlated.
        referrer:
          type: string
          description: Optional context, stored and correlated.
        deadline_ms:
          type: integer
          default: 400
          description: >-
            Whole-call budget in milliseconds. Defaults to `400` and is
            **clamped to `[250, 6000]`** rather than rejected. Lookups that
            don't land in time are absent from this verdict but still complete
            in the background, so the next registration from that domain has
            them. Raise it only if you would rather wait than score a once-seen
            domain without its reputation.
          example: 400
    RegistrationResponse:
      type: object
      required:
        - registration_id
        - tier
        - score
        - reasons
      properties:
        registration_id:
          type: string
          description: >-
            Opaque handle. Store it and pass it back as `registration_id` on
            `POST /v1/identity` when the account is created.
          example: reg_4k2m9xqv7...
        tier:
          type: integer
          minimum: 0
          description: >-
            What to do: `0` allow, `1` challenge (captcha), `2` step up (require
            payment or identity verification). **An open, ordered scale — higher
            means more friction.** New tiers may be added without a new API
            version: compare (`tier >= 2`) rather than switching on an
            exhaustive set, and treat an unrecognised tier as the highest one
            you implement. Pinned to `0` in shadow mode.
          example: 1
        score:
          type: number
          minimum: 0
          maximum: 1
          description: The underlying risk score, for your own tuning.
          example: 0.61
        reasons:
          type: array
          items:
            type: string
          maxItems: 3
          description: Up to three contributing facts, most significant first.
          example:
            - fresh_domain
            - device_reuse
        duplicate:
          type: boolean
          description: Present and `true` on an idempotent replay of an earlier `event_id`.
        shadow_mode:
          type: boolean
          description: >-
            Present and `true` during the warm-up window, when `tier` is pinned
            to `0`. The stored verdict is always the real one.
        degraded:
          type: array
          items:
            type: string
          description: >-
            Present only when a reputation lookup **we** own failed, naming the
            facts (same names as `reasons`) whose evidence was incomplete. Never
            reflects fields you omitted, and never lists lookups skipped because
            `deadline_ms` ran out. The score is not adjusted either way. An open
            set — new names may appear without a new API version.
          example:
            - email_reputation
    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.
    RegistrationClient:
      type: object
      description: >-
        Browser-environment tells. An omitted field is "not reported", which is
        distinct from a reported `false`.
      properties:
        webdriver:
          type: boolean
          description: '`navigator.webdriver`.'
        fingerprint_anomaly:
          type: number
          minimum: 0
          maximum: 1
          description: Your own canvas/WebGL/capability-consistency score.
        load_to_submit_ms:
          type: number
          description: Milliseconds from page load to submit.
        timezone:
          type: string
          description: IANA zone.
          example: America/New_York
    RegistrationForm:
      type: object
      description: >-
        Form-fill telemetry. Omitting the block gates these signals off entirely
        — it is never read as a clean fill.
      properties:
        load_to_submit_ms:
          type: number
          example: 8400
        fields:
          type: object
          description: Per-field fill behaviour, keyed by field name.
          additionalProperties:
            $ref: '#/components/schemas/RegistrationField'
          example:
            email:
              pasted: false
              keystrokes: 22
              corrections: 2
              focus_ms: 3100
    RegistrationField:
      type: object
      properties:
        pasted:
          type: boolean
          description: 'The highest-value bit: scripted fills paste, humans type.'
        keystrokes:
          type: integer
        corrections:
          type: integer
        focus_ms:
          type: number
  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).

````
