openapi: 3.0.3
info:
  title: Briefcase AI - Agent Observability Platform API
  description: 'Comprehensive API for integrating AI agent observability, monitoring, and optimization.


    ## REST ingestion (API key)

    `POST /api/ingest/telemetry` and `POST /api/ingest/batch` record agent runs. Authenticate with an
    API key (prefix `bca_`) in the Authorization header:

    ```

    Authorization: Bearer bca_your_api_key

    ```

    Units: `latency` in milliseconds, `cost` in US dollars, `accuracy` as a 0-100 percentage.


    ## tRPC procedures

    The `/api/trpc/*` paths are tRPC procedures used by the web app. Request payloads are wrapped in a
    `json` key. `ingest.telemetry` and `ingest.batch` take the API key as an `apiKey` field in the body;
    most other procedures require a signed-in browser session rather than an API key.


    ## Rate limits

    Ingestion is rate limited per API key. A request over the limit receives `429` with a `Retry-After`
    header (seconds).

    '
  version: 2.0.0
  contact:
    name: Briefcase AI Support
    url: https://observe.briefcasebrain.io/support
    email: support@briefcasebrain.com
  license:
    name: Proprietary
    url: https://observe.briefcasebrain.io/terms
servers:
- url: https://observe.briefcasebrain.io
  description: Production server
- url: http://localhost:3000
  description: Local development server
security:
- BearerAuth: []
tags:
- name: Telemetry
  description: Real-time agent telemetry ingestion and monitoring
- name: Data Retention
  description: Manage data retention policies and cleanup operations
- name: Agent Runs
  description: Track and analyze AI agent execution runs
- name: Benchmarks
  description: Performance benchmarking and comparison
- name: Validation
  description: Real-time telemetry validation with JSON Schema
- name: Webhooks
  description: Configure webhook notifications
paths:
  /api/ingest/telemetry:
    post:
      tags:
      - Telemetry
      summary: Ingest one agent run (REST)
      description: 'Record a single agent run. Authenticate with `Authorization: Bearer <api key>`; keys
        start with `bca_`.'
      operationId: restIngestTelemetry
      security:
      - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/IngestRun'
            example:
              agentId: 1
              status: success
              latency: 1250
              cost: 0.04
              accuracy: 95
              inputData: Analyze quarterly sales data
              outputData: Sales increased 15% YoY
              metadata:
                model: gpt-4o
                temperature: 0.7
      responses:
        '200':
          description: Run stored
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  runId:
                    type: integer
                    example: 1024
                  message:
                    type: string
                    example: Telemetry data ingested successfully
                  duplicate:
                    type: boolean
                    description: True when the idempotency key was already ingested
                    example: false
        '400':
          description: Validation error (missing or invalid agentId, status, latency or cost)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IngestError'
        '403':
          description: Agent not found or not owned by the API key's account, or the API key is read-only
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IngestError'
        '401':
          description: Missing/malformed Authorization header, or invalid, revoked or expired API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IngestError'
        '429':
          description: Rate limit exceeded for this API key. Retry after the number of seconds in the
            Retry-After header.
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before retrying
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IngestError'
        '413':
          description: Request body exceeds the server's size limit
      parameters:
      - name: Idempotency-Key
        in: header
        required: false
        schema:
          type: string
          maxLength: 128
        description: Optional alternative to the idempotencyKey body field
  /api/ingest/batch:
    post:
      tags:
      - Telemetry
      summary: Ingest up to 1000 agent runs (REST)
      description: Record several runs in one request. Items are validated individually; the request returns
        200 even when some items fail, and failed items are listed in `errors` by index.
      operationId: restIngestBatch
      security:
      - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - items
              properties:
                items:
                  type: array
                  minItems: 1
                  maxItems: 1000
                  items:
                    $ref: '#/components/schemas/IngestRun'
            example:
              items:
              - agentId: 1
                status: success
                latency: 150
                cost: 0.02
                accuracy: 95
              - agentId: 1
                status: failure
                latency: 2400
                cost: 0.03
                errorMessage: Upstream timeout
      responses:
        '200':
          description: Batch processed (possibly with per-item failures)
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  total:
                    type: integer
                  succeeded:
                    type: integer
                  failed:
                    type: integer
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        index:
                          type: integer
                        error:
                          type: string
                  message:
                    type: string
                  results:
                    type: array
                    items:
                      type: object
                      properties:
                        index:
                          type: integer
                        runId:
                          type: integer
                        duplicate:
                          type: boolean
              example:
                success: true
                total: 2
                succeeded: 2
                failed: 0
                results:
                - index: 0
                  runId: 1025
                  duplicate: false
                - index: 1
                  runId: 1026
                  duplicate: false
                message: 'Batch ingestion completed: 2 succeeded, 0 failed'
        '400':
          description: Body has no items array, the array is empty, or it has more than 1000 items
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IngestError'
        '401':
          description: Missing/malformed Authorization header, or invalid, revoked or expired API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IngestError'
        '429':
          description: Rate limit exceeded for this API key. Retry after the number of seconds in the
            Retry-After header.
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before retrying
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IngestError'
        '403':
          description: The API key is read-only
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IngestError'
        '413':
          description: Request body exceeds the server's size limit
  /api/trpc/dataRetention.getPolicy:
    post:
      tags:
      - Data Retention
      summary: Get current retention policy
      description: Retrieve the current data retention policy configuration for your account
      operationId: getRetentionPolicy
      security:
      - BearerAuth: []
      responses:
        '200':
          description: Policy retrieved successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/RetentionPolicy'
              example:
                result:
                  data:
                    userId: 1
                    retentionDays: 30
                    applyToAgentRuns: true
                    applyToBenchmarks: true
                    applyToAlerts: false
                    lastCleanupAt: '2024-01-15T10:30:00Z'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '404':
          description: No retention policy configured
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          $ref: '#/components/responses/RateLimitError'
        '500':
          $ref: '#/components/responses/InternalServerError'
  /api/trpc/dataRetention.updatePolicy:
    post:
      tags:
      - Data Retention
      summary: Update retention policy
      description: Configure data retention settings for your account
      operationId: updateRetentionPolicy
      security:
      - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - json
              properties:
                json:
                  type: object
                  required:
                  - retentionDays
                  - applyToAgentRuns
                  - applyToBenchmarks
                  - applyToAlerts
                  properties:
                    retentionDays:
                      type: integer
                      minimum: 7
                      maximum: 365
                      description: Number of days to retain data
                      example: 90
                    applyToAgentRuns:
                      type: boolean
                      description: Apply policy to agent run records
                      example: true
                    applyToBenchmarks:
                      type: boolean
                      description: Apply policy to benchmark records
                      example: true
                    applyToAlerts:
                      type: boolean
                      description: Apply policy to alert records
                      example: false
      responses:
        '200':
          description: Policy updated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: object
                    properties:
                      data:
                        type: object
                        properties:
                          success:
                            type: boolean
                            example: true
        '400':
          description: Invalid request parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: BAD_REQUEST
                  message: retentionDays must be between 7 and 365
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '429':
          $ref: '#/components/responses/RateLimitError'
        '500':
          $ref: '#/components/responses/InternalServerError'
  /api/trpc/dataRetention.getDataStats:
    post:
      tags:
      - Data Retention
      summary: Get data statistics
      description: View current data storage counts across all data types
      operationId: getDataStats
      security:
      - BearerAuth: []
      responses:
        '200':
          description: Statistics retrieved successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/DataStats'
              example:
                result:
                  data:
                    runs: 1523
                    benchmarks: 45
                    alerts: 23
                    totalRecords: 1591
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '429':
          $ref: '#/components/responses/RateLimitError'
        '500':
          $ref: '#/components/responses/InternalServerError'
  /api/trpc/dataRetention.executeCleanup:
    post:
      tags:
      - Data Retention
      summary: Execute data cleanup
      description: Manually trigger data cleanup based on current retention policy. This permanently deletes
        data older than the configured retention period.
      operationId: executeCleanup
      security:
      - BearerAuth: []
      responses:
        '200':
          description: Cleanup executed successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/CleanupResult'
              example:
                result:
                  data:
                    success: true
                    deletedRuns: 150
                    deletedBenchmarks: 12
                    deletedAlerts: 5
                    totalDeleted: 167
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          description: Insufficient permissions to execute cleanup
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: No retention policy configured
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          $ref: '#/components/responses/RateLimitError'
        '500':
          $ref: '#/components/responses/InternalServerError'
  /api/trpc/ingest.telemetry:
    post:
      tags:
      - Telemetry
      summary: Ingest agent telemetry data
      description: Submit telemetry data for agent runs including performance metrics, outputs, and metadata.
        This is the primary endpoint for real-time agent monitoring.
      operationId: ingestTelemetry
      security:
      - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - json
              properties:
                json:
                  type: object
                  required:
                  - apiKey
                  - agentId
                  - status
                  - latency
                  - cost
                  properties:
                    apiKey:
                      type: string
                      description: API key for authentication
                      example: bca_your_api_key
                    agentId:
                      type: integer
                      description: Unique identifier of the agent
                      example: 42
                    status:
                      type: string
                      enum:
                      - success
                      - failure
                      - partial
                      description: Execution status of the agent run
                      example: success
                    latency:
                      type: number
                      description: Execution time in milliseconds
                      example: 1250
                    cost:
                      type: number
                      description: Cost in USD
                      example: 0.0042
                    accuracy:
                      type: number
                      description: Accuracy score (0-100)
                      example: 95.5
                    inputData:
                      type: string
                      description: Input prompt or data sent to the agent
                      example: Analyze quarterly sales data
                    outputData:
                      type: string
                      description: Agent's output or response
                      example: Sales increased 15% YoY
                    errorMessage:
                      type: string
                      description: Error message if status is failure
                      example: Timeout after 30s
                    toolCalls:
                      type: array
                      description: Array of tool/function calls made by the agent
                      items:
                        type: object
                      example:
                      - name: search_database
                        args:
                          query: Q4 sales
                    reasoningPath:
                      type: string
                      description: Agent's reasoning or chain-of-thought
                      example: First analyzed trends, then compared to previous quarter
                    metadata:
                      type: object
                      additionalProperties: true
                      description: Additional custom metadata
                      example:
                        model: gpt-4
                        temperature: 0.7
            example:
              json:
                apiKey: bca_your_api_key
                agentId: 42
                status: success
                latency: 1250
                cost: 0.0042
                accuracy: 95.5
      responses:
        '200':
          description: Telemetry ingested successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: object
                    properties:
                      data:
                        type: object
                        properties:
                          success:
                            type: boolean
                            example: true
                          runId:
                            type: integer
                            description: ID of the created agent run record
                            example: 1523
        '400':
          description: Invalid request parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Invalid or inactive API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: UNAUTHORIZED
                  message: Invalid or inactive API key
        '403':
          description: API key expired or agent access denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          $ref: '#/components/responses/RateLimitError'
        '500':
          $ref: '#/components/responses/InternalServerError'
  /api/trpc/agents.recordRun:
    post:
      tags:
      - Agent Runs
      summary: Record agent run (authenticated)
      description: Submit agent run data with authentication. Includes drift detection metrics for monitoring
        output consistency.
      operationId: recordAgentRun
      security:
      - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - json
              properties:
                json:
                  type: object
                  required:
                  - agentId
                  - status
                  - latency
                  - cost
                  properties:
                    agentId:
                      type: integer
                      example: 42
                    status:
                      type: string
                      enum:
                      - success
                      - failure
                      - partial
                      example: success
                    latency:
                      type: number
                      description: Execution time in milliseconds
                      example: 1250
                    cost:
                      type: number
                      description: Cost in USD
                      example: 0.0042
                    accuracy:
                      type: number
                      example: 95.5
                    inputData:
                      type: string
                      example: Analyze quarterly sales data
                    outputData:
                      type: string
                      example: Sales increased 15% YoY
                    errorMessage:
                      type: string
                      example: Timeout after 30s
                    toolCalls:
                      type: string
                      description: JSON string of tool calls
                      example: '[{"name": "search_database"}]'
                    reasoningPath:
                      type: string
                      example: First analyzed trends
                    temperature:
                      type: number
                      description: Model temperature parameter
                      example: 0.7
                    taskType:
                      type: string
                      description: Type of task performed
                      example: data_analysis
                    modelTier:
                      type: integer
                      description: Model tier (1=basic, 2=advanced, 3=premium)
                      example: 2
                    totalAgreementRate:
                      type: number
                      description: Consensus agreement rate for drift detection
                      example: 0.85
                    normalizedEditDistance:
                      type: number
                      description: Edit distance metric for output drift
                      example: 0.12
                    factualDriftCount:
                      type: integer
                      description: Number of factual inconsistencies detected
                      example: 0
                    consistencyScore:
                      type: number
                      description: Output consistency score (0-1)
                      example: 0.92
      responses:
        '200':
          description: Run recorded successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: object
                    properties:
                      data:
                        type: object
                        properties:
                          insertId:
                            type: integer
                            example: 1524
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '429':
          $ref: '#/components/responses/RateLimitError'
        '500':
          $ref: '#/components/responses/InternalServerError'
  /api/trpc/ingest.batch:
    post:
      tags:
      - Telemetry
      summary: Batch telemetry ingestion
      description: Submit multiple telemetry records in a single request for high-throughput agents. Reduces
        API calls and improves performance.
      operationId: batchIngestTelemetry
      security:
      - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - json
              properties:
                json:
                  type: object
                  required:
                  - apiKey
                  - records
                  properties:
                    apiKey:
                      type: string
                      description: API key for authentication
                      example: bca_your_api_key
                    records:
                      type: array
                      description: Array of telemetry records to ingest
                      minItems: 1
                      maxItems: 1000
                      items:
                        type: object
                        required:
                        - agentId
                        - status
                        - latency
                        - cost
                        properties:
                          agentId:
                            type: integer
                            description: ID of the agent
                            example: 42
                          status:
                            type: string
                            enum:
                            - success
                            - failure
                            - partial
                            description: Execution status
                            example: success
                          latency:
                            type: number
                            description: Execution time in milliseconds
                            example: 1250
                          cost:
                            type: number
                            description: Execution cost in dollars
                            example: 0.0042
                          accuracy:
                            type: number
                            description: Accuracy score (0-100)
                            example: 95.5
                          inputData:
                            type: string
                            description: Input prompt or data
                          outputData:
                            type: string
                            description: Agent's output
                          errorMessage:
                            type: string
                            description: Error message if failed
                          toolCalls:
                            type: array
                            items:
                              type: object
                          reasoningPath:
                            type: string
                            description: Agent's reasoning
                          metadata:
                            type: object
                            additionalProperties: true
      responses:
        '200':
          description: Batch processing completed
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: object
                    properties:
                      data:
                        type: object
                        properties:
                          success:
                            type: boolean
                            description: True if all records succeeded
                            example: true
                          processed:
                            type: integer
                            description: Number of successfully processed records
                            example: 98
                          failed:
                            type: integer
                            description: Number of failed records
                            example: 2
                          total:
                            type: integer
                            description: Total number of records submitted
                            example: 100
                          results:
                            type: array
                            description: Details of successful records
                            items:
                              type: object
                              properties:
                                index:
                                  type: integer
                                runId:
                                  type: integer
                                success:
                                  type: boolean
                          errors:
                            type: array
                            description: Details of failed records
                            items:
                              type: object
                              properties:
                                index:
                                  type: integer
                                agentId:
                                  type: integer
                                error:
                                  type: string
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '429':
          $ref: '#/components/responses/RateLimitError'
        '500':
          $ref: '#/components/responses/InternalServerError'
  /api/trpc/validation.create:
    post:
      tags:
      - Validation
      summary: Create validation schema
      description: Create a JSON Schema to validate incoming telemetry data in real-time. Alerts are sent
        when validation fails.
      operationId: createValidationSchema
      security:
      - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - json
              properties:
                json:
                  type: object
                  required:
                  - name
                  - jsonSchema
                  properties:
                    agentId:
                      type: integer
                      description: Specific agent ID (null = applies to all agents)
                      example: 42
                    name:
                      type: string
                      description: Name of the validation schema
                      example: Production Data Format
                    description:
                      type: string
                      description: Description of what this schema validates
                      example: Ensures all production telemetry includes required fields
                    jsonSchema:
                      type: string
                      description: JSON Schema definition as string
                      example: '{"type": "object", "required": ["accuracy", "cost"], "properties": {"accuracy":
                        {"type": "number", "minimum": 0, "maximum": 100}}}'
                    isActive:
                      type: boolean
                      description: Whether schema is active
                      default: true
                    alertOnFailure:
                      type: boolean
                      description: Send alert when validation fails
                      default: true
                    webhookUrl:
                      type: string
                      description: Optional webhook URL for validation failures
                      example: https://example.com/webhooks/validation-failure
      responses:
        '200':
          description: Validation schema created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: object
                    properties:
                      data:
                        type: object
                        properties:
                          id:
                            type: integer
                            description: ID of created schema
                            example: 15
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '500':
          $ref: '#/components/responses/InternalServerError'
  /api/trpc/validation.list:
    post:
      tags:
      - Validation
      summary: List validation schemas
      description: Get all validation schemas for the current user
      operationId: listValidationSchemas
      security:
      - BearerAuth: []
      responses:
        '200':
          description: List of validation schemas
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: object
                    properties:
                      data:
                        type: array
                        items:
                          $ref: '#/components/schemas/ValidationSchema'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: 'API key sent as `Authorization: Bearer bca_...`. Create keys under Settings → API
        Keys.'
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key passed in request body for telemetry ingestion
  schemas:
    RetentionPolicy:
      type: object
      properties:
        userId:
          type: integer
          description: User ID associated with the policy
          example: 1
        retentionDays:
          type: integer
          minimum: 7
          maximum: 365
          description: Number of days to retain data
          example: 30
        applyToAgentRuns:
          type: boolean
          description: Whether policy applies to agent run records
          example: true
        applyToBenchmarks:
          type: boolean
          description: Whether policy applies to benchmark records
          example: true
        applyToAlerts:
          type: boolean
          description: Whether policy applies to alert records
          example: false
        lastCleanupAt:
          type: string
          format: date-time
          description: Timestamp of last cleanup execution
          example: '2024-01-15T10:30:00Z'
    DataStats:
      type: object
      properties:
        runs:
          type: integer
          description: Total number of agent run records
          example: 1523
        benchmarks:
          type: integer
          description: Total number of benchmark records
          example: 45
        alerts:
          type: integer
          description: Total number of alert records
          example: 23
        totalRecords:
          type: integer
          description: Sum of all records across data types
          example: 1591
    CleanupResult:
      type: object
      properties:
        success:
          type: boolean
          description: Whether cleanup completed successfully
          example: true
        deletedRuns:
          type: integer
          description: Number of agent run records deleted
          example: 150
        deletedBenchmarks:
          type: integer
          description: Number of benchmark records deleted
          example: 12
        deletedAlerts:
          type: integer
          description: Number of alert records deleted
          example: 5
        totalDeleted:
          type: integer
          description: Total number of records deleted
          example: 28
    ValidationSchema:
      type: object
      properties:
        id:
          type: integer
          description: Schema ID
          example: 15
        userId:
          type: integer
          description: Owner user ID
          example: 1
        agentId:
          type: integer
          nullable: true
          description: Specific agent ID (null = all agents)
          example: 42
        name:
          type: string
          description: Schema name
          example: Production Data Format
        description:
          type: string
          description: Schema description
          example: Validates production telemetry format
        jsonSchema:
          type: string
          description: JSON Schema definition
          example: '{"type": "object", "required": ["accuracy"]}'
        isActive:
          type: boolean
          description: Whether schema is active
          example: true
        alertOnFailure:
          type: boolean
          description: Send alerts on validation failure
          example: true
        webhookUrl:
          type: string
          nullable: true
          description: Webhook URL for failures
          example: https://example.com/webhook
        createdAt:
          type: string
          format: date-time
          example: '2024-01-15T10:30:00Z'
        updatedAt:
          type: string
          format: date-time
          example: '2024-01-15T10:30:00Z'
    Error:
      type: object
      required:
      - error
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Error code
              example: UNAUTHORIZED
            message:
              type: string
              description: Human-readable error message
              example: Invalid or missing API key
    IngestRun:
      type: object
      required:
      - agentId
      - status
      - latency
      - cost
      properties:
        agentId:
          type: integer
          description: Numeric ID of an agent owned by the API key's account
          example: 1
        status:
          type: string
          enum:
          - success
          - failure
          - partial
        latency:
          type: number
          minimum: 0
          description: Execution time in milliseconds (rounded to whole milliseconds)
          example: 1250
        cost:
          type: number
          minimum: 0
          description: Cost in US dollars (0.04 = four cents)
          example: 0.04
        accuracy:
          type: number
          minimum: 0
          maximum: 100
          description: Accuracy as a percentage 0-100; values of 1 or less are read as a fraction (0.95
            = 95%)
          example: 95
        inputData:
          type: string
        outputData:
          type: string
        errorMessage:
          type: string
        toolCalls:
          type: array
          items: {}
        reasoningPath:
          type: string
        metadata:
          type: object
          additionalProperties: true
        idempotencyKey:
          type: string
          maxLength: 128
          description: Optional. A run re-sent with the same key for the same agent is not stored twice.
    IngestError:
      type: object
      required:
      - success
      - error
      properties:
        success:
          type: boolean
          example: false
        error:
          type: string
        message:
          type: string
  responses:
    BadRequestError:
      description: Invalid request parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: BAD_REQUEST
              message: Invalid request parameters
    UnauthorizedError:
      description: Authentication failed - invalid or missing API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: UNAUTHORIZED
              message: Invalid or missing API key
    RateLimitError:
      description: Rate limit exceeded
      headers:
        Retry-After:
          schema:
            type: integer
          description: Seconds to wait before retrying
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: RATE_LIMIT_EXCEEDED
              message: Rate limit exceeded. Please retry after 3600 seconds.
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: INTERNAL_SERVER_ERROR
              message: An unexpected error occurred. Please try again later.
