# Submit a label

> Report ground truth (`fraud` or `legitimate`) when a reviewer confirms an account. Feeds per-customer retraining. The account doesn't need prior `/v1/score` calls.

Report ground truth when a reviewer confirms an account is `fraud` or `legitimate`.
Labels feed per-customer retraining that supersedes the cold-start scorer.

Training needs **both** classes — a set of `fraud` labels with no `legitimate`
counterparts can't produce a model. Confirming that an investigated account was fine is
as valuable as confirming that it wasn't.

Pass an optional `event_id` to make retries safe; see
[idempotency](https://docs.vectoral.si/api-reference/introduction.md#idempotency).


## OpenAPI

````yaml openapi.json POST /v1/labels
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/labels:
    post:
      tags:
        - Scoring
      summary: Submit a label
      description: >-
        Report ground truth (`fraud` or `legitimate`) when a reviewer confirms
        an account. Feeds per-customer retraining. The account doesn't need
        prior `/v1/score` calls.
      operationId: label
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LabelRequest'
            example:
              account_id: user_abc123
              label: fraud
              notes: chargeback observed; reseller wrapper detected
              event_id: label_5510aa
      responses:
        '200':
          $ref: '#/components/responses/OK'
        '400':
          description: >-
            Malformed JSON or body over 1 MiB (`decode: …`), missing
            `account_id` (`account_id required`), or a `label` other than
            `fraud`/`legitimate` (`label must be "fraud" or "legitimate"`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: label must be "fraud" or "legitimate"
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          description: >-
            Internal error persisting the event. Safe to retry with the same
            `event_id`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: 'persist: <database error>'
components:
  schemas:
    LabelRequest:
      type: object
      required:
        - account_id
        - label
      properties:
        account_id:
          type: string
          example: user_abc123
          description: The account being labelled. Doesn't need prior `/v1/score` calls.
        label:
          type: string
          enum:
            - fraud
            - legitimate
          example: fraud
          description: Exact, lower-case. Any other value returns `400`.
        notes:
          type: string
          example: chargeback observed; reseller wrapper detected
          description: Free-form reviewer context. Stored, not scored.
        event_id:
          type: string
          description: >-
            Optional idempotency key. Repeating the same `(customer, event_id)`
            writes nothing and returns `duplicate: true`.
          example: label_5510aa
    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.
    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
  responses:
    OK:
      description: Success
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/OKResponse'
    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).

````
