> ## 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 a past evaluation

> Reads only. Returns an evaluation of this organization and the key's environment, including assignment_mode and content: {state, attribute_values?} when inputs were stored, or content: null when they were not (store_state: false). A submitted JSON null is content: {state: null}; another environment's evaluation is 404, so a test key never reads production traffic. The web app (WebApi) may not read evaluations (403): a blind spot-check card carries the id.



## OpenAPI

````yaml /openapi.json get /v1/evaluations/{evaluation_id}
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 seed 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`). 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/evaluations/{evaluation_id}:
    get:
      tags:
        - evaluate
      summary: Get a past evaluation
      description: >-
        Reads only. Returns an evaluation of this organization and the key's
        environment, including assignment_mode and content: {state,
        attribute_values?} when inputs were stored, or content: null when they
        were not (store_state: false). A submitted JSON null is content: {state:
        null}; another environment's evaluation is 404, so a test key never
        reads production traffic. The web app (WebApi) may not read evaluations
        (403): a blind spot-check card carries the id.
      operationId: getEvaluation
      parameters:
        - schema:
            $ref: '#/components/schemas/EvlId'
          required: true
          name: evaluation_id
          in: path
      responses:
        '200':
          description: The evaluation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EvaluationResponse'
        '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:evaluate
components:
  schemas:
    EvlId:
      type: string
      pattern: >-
        ^evl_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
    EvaluationResponse:
      oneOf:
        - type: object
          properties:
            environment:
              $ref: '#/components/schemas/Environment'
            id:
              $ref: '#/components/schemas/EvlIdOutput'
            answers:
              type: object
              additionalProperties:
                $ref: '#/components/schemas/NoulAnswer'
              description: Each question's answer, as System One returns it.
            aggregations:
              type: object
              additionalProperties:
                $ref: '#/components/schemas/AggregationResult'
            via:
              type: string
              description: >-
                A zero-based rule index, `cases.<label>` for an exact matched
                case, or `else` for the fallback.
            moonbounce:
              type: object
              properties:
                decision_id:
                  $ref: '#/components/schemas/DecisionIdOutput'
                item_id:
                  type: string
                structure_hash:
                  $ref: '#/components/schemas/StructureHashOutput'
                metadata:
                  $ref: '#/components/schemas/MetadataOutput'
                summary:
                  type: string
              required:
                - decision_id
                - item_id
                - structure_hash
              additionalProperties: true
              x-moonbounce-sdk-known-fields: true
            version:
              type: object
              properties:
                structure_hash:
                  $ref: '#/components/schemas/StructureHashOutput'
                binding:
                  type: integer
                  minimum: 1
                engine_profile:
                  type: string
              required:
                - structure_hash
                - binding
                - engine_profile
              additionalProperties: true
              x-moonbounce-sdk-known-fields: true
            engines:
              type: object
              additionalProperties:
                $ref: '#/components/schemas/EngineUse'
            usage:
              $ref: '#/components/schemas/Usage'
            cost:
              type: object
              properties:
                engine_calls:
                  type: integer
                  minimum: 0
                  description: >-
                    On evaluate and seeds, upstream engine calls reported in
                    usage, including retries; one call can answer several
                    features (Jev compiles them). On previews, features sent to
                    engines, not upstream calls.
                cache_hits:
                  type: integer
                  minimum: 0
                  description: >-
                    Feature answers reused from cache. Only previews use the
                    cache today; evaluate and seeds report 0.
                input_tokens:
                  type: integer
                  minimum: 0
                usd_micros:
                  type: integer
                  minimum: 0
              required:
                - engine_calls
                - cache_hits
                - input_tokens
                - usd_micros
              additionalProperties: true
              description: absent if no spend was recorded for this evaluation
              x-moonbounce-sdk-known-fields: true
            calls:
              type: array
              items:
                $ref: '#/components/schemas/EvaluateCallCost'
            assignment_mode:
              $ref: '#/components/schemas/AssignmentModeOutput'
            content:
              anyOf:
                - $ref: '#/components/schemas/EvaluationContent'
                - type: 'null'
            status:
              type: string
              enum:
                - computed
            value:
              type: number
            outcome:
              not: {}
              description: 'Must be absent: a computed result is a number, with no outcome.'
              x-moonbounce-absent: true
            missing:
              type: array
              items:
                $ref: '#/components/schemas/FeatureRefOutput'
              description: >-
                The questions the result depends on (through `result` and every
                aggregation on its path) that have no answer, abstained or
                failed, as `questions.x` paths in authored question order.
                Absent when none is missing; reported for every status. A caller
                who must not act on partial evidence checks that it is absent,
                for example `status === "decided" && !missing`.
          required:
            - environment
            - id
            - answers
            - aggregations
            - moonbounce
            - version
            - engines
            - usage
            - assignment_mode
            - content
            - status
            - value
          additionalProperties: true
          x-moonbounce-sdk-known-fields: true
        - type: object
          properties:
            environment:
              $ref: '#/components/schemas/Environment'
            id:
              $ref: '#/components/schemas/EvlIdOutput'
            answers:
              type: object
              additionalProperties:
                $ref: '#/components/schemas/NoulAnswer'
              description: Each question's answer, as System One returns it.
            aggregations:
              type: object
              additionalProperties:
                $ref: '#/components/schemas/AggregationResult'
            via:
              type: string
              description: >-
                A zero-based rule index, `cases.<label>` for an exact matched
                case, or `else` for the fallback.
            moonbounce:
              type: object
              properties:
                decision_id:
                  $ref: '#/components/schemas/DecisionIdOutput'
                item_id:
                  type: string
                structure_hash:
                  $ref: '#/components/schemas/StructureHashOutput'
                metadata:
                  $ref: '#/components/schemas/MetadataOutput'
                summary:
                  type: string
              required:
                - decision_id
                - item_id
                - structure_hash
              additionalProperties: true
              x-moonbounce-sdk-known-fields: true
            version:
              type: object
              properties:
                structure_hash:
                  $ref: '#/components/schemas/StructureHashOutput'
                binding:
                  type: integer
                  minimum: 1
                engine_profile:
                  type: string
              required:
                - structure_hash
                - binding
                - engine_profile
              additionalProperties: true
              x-moonbounce-sdk-known-fields: true
            engines:
              type: object
              additionalProperties:
                $ref: '#/components/schemas/EngineUse'
            usage:
              $ref: '#/components/schemas/Usage'
            cost:
              type: object
              properties:
                engine_calls:
                  type: integer
                  minimum: 0
                  description: >-
                    On evaluate and seeds, upstream engine calls reported in
                    usage, including retries; one call can answer several
                    features (Jev compiles them). On previews, features sent to
                    engines, not upstream calls.
                cache_hits:
                  type: integer
                  minimum: 0
                  description: >-
                    Feature answers reused from cache. Only previews use the
                    cache today; evaluate and seeds report 0.
                input_tokens:
                  type: integer
                  minimum: 0
                usd_micros:
                  type: integer
                  minimum: 0
              required:
                - engine_calls
                - cache_hits
                - input_tokens
                - usd_micros
              additionalProperties: true
              description: absent if no spend was recorded for this evaluation
              x-moonbounce-sdk-known-fields: true
            calls:
              type: array
              items:
                $ref: '#/components/schemas/EvaluateCallCost'
            assignment_mode:
              $ref: '#/components/schemas/AssignmentModeOutput'
            content:
              anyOf:
                - $ref: '#/components/schemas/EvaluationContent'
                - type: 'null'
            status:
              type: string
              enum:
                - decided
            value:
              type: number
            outcome:
              $ref: '#/components/schemas/Outcome'
            missing:
              type: array
              items:
                $ref: '#/components/schemas/FeatureRefOutput'
              description: >-
                The questions the result depends on (through `result` and every
                aggregation on its path) that have no answer, abstained or
                failed, as `questions.x` paths in authored question order.
                Absent when none is missing; reported for every status. A caller
                who must not act on partial evidence checks that it is absent,
                for example `status === "decided" && !missing`.
          required:
            - environment
            - id
            - answers
            - aggregations
            - moonbounce
            - version
            - engines
            - usage
            - assignment_mode
            - content
            - status
            - outcome
          additionalProperties: true
          x-moonbounce-sdk-known-fields: true
        - type: object
          properties:
            environment:
              $ref: '#/components/schemas/Environment'
            id:
              $ref: '#/components/schemas/EvlIdOutput'
            answers:
              type: object
              additionalProperties:
                $ref: '#/components/schemas/NoulAnswer'
              description: Each question's answer, as System One returns it.
            aggregations:
              type: object
              additionalProperties:
                $ref: '#/components/schemas/AggregationResult'
            via:
              type: string
              description: >-
                A zero-based rule index, `cases.<label>` for an exact matched
                case, or `else` for the fallback.
            moonbounce:
              type: object
              properties:
                decision_id:
                  $ref: '#/components/schemas/DecisionIdOutput'
                item_id:
                  type: string
                structure_hash:
                  $ref: '#/components/schemas/StructureHashOutput'
                metadata:
                  $ref: '#/components/schemas/MetadataOutput'
                summary:
                  type: string
              required:
                - decision_id
                - item_id
                - structure_hash
              additionalProperties: true
              x-moonbounce-sdk-known-fields: true
            version:
              type: object
              properties:
                structure_hash:
                  $ref: '#/components/schemas/StructureHashOutput'
                binding:
                  type: integer
                  minimum: 1
                engine_profile:
                  type: string
              required:
                - structure_hash
                - binding
                - engine_profile
              additionalProperties: true
              x-moonbounce-sdk-known-fields: true
            engines:
              type: object
              additionalProperties:
                $ref: '#/components/schemas/EngineUse'
            usage:
              $ref: '#/components/schemas/Usage'
            cost:
              type: object
              properties:
                engine_calls:
                  type: integer
                  minimum: 0
                  description: >-
                    On evaluate and seeds, upstream engine calls reported in
                    usage, including retries; one call can answer several
                    features (Jev compiles them). On previews, features sent to
                    engines, not upstream calls.
                cache_hits:
                  type: integer
                  minimum: 0
                  description: >-
                    Feature answers reused from cache. Only previews use the
                    cache today; evaluate and seeds report 0.
                input_tokens:
                  type: integer
                  minimum: 0
                usd_micros:
                  type: integer
                  minimum: 0
              required:
                - engine_calls
                - cache_hits
                - input_tokens
                - usd_micros
              additionalProperties: true
              description: absent if no spend was recorded for this evaluation
              x-moonbounce-sdk-known-fields: true
            calls:
              type: array
              items:
                $ref: '#/components/schemas/EvaluateCallCost'
            assignment_mode:
              $ref: '#/components/schemas/AssignmentModeOutput'
            content:
              anyOf:
                - $ref: '#/components/schemas/EvaluationContent'
                - type: 'null'
            status:
              type: string
              enum:
                - abstained
            value:
              not: {}
              description: 'Must be absent: an abstained result has no value.'
              x-moonbounce-absent: true
            outcome:
              $ref: '#/components/schemas/Outcome'
            missing:
              type: array
              items:
                $ref: '#/components/schemas/FeatureRefOutput'
              description: >-
                The questions the result depends on (through `result` and every
                aggregation on its path) that have no answer, abstained or
                failed, as `questions.x` paths in authored question order.
                Absent when none is missing; reported for every status. A caller
                who must not act on partial evidence checks that it is absent,
                for example `status === "decided" && !missing`.
          required:
            - environment
            - id
            - answers
            - aggregations
            - moonbounce
            - version
            - engines
            - usage
            - assignment_mode
            - content
            - status
          additionalProperties: true
          x-moonbounce-sdk-known-fields: true
    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
    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.
    EvlIdOutput:
      type: string
      pattern: >-
        ^evl_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
    NoulAnswer:
      anyOf:
        - type: object
          properties:
            type:
              type: string
              enum:
                - noul
            noul:
              type: number
              minimum: 0
              maximum: 1
          required:
            - type
            - noul
          additionalProperties: true
          x-moonbounce-sdk-known-fields: true
        - type: object
          properties:
            type:
              type: string
              enum:
                - noul
            abstained:
              type: boolean
              enum:
                - true
          required:
            - type
            - abstained
          additionalProperties: true
          x-moonbounce-sdk-known-fields: true
        - type: object
          properties:
            type:
              type: string
              enum:
                - noul
            failed:
              type: boolean
              enum:
                - true
          required:
            - type
            - failed
          additionalProperties: true
          x-moonbounce-sdk-known-fields: true
      description: P(true), or why there is no answer.
    AggregationResult:
      type: object
      properties:
        type:
          type: string
        value:
          type: number
        outcome:
          $ref: '#/components/schemas/Outcome'
        via:
          type: string
          description: >-
            A zero-based rule index, `cases.<label>` for an exact matched case,
            or `else` for the fallback.
        missing:
          type: array
          items:
            $ref: '#/components/schemas/FeatureRefOutput'
          description: >-
            weighted_mean only: the inputs dropped for having no answer, as
            written (`questions.x`).
        abstained:
          type: boolean
          enum:
            - true
      required:
        - type
      additionalProperties: true
      description: >-
        An aggregation's value. `value` for numbers (for bands, the input it
        cut); `outcome` for bands, rules and match; `via` is the zero-based rule
        index, `cases.<label>` for a matched case, or `else` for the fallback;
        `abstained` when unknown.
      x-moonbounce-sdk-known-fields: true
    DecisionIdOutput:
      type: string
      pattern: ^[a-z][a-z0-9_.-]{0,127}$
    StructureHashOutput:
      type: string
      pattern: ^sha256:[0-9a-f]{64}$
    MetadataOutput:
      type: object
      additionalProperties:
        anyOf:
          - type: string
            maxLength: 512
          - type: number
          - type: boolean
          - type: 'null'
      description: >-
        Caller key-values, stored with the evaluation and never shown to the
        model. Keys starting `mb.` are reserved for Moonbounce provenance:
        `mb.commit`, `mb.branch`, `mb.service` and `mb.release`, which say where
        a call came from.
    EngineUse:
      type: object
      properties:
        engine:
          type: string
        model:
          type: string
        resolved_model:
          type: string
        adapter:
          type: string
        cached:
          type: boolean
      required:
        - engine
        - model
        - resolved_model
        - adapter
        - cached
      additionalProperties: true
      x-moonbounce-sdk-known-fields: true
    Usage:
      type: object
      properties:
        input_tokens:
          type: integer
        output_tokens:
          type: integer
      required:
        - input_tokens
        - output_tokens
      additionalProperties: true
      x-moonbounce-sdk-known-fields: true
    EvaluateCallCost:
      type: object
      properties:
        questions:
          type: array
          items:
            $ref: '#/components/schemas/NameOutput'
        reads:
          type: array
          items:
            $ref: '#/components/schemas/StatePathOutput'
          description: >-
            The paths sent, as the questions wrote them (`state.message`);
            absent when the whole state was.
        input_tokens:
          type: integer
          minimum: 0
      required:
        - questions
      additionalProperties: true
      description: One upstream System One call.
      x-moonbounce-sdk-known-fields: true
    AssignmentModeOutput:
      type: string
      enum:
        - primary
        - shadow
        - backtest
        - seed
    EvaluationContent:
      type: object
      properties:
        state:
          description: The state as submitted, including JSON null.
        attribute_values:
          $ref: '#/components/schemas/AttributeValues'
      required:
        - state
      additionalProperties: true
      description: >-
        Stored inputs. A null content wrapper means inputs were not stored;
        state:null inside the wrapper is a submitted JSON null.
      x-moonbounce-sdk-known-fields: true
    FeatureRefOutput:
      type: string
      minLength: 1
      maxLength: 80
      description: >-
        A feature's path: `questions.<name>`, `attributes.<name>` or
        `aggregations.<name>`.
      examples:
        - questions.asks_for_refund
        - aggregations.band
    Outcome:
      type: string
      minLength: 1
      maxLength: 200
      description: >-
        An outcome name, or the exact enum label when a string attribute is the
        result.
    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
    NameOutput:
      type: string
      pattern: ^[a-z][a-z0-9_]{0,63}$
    StatePathOutput:
      type: string
      minLength: 1
      maxLength: 256
      description: >-
        `state.<key>` or a nested object path such as
        `state.order.customer.tier`: keys of an object `state`. A key has no
        `.`, `[` or `]`. Array indexes are not supported yet.
      examples:
        - state.message
        - state.order.order_total_usd
    AttributeValues:
      type: object
      additionalProperties:
        anyOf:
          - type: string
            maxLength: 200
          - type: number
          - type: boolean
  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.