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

# Ingest Agent Trace

> Ingest a full agent execution trace and run the trace-level detectors.

Runs the value-level dataflow-taint analyzer (``FLOW001``, fail-open) and
the goal-alignment auditor (fail-closed by its own design, opt-in) over the
trace, aggregates their outputs into an allow / warn / block decision, and
persists a ``security_event``. Fails open: a detector or DB hiccup never
500s the caller.



## OpenAPI

````yaml /api-reference/openapi-developer.json post /api/v1/agent/trace
openapi: 3.1.0
info:
  title: PromptGuard Developer API
  description: >-
    Public API for developers to integrate PromptGuard security into their
    applications
  version: 1.0.0
servers:
  - url: https://api.promptguard.co
    description: Production
security:
  - ApiKeyAuth: []
paths:
  /api/v1/agent/trace:
    post:
      tags:
        - agent
      summary: Ingest Agent Trace
      description: >-
        Ingest a full agent execution trace and run the trace-level detectors.


        Runs the value-level dataflow-taint analyzer (``FLOW001``, fail-open)
        and

        the goal-alignment auditor (fail-closed by its own design, opt-in) over
        the

        trace, aggregates their outputs into an allow / warn / block decision,
        and

        persists a ``security_event``. Fails open: a detector or DB hiccup never

        500s the caller.
      operationId: ingest_agent_trace_api_v1_agent_trace_post
      parameters:
        - name: x-api-key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Api-Key
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgentTraceRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentTraceResponse'
        '401':
          description: Missing or invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthErrorEnvelope'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '429':
          description: Monthly quota exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QuotaErrorEnvelope'
components:
  schemas:
    AgentTraceRequest:
      properties:
        user_objective:
          type: string
          title: User Objective
          default: ''
        events:
          items:
            $ref: '#/components/schemas/AgentTraceEvent'
          type: array
          title: Events
        tool_labels:
          anyOf:
            - additionalProperties:
                $ref: '#/components/schemas/AgentToolLabels'
              type: object
            - type: 'null'
          title: Tool Labels
      type: object
      title: AgentTraceRequest
      description: >-
        A full agent execution trace to audit post-hoc.


        Unlike ``/validate-tool`` (a pre-execution check of a single tool name +

        args), this carries the whole chronological trace *with tool outputs*
        plus

        the user's original objective, so the value-level dataflow-taint and

        goal-alignment detectors can fire.
    AgentTraceResponse:
      properties:
        decision:
          type: string
          title: Decision
        findings:
          items:
            $ref: '#/components/schemas/AgentTraceFinding'
          type: array
          title: Findings
          default: []
        event_id:
          type: string
          title: Event Id
      type: object
      required:
        - decision
        - event_id
      title: AgentTraceResponse
      description: Aggregated verdict over the ingested trace.
    AuthErrorEnvelope:
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
          examples:
            - code: missing_api_key
              message: >-
                PromptGuard API key required. Please provide via X-API-Key
                header.
              type: authentication_error
      type: object
      required:
        - error
      title: AuthErrorEnvelope
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    QuotaErrorEnvelope:
      properties:
        error:
          $ref: '#/components/schemas/QuotaErrorDetail'
      type: object
      required:
        - error
      title: QuotaErrorEnvelope
    AgentTraceEvent:
      properties:
        role:
          type: string
          title: Role
          default: ''
        tool_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Tool Name
        arguments:
          additionalProperties: true
          type: object
          title: Arguments
        output:
          title: Output
        content:
          type: string
          title: Content
          default: ''
        thought:
          type: string
          title: Thought
          default: ''
      type: object
      title: AgentTraceEvent
      description: >-
        One event of a full agent execution trace.


        An event with a ``tool_name`` is a tool call: its ``arguments`` (a
        sink's

        inputs) and ``output`` (a source of taint) drive the trace-level
        detectors.

        Events without one are plain assistant / user turns, kept as context.
    AgentToolLabels:
      properties:
        untrusted_content:
          type: boolean
          title: Untrusted Content
          default: false
        private_data:
          type: boolean
          title: Private Data
          default: false
        public_sink:
          type: boolean
          title: Public Sink
          default: false
        destructive:
          type: boolean
          title: Destructive
          default: false
      type: object
      title: AgentToolLabels
      description: Capability profile for one tool along the four lethal-trifecta axes.
    AgentTraceFinding:
      properties:
        detector:
          type: string
          title: Detector
        code:
          type: string
          title: Code
        severity:
          type: string
          title: Severity
        reason:
          type: string
          title: Reason
        decision:
          type: string
          title: Decision
        metadata:
          additionalProperties: true
          type: object
          title: Metadata
      type: object
      required:
        - detector
        - code
        - severity
        - reason
        - decision
      title: AgentTraceFinding
      description: A single detector hit, normalized across detectors.
    ErrorDetail:
      properties:
        message:
          type: string
          title: Message
          description: Human-readable error description
        type:
          type: string
          title: Type
          description: Error category, e.g. 'authentication_error'
        code:
          type: string
          title: Code
          description: Machine-readable error code
      type: object
      required:
        - message
        - type
        - code
      title: ErrorDetail
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    QuotaErrorDetail:
      properties:
        message:
          type: string
          title: Message
        type:
          type: string
          title: Type
          description: '''quota_exceeded'' or ''spending_limit_exceeded'''
        code:
          type: string
          title: Code
          description: '''monthly_quota_exceeded'' or ''spending_limit_exceeded'''
        current_plan:
          type: string
          title: Current Plan
        requests_used:
          type: integer
          title: Requests Used
        requests_limit:
          type: integer
          title: Requests Limit
        upgrade_url:
          type: string
          title: Upgrade Url
        retry_after:
          anyOf:
            - type: integer
            - type: 'null'
          title: Retry After
      type: object
      required:
        - message
        - type
        - code
        - current_plan
        - requests_used
        - requests_limit
        - upgrade_url
      title: QuotaErrorDetail
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: >-
        PromptGuard API key for developer endpoints. Keys start with pg_live_
        and are created in the dashboard.

````