> ## Documentation Index
> Fetch the complete documentation index at: https://docs.errorbar.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a reward session

> Register the certified reward for YOUR trainer. The reward is validated first (calibrated, non-drift-flagged, population-bound judges — refused with the reason otherwise), the budget is held in the wallet, and the response carries every judge's signed certificate so the trainer holds the grader's error rate before the first rollout is scored. Optional `anchor`: an independent judge the run is checked against mid-run (POST …/anchor). Requires an owner/admin key with platform:write. errorbar never runs the training — that is what makes the certificate independent.



## OpenAPI

````yaml /openapi.json post /v1/reward/sessions
openapi: 3.1.0
info:
  title: errorbar Management API
  description: >-
    The management API behind the improvement loop: capture and setup, request
    logs and datasets, grades (labels), judges (criteria), evals and deploy
    gates, fine-tuning and reinforcement learning, dedicated GPU endpoints, and
    model aliases and versions. Authenticated with a workspace API key
    (sk_sovereign_...). The inference API (chat, embeddings, rerank, responses)
    is OpenAI-compatible and documented separately.


    Responses are snake_case, list endpoints on the loop products use the
    {"object": "list", "data": [...]} envelope, and refusals use the same nested
    error shape the gateway emits: {"error": {"message", "type", "code"}}.
    Request bodies on the loop products (logs, labels, criteria, evals,
    datasets, aliases) are snake_case; the training and infrastructure products
    (fine-tuning, GRPO, environment tools, dedicated, model-version adoption)
    validate camelCase bodies, and each schema below says which it is. Endpoints
    that spend money require a key minted by a workspace owner or admin and
    return 403 otherwise.
  version: 1.0.0
servers:
  - url: https://gateway.errorbar.ai
    description: Production
  - url: https://www.errorbar.ai/api
    description: Control plane (also served at this base URL)
security:
  - bearerAuth: []
tags:
  - name: Certified reward
    description: >-
      The certified reward for your own trainer: sessions with judge
      certificates, scoring with a ledger-true kill switch, and the mid-run
      anchor that holds a run when the reward diverges from an independent
      judge.
paths:
  /v1/reward/sessions:
    post:
      tags:
        - Certified reward
      summary: Create a reward session
      description: >-
        Register the certified reward for YOUR trainer. The reward is validated
        first (calibrated, non-drift-flagged, population-bound judges — refused
        with the reason otherwise), the budget is held in the wallet, and the
        response carries every judge's signed certificate so the trainer holds
        the grader's error rate before the first rollout is scored. Optional
        `anchor`: an independent judge the run is checked against mid-run (POST
        …/anchor). Requires an owner/admin key with platform:write. errorbar
        never runs the training — that is what makes the certificate
        independent.
      operationId: createRewardSession
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateRewardSession'
      responses:
        '201':
          description: Created, with certificates.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RewardSession'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/InsufficientBalance'
        '403':
          $ref: '#/components/responses/Forbidden'
components:
  schemas:
    CreateRewardSession:
      type: object
      required:
        - reward
        - rewardBudgetUsd
      properties:
        reward:
          $ref: '#/components/schemas/RewardSpec'
        agentic:
          type: boolean
          default: false
          description: >-
            Whole-trajectory rewards need trace-unit judges; single-turn rewards
            need request-unit ones.
        rewardBudgetUsd:
          type: number
          description: >-
            Held in the wallet at creation; released on stop, expiry or
            exhaustion. Max 10000.
        ttlHours:
          type: number
          default: 72
          description: >-
            Session expiry (max 720). Scoring past it is refused and the hold
            released.
        label:
          type: string
          maxLength: 120
        anchor:
          type: object
          properties:
            criterionId:
              type: string
              description: >-
                An INDEPENDENT calibrated judge: a different criterion whose
                model or prompt differs from every reward judge, aligned ≥ 0.9,
                not drift-flagged, same unit.
          required:
            - criterionId
        tasks:
          type: array
          items:
            $ref: '#/components/schemas/RewardTask'
          description: >-
            Optional taskset (≤ 2,000). Stored on the session so `GET
            /v1/reward/sessions/{id}/environment?format=tasks` hands back
            tasks.jsonl.
    RewardSession:
      type: object
      properties:
        id:
          type: string
        status:
          type: string
          enum:
            - ACTIVE
            - COMPLETED
            - OVERBUDGET
            - STOPPED
            - FAILED
          description: >-
            OVERBUDGET: the reward budget's kill switch fired. STOPPED: stopped
            by you or expired.
        agentic:
          type: boolean
        reward:
          $ref: '#/components/schemas/RewardSpec'
        label:
          type:
            - string
            - 'null'
        budget_usd:
          type: number
        spent_usd:
          type: number
          description: Ledger-true judge spend so far.
        expires_at:
          type: string
          format: date-time
        created_at:
          type: string
          format: date-time
        stopped_at:
          type:
            - string
            - 'null'
          format: date-time
        certificates:
          type: array
          items:
            type: object
          description: >-
            One signed judge certificate per reward criterion (see GET
            /v1/criteria/{id}/certificate): sensitivity, specificity, κ with
            intervals, trust, what voids it.
        anchor:
          oneOf:
            - $ref: '#/components/schemas/RewardSessionAnchor'
            - type: 'null'
        task_count:
          type: integer
          description: Tasks stored on the session (0 when the trainer keeps its own).
    RewardSpec:
      oneOf:
        - type: object
          required:
            - mode
            - criterionId
          properties:
            mode:
              type: string
              enum:
                - single
            criterionId:
              type: string
              description: A calibrated judge (TPR and TNR ≥ 0.9, not drift-flagged).
        - type: object
          required:
            - mode
            - criterionIds
          properties:
            mode:
              type: string
              enum:
                - compositional
            criterionIds:
              type: array
              items:
                type: string
              minItems: 2
              description: >-
                Two or more calibrated judges (each ≥ 0.75); the composite grade
                is their mean with any assertions.
            assertions:
              type: array
              items:
                type: object
              description: >-
                Deterministic components (json_schema, regex_match, tool_called,
                exec …), 0/1 each.
    RewardTask:
      type: object
      required:
        - goal
      properties:
        goal:
          type: array
          items:
            type: object
            properties:
              role:
                type: string
              content:
                type: string
          description: The task as chat messages (1..50).
        image:
          type: string
          description: Optional sandbox image.
        verifier:
          type: array
          items:
            type: object
            properties:
              command:
                type: string
              timeout_sec:
                type: integer
          description: >-
            Per-task exec verifiers (≤ 8), run server-side as deterministic
            reward components.
    RewardSessionAnchor:
      type: object
      properties:
        criterion_id:
          type: string
        criterion_name:
          type: string
        held:
          type: boolean
        held_at:
          type:
            - string
            - 'null'
          format: date-time
        held_reason:
          type:
            - string
            - 'null'
        pinned_step:
          type:
            - string
            - 'null'
          description: The step of the best anchor point — the checkpoint to ship.
        checks:
          type: integer
        history:
          type: array
          items:
            $ref: '#/components/schemas/AnchorPoint'
          description: The last 20 checks.
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
              description: >-
                invalid_request_error, insufficient_quota, rate_limit_error, or
                api_error.
            code:
              type: string
              description: >-
                Machine-stable cause, e.g. invalid_api_key, not_found,
                insufficient_permissions, precondition_failed.
          required:
            - message
            - type
            - code
      description: >-
        Every refusal — gateway and management API alike — uses this one
        envelope.
    AnchorPoint:
      type: object
      properties:
        step:
          type: string
        at:
          type: string
          format: date-time
        'n':
          type: integer
          description: Prompts both the reward and the anchor judge could grade.
        reward_rate:
          type: number
          description: >-
            Mean composite grade under the session's reward on the anchor
            outputs — the signal being optimised.
        anchor_rate:
          type: number
          description: >-
            The independent anchor judge's pass rate, corrected for its measured
            error (Lang–Reiczigel) when the criterion carries report counts.
        anchor_ci:
          type: array
          items:
            type: number
          minItems: 2
          maxItems: 2
        anchor_corrected:
          type: boolean
        masked:
          type: integer
          description: Items the anchor judge could not parse — counted in neither rate.
  responses:
    BadRequest:
      description: Malformed request or invalid field.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Missing, malformed, or revoked API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              message: Invalid API key
              type: invalid_request_error
              code: invalid_api_key
    InsufficientBalance:
      description: Your wallet can't cover the required prepaid runway.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              message: >-
                Insufficient balance: deploying this endpoint requires at least
                1h of runway. Top up and try again.
              type: insufficient_quota
              code: insufficient_balance
    Forbidden:
      description: The key lacks the required owner/admin permission.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Your workspace API key, e.g. `sk_sovereign_...`, sent as `Authorization:
        Bearer <key>`.

````