VectoralDocsWebsite
API referenceView Markdown

Hydrate account context

Store customer-attested facts about an account — plan, payment method, verification state, chargeback and delinquency history — to be read as trust/risk priors at score time and surfaced during human review.

Writes are merged: a field you omit is left as it is, not cleared, so you can flip one attribute on a billing event without restating the rest. You can also send the same object inline as account.context on /v1/score, which overlays whatever is stored.

An empty string for plan_type or trust_label, or null for a boolean, is treated as omitted — it leaves the stored value in place rather than clearing it.

Tell Vectoral what you already know about an account — plan, payment method, verification state, chargeback and delinquency history. These are read as trust and risk priors at score time, and shown to whoever reviews the account later.

Merge semantics

Writes merge. A field you omit is left as it is, not cleared — so you can flip one attribute on a billing webhook without restating the account's whole context:

bash
curl -X POST https://api.vectoral.cloud/v1/accounts/user_abc123/context \
  -H "Authorization: Bearer vg_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{ "has_payment_method": true }'

An empty string or null is treated as omitted and leaves the stored value unchanged. To correct a boolean, send the opposite value explicitly; to change plan_type or trust_label, send the new value.

Inline instead

The same object can travel inline on /v1/score as account.context, which overlays whatever is stored. Use whichever fits your architecture:

  • Hydrate here when the facts change on their own schedule (billing events, KYC completion) and your scoring path doesn't have them to hand.
  • Send inline when your scoring path already loads the user record anyway.

plan_type and trust_label are matched case-insensitively. free is read the same as unpaid and trial, and allowlist and trusted the same as vip. Other values are stored but ignored in scoring.

OpenAPI

POST/v1/accounts/{accountId}/context

Parameters

NameLocationTypeDescription
accountIdRequiredpathstring

Your stable account id — the same account_id you send on /v1/score. The account is created if it doesn't exist yet.

Request body

FieldTypeDescription
plan_typeOptionalpaid | unpaid | trial | free

Case-insensitive. paid is a trust signal; unpaid, trial and free are risk signals. Any other value is ignored (treated as unknown).

has_payment_methodOptionalboolean

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.

email_verifiedOptionalboolean

true raises trust; false is a risk signal.

identity_verifiedOptionalboolean

KYC or equivalent identity verification. true raises trust.

prior_chargebackOptionalboolean

A prior chargeback or payment dispute. Strong risk signal.

billing_delinquentOptionalboolean

Overdue or failed billing. true is a risk signal.

trust_labelOptionalvip | allowlisted | allowlist | trusted

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.

Response 200

Stored

FieldTypeDescription
okRequiredboolean
duplicateOptionalboolean

Present and true only when the event was already recorded under this event_id and nothing was written. Omitted otherwise.

Response 400

Malformed JSON, an empty body, a wrong field type, or a body over 1 MiB (decode: …).

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

Internal error persisting the context. Writes are merges, so retrying is safe.

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/accounts/{accountId}/context:
    post:
      tags:
        - Scoring
      summary: Hydrate account context
      description: >-
        Store customer-attested facts about an account — plan, payment method,
        verification state, chargeback and delinquency history — to be read as
        trust/risk priors at score time and surfaced during human review.


        Writes are **merged**: a field you omit is left as it is, not cleared,
        so you can flip one attribute on a billing event without restating the
        rest. You can also send the same object inline as `account.context` on
        `/v1/score`, which overlays whatever is stored.


        An empty string for `plan_type` or `trust_label`, or `null` for a
        boolean, is treated as omitted — it leaves the stored value in place
        rather than clearing it.
      operationId: accountContext
      parameters:
        - name: accountId
          in: path
          required: true
          schema:
            type: string
          example: user_abc123
          description: >-
            Your stable account id — the same `account_id` you send on
            `/v1/score`. The account is created if it doesn't exist yet.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AccountContext'
            example:
              plan_type: paid
              has_payment_method: true
              email_verified: true
      responses:
        '200':
          description: Stored
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OKResponse'
              example:
                ok: true
        '400':
          description: >-
            Malformed JSON, an empty body, a wrong field type, or a body over 1
            MiB (`decode: …`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: 'decode: EOF'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          description: >-
            Internal error persisting the context. Writes are merges, so
            retrying is safe.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: 'persist: <database error>'
components:
  schemas:
    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
    OKResponse:
      type: object
      properties:
        ok:
          type: boolean
          example: true
        duplicate:
          type: boolean
          description: >-
            Present and `true` only when the event was already recorded under
            this `event_id` and nothing was written. Omitted otherwise.
          example: true
      required:
        - ok
    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.
  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.