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

# Make a decision

> Runs the live version of the decision (or `options.version`) on `input`.



## OpenAPI

````yaml /openapi.yaml post /decide/{slug}
openapi: 3.1.0
info:
  title: Branch Pilot API
  version: '1.0'
  summary: The AI decision layer for workflows.
  description: >
    One endpoint per decision. Send the input your decision expects, get a typed
    answer with

    calibrated probabilities, a confidence and the engine that produced it.


    Personal data in declared PII fields (and detected in free text) is
    pseudonymized before

    any model call; only the pseudonymized input is logged.
  contact:
    email: hello@branchpilot.ai
  termsOfService: https://branchpilot.ai/terms
servers:
  - url: https://api.branchpilot.ai/v1
    description: Production
security:
  - apiKey: []
tags:
  - name: Decide
  - name: Runs
  - name: Decisions
paths:
  /decide/{slug}:
    post:
      tags:
        - Decide
      summary: Make a decision
      description: Runs the live version of the decision (or `options.version`) on `input`.
      operationId: decide
      parameters:
        - $ref: '#/components/parameters/slug'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DecideRequest'
            examples:
              route:
                value:
                  input:
                    email: anna@acme.com
                    message: Could we get a quote for 40 seats?
      responses:
        '200':
          description: The decision.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DecideResponse'
              examples:
                route:
                  value:
                    run_id: 3f0b2c1e-6c1d-4a1e-9f3a-8a1b2c3d4e5f
                    decision: lead-routing
                    version: 3
                    status: ok
                    choice: sales
                    probabilities:
                      sales: 0.87
                      support: 0.09
                      spam: 0.04
                    confidence: 0.87
                    confidence_source: calibrated
                    engine: jev
                    model: jev-1.13.0
                    latency_ms: 212
                    pii_redacted: 1
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: The decision has no published version.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '413':
          description: Body larger than 128 KB.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: >-
            Monthly quota reached. `Retry-After` gives the seconds until the
            next period.
          headers:
            Retry-After:
              schema:
                type: integer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '502':
          description: No engine could answer; `details` lists the attempts.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  parameters:
    slug:
      name: slug
      in: path
      required: true
      description: Slug of the decision, as shown in the app.
      schema:
        type: string
        pattern: ^[a-z0-9]+(-[a-z0-9]+)*$
        example: lead-routing
  schemas:
    DecideRequest:
      type: object
      required:
        - input
      properties:
        input:
          description: >-
            The payload to decide on. A JSON object matching the declared
            fields, or free text.
          oneOf:
            - type: object
            - type: string
            - type: array
        options:
          type: object
          properties:
            version:
              type: integer
              minimum: 1
              description: Run this version instead of the live one.
            engine:
              type: string
              enum:
                - jev
                - llm
              description: Force an engine for this call.
    DecideResponse:
      type: object
      required:
        - run_id
        - decision
        - version
        - status
        - probabilities
        - confidence
        - engine
        - model
        - latency_ms
        - pii_redacted
      properties:
        run_id:
          type: string
          format: uuid
        decision:
          type: string
        version:
          type: integer
        status:
          type: string
          enum:
            - ok
            - uncertain
            - pending
          description: >-
            `uncertain`: confidence below the decision threshold. `pending`:
            sent to the human review queue.
        choice:
          type: string
          description: Route decisions. `__uncertain__` when status is `uncertain`.
        score:
          type: number
          minimum: 0
          maximum: 100
          description: Score decisions, remapped to 0–100.
        raw_score:
          type: number
          description: Score decisions, weighted position on the 0..N-1 level scale.
        legend:
          type: object
          additionalProperties:
            type: string
          description: Score decisions, level index → label.
        labels:
          type: array
          items:
            type: string
          description: >-
            Classify decisions, labels whose probability reached their
            threshold.
        probabilities:
          type: object
          additionalProperties:
            type: number
        confidence:
          type: number
          minimum: 0
          maximum: 1
        confidence_source:
          type: string
          enum:
            - calibrated
            - self_reported
        engine:
          type: string
          enum:
            - jev
            - llm_fallback
        model:
          type: string
        latency_ms:
          type: integer
        pii_redacted:
          type: integer
          description: >-
            Number of personal-data substitutions performed before the model
            call.
        fallback_reason:
          type: string
          description: >-
            Present when the LLM fallback answered; why the primary engine did
            not.
        review_url:
          type: string
          format: uri
          description: Present when status is `pending`.
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
            message:
              type: string
            details: {}
  responses:
    BadRequest:
      description: Invalid JSON, or input does not match the declared fields.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Missing, invalid or revoked API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Unknown resource.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: An API key created in Settings → API keys (`bp_live_…` or `bp_test_…`).

````