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

# Get what a decision optimizes for

> The decision's current objective revision in the calling key's environment: which mistakes matter and how much, and its target. `revision` and `objective` are null when none was set, which means balanced losses. Previews are judged by it (`loss_report`). Compare `objective_hash` with the decision file's objective to see whether the stored copy is current. 404 when the decision doesn't exist (no structure registered or evaluated).



## OpenAPI

````yaml /openapi.json get /v1/decisions/{decision_id}/objective
openapi: 3.1.0
info:
  title: Moonbounce Decisions API
  version: 0.0.0
  description: >-
    Moonbounce decisions: evaluate an item's state against a decision structure
    (System One questions, attributes you supply and aggregations over both),
    record feedback and import labeled examples, review a ranked queue, and
    improve the structure through suggestions that ship as code diffs, each with
    a preview (backtest) and an evidence label.


    **Authentication.** Send an API key as `Authorization: Bearer <key>` on
    every operation except `GET /health` and `POST /v1/structures/hash`. Call
    the API from a server, never a browser: a key must not reach one, and the
    API sends no CORS headers. A key belongs to one organization and one
    environment: production, or test for a key with the `env:test` permission.
    Test traffic never counts as production traffic.


    **Requests.** JSON bodies (`Content-Type: application/json`) of at most 1
    MB, parsed strictly: duplicate keys, lone surrogates, integers outside
    ±(2^53 - 1), `__proto__` keys, U+0000 and nesting deeper than 64 are a 400.


    **Retries.** Send an `Idempotency-Key` on every POST under /v1 that takes
    one (all but `POST /v1/structures/hash` and `POST /v1/review/items/fill`,
    whose retry is another fill within the day's budget). Keep it for the
    request's retries. The same key with the same request returns the first
    stored result, marked `Idempotent-Replayed: true`, for 24 hours (410 if that
    result was since deleted); with another request it is 422
    IDEMPOTENCY_KEY_REUSED. Keys are scoped to the organization and environment
    across every operation, so use a fresh key per request. A request that
    failed before its result was stored runs again when retried. 429 and 503
    under /v1 may carry `Retry-After` (seconds); a daily QUOTA_EXCEEDED cap
    instead names its reset time.


    **Errors.** Every error under /v1 is `{"error": {"type", "message",
    "reason"?, "param"?, "details"?}}` (ErrorBody); `GET /health` answers its
    own shape. Every response carries a `Request-Id` header. Rate limits apply
    per key, and per client IP for requests without a valid key; a 429
    RATE_LIMITED carries `Retry-After`.
servers:
  - url: https://api.moonbounce.ai
    description: Production
security: []
paths:
  /v1/decisions/{decision_id}/objective:
    get:
      tags:
        - objective
      summary: Get what a decision optimizes for
      description: >-
        The decision's current objective revision in the calling key's
        environment: which mistakes matter and how much, and its target.
        `revision` and `objective` are null when none was set, which means
        balanced losses. Previews are judged by it (`loss_report`). Compare
        `objective_hash` with the decision file's objective to see whether the
        stored copy is current. 404 when the decision doesn't exist (no
        structure registered or evaluated).
      operationId: getObjective
      parameters:
        - schema:
            $ref: '#/components/schemas/DecisionId'
          required: true
          name: decision_id
          in: path
      responses:
        '200':
          description: The current objective
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DecisionObjective'
        '400':
          description: 'Invalid request: `param` names the field at fault when one applies'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '401':
          description: Missing or invalid API key (reason KEY_INVALID)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '403':
          description: The key may not do this
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '404':
          description: Not found, or not in this key's organization and environment
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '429':
          description: >-
            RATE_LIMITED: retry after Retry-After seconds; QUOTA_EXCEEDED:
            details.reset_at gives the daily reset time (no Retry-After)
          headers:
            Retry-After:
              schema:
                type: string
                description: Seconds to wait before retrying, when waiting helps.
              required: false
              description: Seconds to wait before retrying, when waiting helps.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
        '503':
          description: >-
            Temporarily unavailable, with Retry-After (for example reason
            AUTH_UNAVAILABLE, ENGINE_UNAVAILABLE or STORE_UNAVAILABLE): retry
            with the same Idempotency-Key
          headers:
            Retry-After:
              schema:
                type: string
                description: Seconds to wait before retrying, when waiting helps.
              required: true
              description: Seconds to wait before retrying, when waiting helps.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBody'
      security:
        - bearerAuth:
            - decisions:develop
components:
  schemas:
    DecisionId:
      type: string
      pattern: ^[a-z][a-z0-9_.-]{0,127}$
    DecisionObjective:
      type: object
      properties:
        decision_id:
          $ref: '#/components/schemas/DecisionIdOutput'
        environment:
          $ref: '#/components/schemas/Environment'
        revision:
          type:
            - integer
            - 'null'
          minimum: 1
          description: >-
            The objective revision. Null when none was ever set here, which
            means balanced losses.
        objective:
          type:
            - object
            - 'null'
          properties:
            fallback:
              type: string
              minLength: 1
              maxLength: 200
              description: >-
                The safe outcome. Sending a case there when it belonged
                elsewhere is `minor`, unless that mistake is listed.
            mistakes:
              type: array
              items:
                $ref: '#/components/schemas/ObjectiveMistakeOutput'
              maxItems: 400
            target:
              type: object
              properties:
                max_loss_per_case:
                  type: number
                  minimum: 0
                  description: The loss per case at which the decision is good enough.
              required:
                - max_loss_per_case
              additionalProperties: true
              description: >-
                Optional. The refine loop stops when the loss per case reaches
                it; without one, the owner decides.
              x-moonbounce-sdk-known-fields: true
            outcome:
              type: string
              minLength: 1
              maxLength: 200
              description: 'With `priority`: the outcome the two-outcome shortcut is about.'
            priority:
              type: string
              enum:
                - catch_all
                - be_sure
                - balanced
              description: >-
                With `outcome`, the shortcut: `catch_all` makes missing
                `outcome` costly and a false alarm normal, `be_sure` the
                reverse, `balanced` both normal. A listed mistake overrides the
                shortcut's entry for it.
          additionalProperties: true
          description: >-
            The stored objective. Null means balanced losses: each outcome's
            mistakes weigh the same in total.
          x-moonbounce-sdk-known-fields: true
        objective_hash:
          type:
            - string
            - 'null'
          description: >-
            The objective's hash, as loop status and previews report it. Null
            with `objective`. Compare it with the decision file's to see drift.
        unknown_outcomes:
          type: array
          items:
            type: string
          description: >-
            Outcomes the objective names that the decision's most recently
            registered structure can't produce. Their entries will be left out
            of scoring; check for a typo or a renamed outcome. Empty when that
            structure's result is a value, with no outcomes to check against.
        created_at:
          type:
            - string
            - 'null'
          format: date-time
      required:
        - decision_id
        - environment
        - revision
        - objective
        - objective_hash
        - unknown_outcomes
        - created_at
    ErrorBody:
      type: object
      properties:
        error:
          type: object
          properties:
            type:
              $ref: '#/components/schemas/ErrorType'
            reason:
              type: string
              pattern: ^[A-Z][A-Z0-9_]+$
              description: >-
                Set where a caller can act on it, one of the reasons in the
                ErrorReason schema. New reasons may be added: treat an unknown
                one by the status and `type`.
            message:
              type: string
              description: For people; don't parse it.
            param:
              type: string
              description: >-
                The request field at fault, as a dotted path
                (`attribute_values.region`, `claims.1.value`).
            details:
              type: object
              properties:
                issues:
                  type: array
                  items:
                    $ref: '#/components/schemas/ErrorIssue'
              additionalProperties: {}
          required:
            - type
            - message
          additionalProperties: true
          x-moonbounce-sdk-known-fields: true
      required:
        - error
      additionalProperties: true
      x-moonbounce-sdk-known-fields: true
    DecisionIdOutput:
      type: string
      pattern: ^[a-z][a-z0-9_.-]{0,127}$
    Environment:
      type: string
      enum:
        - production
        - test
      description: >-
        The environment of the key that made the call: `production` or `test`.
        Evaluations, feedback, reviews and suggestions are separate per
        environment; registered structures are shared.
    ObjectiveMistakeOutput:
      anyOf:
        - type: object
          properties:
            expected:
              type: string
              minLength: 1
              maxLength: 200
              description: The outcome the case should have had.
            got:
              type: string
              minLength: 1
              maxLength: 200
              description: The outcome the decision gave instead.
            severity:
              $ref: '#/components/schemas/SeverityOutput'
          required:
            - expected
            - got
            - severity
          additionalProperties: true
          x-moonbounce-sdk-known-fields: true
        - type: object
          properties:
            expected:
              type: string
              minLength: 1
              maxLength: 200
              description: The outcome the case should have had.
            got:
              type: string
              minLength: 1
              maxLength: 200
              description: The outcome the decision gave instead.
            loss:
              type: number
              minimum: 0
              maximum: 1000000
              description: >-
                A direct loss in place of a severity. At least 10 counts as
                severe.
          required:
            - expected
            - got
            - loss
          additionalProperties: true
          x-moonbounce-sdk-known-fields: true
      description: >-
        One mistake that matters, by severity or by a direct loss. A mistake
        that isn't listed is `normal`.
    ErrorType:
      type: string
      enum:
        - invalid_request
        - authentication
        - permission_denied
        - not_found
        - conflict
        - rate_limited
        - engine_failed
        - unavailable
        - internal
    ErrorIssue:
      type: object
      properties:
        param:
          type: string
        code:
          type: string
          pattern: ^[A-Z][A-Z0-9_]+$
          description: >-
            Stable, extensible issue code; unknown codes still have a parameter
            and human-readable message.
        message:
          type: string
      required:
        - param
        - code
        - message
      additionalProperties: true
      x-moonbounce-sdk-known-fields: true
    SeverityOutput:
      type: string
      enum:
        - minor
        - normal
        - costly
        - severe
      description: >-
        How bad a mistake is: `minor` weighs 0.5, `normal` 1, `costly` 3 and
        `severe` 10.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        An API key, sent as `Authorization: Bearer <key>`. Each operation lists
        the scope its key needs: `decisions:evaluate` (evaluate and read
        evaluations), `decisions:feedback` (your app's feedback) or
        `decisions:develop` (everything else, including owner feedback and the
        review queue). An operation listing no scope takes any scoped key. A key
        with no scope, or without the operation's, gets 403 INSUFFICIENT_SCOPE.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.