# Account detail

> Stored state, latest score with reasons, a usage rollup over `window`, and model mix for one account.

Stored state, latest score with reasons, a usage rollup, and model mix for one account.

The rollup and model mix cover the `window` parameter (`1h`, `1d`, `7d`, or `30d`;
30 days by default), and the rollup is returned under the `window` key.
`request_count` is lifetime. An account this customer has never sent returns `404`.

> [!NOTE]
>
> `latest_score` is `null` for an account that has only ever sent identity or telemetry
> events and has never been scored. That is different from a low score — don't read a
> missing verdict as a clean one.


## OpenAPI

````yaml openapi.json GET /v1/accounts/{accountId}
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/accounts/{accountId}:
    get:
      tags:
        - Dashboard
      summary: Account detail
      description: >-
        Stored state, latest score with reasons, a usage rollup over `window`,
        and model mix for one account.
      operationId: accountDetail
      parameters:
        - name: accountId
          in: path
          required: true
          schema:
            type: string
          description: >-
            The same `account_id` you send to `/v1/score`. URL-encode it if it
            contains reserved characters.
        - name: window
          in: query
          schema:
            type: string
            enum:
              - 1h
              - 1d
              - 7d
              - 30d
            default: 30d
          description: >-
            Lookback for the `window` usage rollup and `model_mix`. Any other
            value is a 400.
      responses:
        '200':
          description: Account detail
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccountDetail'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: >-
            No such account for this customer (`{"error": "account not
            found"}`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: account not found
        '500':
          $ref: '#/components/responses/InternalError'
components:
  schemas:
    AccountDetail:
      type: object
      properties:
        account_id:
          type: string
          example: user_abc123
        first_seen:
          type: string
          format: date-time
        last_seen:
          type: string
          format: date-time
        subscription_tier:
          type: string
          example: free
          description: >-
            The tier you last sent at `/v1/score`. Unlike the list endpoint this
            is never `null`: an empty string means none was sent.
        request_count:
          type: integer
          example: 5120
          description: >-
            Lifetime count of scored requests for the account. Not affected by
            `window`.
        latest_score:
          $ref: '#/components/schemas/ScoreSummary'
        window:
          type: object
          description: >-
            Post-call usage summed over the selected `window` query parameter
            (default: trailing 30 days). All zeros when there are no events.
          properties:
            events:
              type: integer
              example: 5120
            prompt_tokens:
              type: integer
              example: 1840221
            completion_tokens:
              type: integer
              example: 612043
            inference_cost_usd:
              type: number
              example: 38.42
          required:
            - events
            - prompt_tokens
            - completion_tokens
            - inference_cost_usd
        model_mix:
          type: array
          description: >-
            Post-call event counts per model over the selected `window`
            (default: trailing 30 days). An empty array when there are none;
            events with no model are grouped under `""`. Order is not
            guaranteed.
          items:
            type: object
            properties:
              model:
                type: string
                example: gpt-4o-mini
              count:
                type: integer
                example: 5000
            required:
              - model
              - count
      required:
        - account_id
        - first_seen
        - last_seen
        - subscription_tier
        - request_count
        - latest_score
        - window
        - model_mix
    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.
    ScoreSummary:
      type:
        - object
        - 'null'
      description: >-
        The account's latest score. `null` when the account has never been
        scored.
      properties:
        score:
          type: number
          example: 0.82
        tier:
          type: string
          enum:
            - low
            - medium
            - high
          example: high
          description: Risk tier of the score.
        reasons:
          type:
            - array
            - 'null'
          items:
            type: string
          example:
            - ip_rotation
            - token_velocity_sustained_1h
          description: Reason codes behind the score.
        received_at:
          type: string
          format: date-time
          description: When the score request was received.
        shadow_mode:
          type: boolean
          example: false
          description: >-
            Whether the request was scored during the customer's shadow-mode
            warm-up. The stored score is always the unmasked one.
        deep_mode_active:
          type: boolean
          example: false
      required:
        - score
        - tier
        - reasons
        - received_at
        - shadow_mode
        - deep_mode_active
  responses:
    BadRequest:
      description: >-
        Malformed request: invalid JSON, a body over the size cap, or a query
        parameter outside its allowed values.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    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
    InternalError:
      description: >-
        Server-side failure (e.g. a database error). Read endpoints don't fail
        open.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  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).

````
