> ## 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.

Guide: [Analyse a full agent run](https://docs.promptguard.co/security/agent-traces)



## 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.


        Guide: [Analyse a full agent
        run](https://docs.promptguard.co/security/agent-traces)
      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'
              example:
                decision: block
                findings:
                  - detector: dataflow_taint
                    code: FLOW001
                    severity: high
                    reason: >-
                      A untrusted value produced by 'read_file' reached the
                      external public sink 'send_email': the agent exfiltrated
                      data from an untrusted/sensitive source to an outside
                      destination.
                    decision: block
                    rule:
                      detector: dataflow_taint
                      id: untrusted_or_sensitive_to_public_sink
                      suppressible: true
                    metadata:
                      source_tool: read_file
                      sink_tool: send_email
                      value_class: untrusted
                event_id: 788b2dca-fde4-457f-8297-aa3be96a528f
        '401':
          description: Missing, malformed, unknown, disabled or expired API key
          content:
            application/json:
              examples:
                missing_api_key:
                  summary: No X-API-Key header
                  value:
                    error:
                      message: >-
                        PromptGuard API key required. Please provide via
                        X-API-Key header.
                      type: authentication_error
                      code: missing_api_key
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#missing_api_key
                malformed_api_key:
                  summary: Not a pg_live_ key
                  value:
                    error:
                      message: Invalid API key format
                      type: authentication_error
                      code: invalid_api_key
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#invalid_api_key
                unknown_api_key:
                  summary: No such key
                  value:
                    error:
                      message: Invalid API key
                      type: authentication_error
                      code: invalid_api_key
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#invalid_api_key
                disabled_api_key:
                  summary: Key disabled
                  value:
                    error:
                      message: API key is disabled
                      type: authentication_error
                      code: disabled_api_key
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#disabled_api_key
                expired_api_key:
                  summary: Key expired
                  value:
                    error:
                      message: API key has expired
                      type: authentication_error
                      code: expired_api_key
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#expired_api_key
              schema:
                $ref: '#/components/schemas/AuthErrorEnvelope'
        '403':
          description: Refused by the key's scopes or the organization's IP allowlist
          content:
            application/json:
              examples:
                scope_denied:
                  summary: The key's scopes exclude this endpoint
                  value:
                    error:
                      message: >-
                        This endpoint needs the `scan:write` scope, which this
                        API key does not hold. Create a key that includes it, or
                        use an unrestricted key.
                      type: insufficient_scope
                      code: scope_denied
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#scope_denied
                scan_only_credential:
                  summary: A scan-only device credential
                  value:
                    error:
                      message: This credential is scan-only; endpoint not permitted.
                      type: insufficient_scope
                      code: scope_denied
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#scope_denied
                read_only_key:
                  summary: A SIEM export key
                  value:
                    error:
                      message: >-
                        This is a read-only export key. It may only GET
                        /api/v1/alerts, /api/v1/audit-events,
                        /api/v1/audit-events/stream, /api/v1/interactions and
                        /api/v1/interactions/stream.
                      type: insufficient_scope
                      code: read_only_key
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#read_only_key
                ip_not_allowed:
                  summary: Caller IP outside the allowlist
                  value:
                    error:
                      message: Request IP is not in the organization's allowlist
                      type: permission_error
                      code: ip_not_allowed
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#ip_not_allowed
                ip_allowlist_error:
                  summary: Allowlist could not be checked
                  value:
                    error:
                      message: IP allowlist validation failed
                      type: permission_error
                      code: ip_allowlist_error
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#ip_allowlist_error
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorEnvelope'
        '429':
          description: >-
            Rate limit, monthly quota, the key's own monthly cap, spending
            limit, or an inactive subscription (branch on `error.code`)
          content:
            application/json:
              examples:
                rate_limit_exceeded:
                  summary: Per-minute limit reached
                  value:
                    error:
                      message: >-
                        Rate limit exceeded: your plan allows 60 requests per
                        minute. Please retry later.
                      type: rate_limit_exceeded
                      code: rate_limit_exceeded
                      retry_after: 42
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#rate_limit_exceeded
                api_key_request_cap_exceeded:
                  summary: This key's own monthly request cap reached
                  value:
                    error:
                      message: >-
                        This API key's monthly cap of 10,000 requests is
                        reached. It resets on December 1 (UTC). Raise or remove
                        the cap in the dashboard, or use another key.
                      type: quota_exceeded
                      code: api_key_request_cap_exceeded
                      requests_limit: 10000
                      resets_at: '2026-12-01T00:00:00+00:00'
                      retry_after: 1209600
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#api_key_request_cap_exceeded
                monthly_quota_exceeded:
                  summary: Monthly request quota spent
                  value:
                    error:
                      message: Monthly quota of 100,000 requests exceeded.
                      type: quota_exceeded
                      code: monthly_quota_exceeded
                      current_plan: pro
                      requests_used: 100000
                      requests_limit: 100000
                      upgrade_url: https://app.promptguard.co/dashboard/billing
                      retry_after: 1209600
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#monthly_quota_exceeded
                spending_limit_exceeded:
                  summary: Monthly spending limit reached
                  value:
                    error:
                      message: Monthly spending limit of $500.00 exceeded.
                      type: spending_limit_exceeded
                      code: spending_limit_exceeded
                      current_plan: scale
                      current_spending: 500.12
                      spending_limit: 500
                      settings_url: https://app.promptguard.co/dashboard/spending
                      retry_after: 1209600
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#spending_limit_exceeded
                subscription_inactive:
                  summary: Subscription not active; never retry
                  value:
                    error:
                      message: 'Your pro subscription is not active (status: past_due).'
                      type: subscription_inactive
                      code: subscription_inactive
                      current_plan: pro
                      subscription_status: past_due
                      reactivate_url: https://app.promptguard.co/dashboard/billing
                      doc_url: >-
                        https://docs.promptguard.co/production/error-handling#subscription_inactive
              schema:
                anyOf:
                  - $ref: '#/components/schemas/RateLimitErrorEnvelope'
                  - $ref: '#/components/schemas/QuotaErrorEnvelope'
                  - $ref: '#/components/schemas/KeyRequestCapErrorEnvelope'
                  - $ref: '#/components/schemas/SubscriptionInactiveErrorEnvelope'
                title: Response 429 Ingest Agent Trace Api V1 Agent Trace Post
      externalDocs:
        description: 'Guide: Analyse a full agent run'
        url: https://docs.promptguard.co/security/agent-traces
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
    ErrorEnvelope:
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
      type: object
      required:
        - error
      title: ErrorEnvelope
    ValidationErrorEnvelope:
      description: The developer API's 422 (`shared/infrastructure/framework_errors.py`).
      properties:
        error:
          $ref: '#/components/schemas/ValidationErrorDetail'
        detail:
          deprecated: true
          description: >-
            The same list as `error.details`, in FastAPI's old shape. Removed on
            2027-02-11; read `error.details`
          items:
            $ref: '#/components/schemas/ValidationErrorField'
          title: Detail
          type: array
      required:
        - error
        - detail
      title: ValidationErrorEnvelope
      type: object
      example:
        error:
          message: 'The request is invalid: body.messages: Field required'
          type: invalid_request_error
          code: invalid_request
          details:
            - type: missing
              loc:
                - body
                - messages
              msg: Field required
              input:
                direction: input
          error_id: 3f0b8c1e-6a0e-4d52-9a57-0c2a9a7f5b11
          doc_url: >-
            https://docs.promptguard.co/production/error-handling#invalid_request
        detail:
          - type: missing
            loc:
              - body
              - messages
            msg: Field required
            input:
              direction: input
    RateLimitErrorEnvelope:
      properties:
        error:
          $ref: '#/components/schemas/RateLimitErrorDetail'
      type: object
      required:
        - error
      title: RateLimitErrorEnvelope
    QuotaErrorEnvelope:
      properties:
        error:
          $ref: '#/components/schemas/QuotaErrorDetail'
      type: object
      required:
        - error
      title: QuotaErrorEnvelope
    KeyRequestCapErrorEnvelope:
      properties:
        error:
          $ref: '#/components/schemas/KeyRequestCapErrorDetail'
      type: object
      required:
        - error
      title: KeyRequestCapErrorEnvelope
    SubscriptionInactiveErrorEnvelope:
      properties:
        error:
          $ref: '#/components/schemas/SubscriptionInactiveErrorDetail'
      type: object
      required:
        - error
      title: SubscriptionInactiveErrorEnvelope
    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
        rule:
          anyOf:
            - $ref: '#/components/schemas/FindingRule'
            - type: 'null'
          description: >-
            The detector and rule that made this finding, the pair a Suppression
            names.
        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
        doc_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Doc Url
          description: >-
            The error catalogue's entry for `code` (cause and fix); present when
            the catalogue documents the code
      type: object
      required:
        - message
        - type
        - code
      title: ErrorDetail
    ValidationErrorDetail:
      properties:
        message:
          description: The failed fields, one line
          title: Message
          type: string
        type:
          description: '''invalid_request_error'''
          title: Type
          type: string
        code:
          description: '''invalid_request'''
          title: Code
          type: string
        details:
          description: Each field that failed
          items:
            $ref: '#/components/schemas/ValidationErrorField'
          title: Details
          type: array
        error_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: Equals the X-Request-ID header
          title: Error Id
        doc_url:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: >-
            The error catalogue's entry for `code` (cause and fix); present when
            the catalogue documents the code
          title: Doc Url
      required:
        - message
        - type
        - code
        - details
      title: ValidationErrorDetail
      type: object
    ValidationErrorField:
      description: One field that failed validation, as FastAPI reports it.
      properties:
        loc:
          description: The field's path, e.g. ['body', 'messages']
          items:
            anyOf:
              - type: string
              - type: integer
          title: Loc
          type: array
        msg:
          description: What is wrong with it
          title: Msg
          type: string
        type:
          description: The kind of failure, e.g. 'missing'
          title: Type
          type: string
        input:
          default: null
          description: The value that was sent
          title: Input
        ctx:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          default: null
          description: The limit it broke, where there is one
          title: Ctx
      required:
        - loc
        - msg
        - type
      title: ValidationErrorField
      type: object
    RateLimitErrorDetail:
      properties:
        message:
          type: string
          title: Message
        type:
          type: string
          title: Type
          description: '''rate_limit_exceeded'''
        code:
          type: string
          title: Code
          description: '''rate_limit_exceeded'''
        retry_after:
          type: integer
          title: Retry After
          description: Seconds until the window resets; also `Retry-After`
        doc_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Doc Url
          description: >-
            The error catalogue's entry for `code` (cause and fix); present when
            the catalogue documents the code
      type: object
      required:
        - message
        - type
        - code
        - retry_after
      title: RateLimitErrorDetail
    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:
          anyOf:
            - type: integer
            - type: 'null'
          title: Requests Limit
          description: >-
            The month's Request allowance; null on a Plan sold in usage credit
            (ADR-0041), which reports `credit_*` instead
        credit_usd:
          anyOf:
            - type: number
            - type: 'null'
          title: Credit Usd
          description: The month's usage credit at list prices, in US dollars
        credit_used_usd:
          anyOf:
            - type: number
            - type: 'null'
          title: Credit Used Usd
          description: What this month's Requests cost at list prices, in US dollars
        credit_remaining_usd:
          anyOf:
            - type: number
            - type: 'null'
          title: Credit Remaining Usd
          description: The month's usage credit not yet spent, in US dollars
        upgrade_url:
          type: string
          title: Upgrade Url
        retry_after:
          anyOf:
            - type: integer
            - type: 'null'
          title: Retry After
        doc_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Doc Url
          description: >-
            The error catalogue's entry for `code` (cause and fix); present when
            the catalogue documents the code
      type: object
      required:
        - message
        - type
        - code
        - current_plan
        - requests_used
        - requests_limit
        - upgrade_url
      title: QuotaErrorDetail
    KeyRequestCapErrorDetail:
      properties:
        message:
          type: string
          title: Message
        type:
          type: string
          title: Type
          description: '''quota_exceeded'''
        code:
          type: string
          title: Code
          description: '''api_key_request_cap_exceeded'''
        requests_limit:
          type: integer
          title: Requests Limit
          description: The key's monthly Request cap
        resets_at:
          type: string
          title: Resets At
          description: 'When the cap resets: the first of next month, UTC'
        retry_after:
          type: integer
          title: Retry After
        doc_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Doc Url
          description: >-
            The error catalogue's entry for `code` (cause and fix); present when
            the catalogue documents the code
      type: object
      required:
        - message
        - type
        - code
        - requests_limit
        - resets_at
        - retry_after
      title: KeyRequestCapErrorDetail
      description: >-
        One key past its own monthly Request cap (#1111), not the account's
        quota.


        Deliberately not ``QuotaErrorDetail``: nothing about the Plan was
        exceeded,

        so it names no Plan and offers no upgrade. The account's other keys are

        still served.
    SubscriptionInactiveErrorDetail:
      properties:
        message:
          type: string
          title: Message
        type:
          type: string
          title: Type
          description: '''subscription_inactive'''
        code:
          type: string
          title: Code
          description: '''subscription_inactive'''
        current_plan:
          type: string
          title: Current Plan
        subscription_status:
          type: string
          title: Subscription Status
          description: >-
            e.g. 'cancelled', 'past_due', 'paused'; 'none' where no plan covers
            the key's organization at all
        reactivate_url:
          type: string
          title: Reactivate Url
        doc_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Doc Url
          description: >-
            The error catalogue's entry for `code` (cause and fix); present when
            the catalogue documents the code
      type: object
      required:
        - message
        - type
        - code
        - current_plan
        - subscription_status
        - reactivate_url
      title: SubscriptionInactiveErrorDetail
      description: >-
        A refusal for the subscription's state, not for a spent quota.


        Deliberately not ``QuotaErrorDetail``: it carries no ``requests_used`` /

        ``requests_limit`` (nothing was exceeded -- reporting them beside this

        message is the contradiction #565 was filed for), no ``retry_after``

        (waiting does not fix it), and no ``on_demand_url`` (pay-as-you-go on a
        dead

        subscription is refused by design). One door, and it works.
    FindingRule:
      properties:
        detector:
          type: string
          title: Detector
          description: >-
            The detector that made the finding, e.g. `injection_regex`, `pii`,
            `ml_injection_classifier`. Stable across releases.
        id:
          type: string
          title: Id
          description: >-
            The rule of that detector that fired. Stable across releases: a
            detector that reports by type uses the type (`email` for `pii`), a
            pattern rule its declared name (`ignore_previous_instructions`), an
            ATR rule ATR's own id, and a detector with one verdict its own name.
        suppressible:
          type: boolean
          title: Suppressible
          description: >-
            Whether a Suppression may target this rule. False for the ML
            injection classifier and every model or LLM judge of injection, the
            secret detectors, canary tokens, and the project's own rules and MCP
            configuration. Other judges, such as content safety, can be.
      type: object
      required:
        - detector
        - id
        - suppressible
      title: FindingRule
      description: Which rule of which detector a finding is, as the API returns it.
  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.

````

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