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

# Scan Agent Memory

> Scan a chunk of agent memory for poisoning (OWASP Agentic ASI06).

A poisoned memory chunk is persisted, so it can be written once and fire in
a later session against a different user. Payloads are often latent — they
arm rather than act ("when asked about X, do Y") — so this detects
conditional triggers as well as direct injection vocabulary.

Scan on `write` to stop the plant, and on `read` to catch chunks poisoned
through another path. Fails open: a detector or database error returns a
decision rather than an error response.



## OpenAPI

````yaml /api-reference/openapi-developer.json post /api/v1/agent/memory
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/memory:
    post:
      tags:
        - agent
      summary: Scan Agent Memory
      description: >-
        Scan a chunk of agent memory for poisoning (OWASP Agentic ASI06).


        A poisoned memory chunk is persisted, so it can be written once and fire
        in

        a later session against a different user. Payloads are often latent —
        they

        arm rather than act ("when asked about X, do Y") — so this detects

        conditional triggers as well as direct injection vocabulary.


        Scan on `write` to stop the plant, and on `read` to catch chunks
        poisoned

        through another path. Fails open: a detector or database error returns a

        decision rather than an error response.
      operationId: scan_agent_memory_api_v1_agent_memory_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/AgentMemoryRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentMemoryResponse'
        '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:
    AgentMemoryRequest:
      properties:
        content:
          type: string
          title: Content
          description: The memory chunk to scan
        direction:
          type: string
          title: Direction
          description: >-
            'write' before persisting a chunk, 'read' when a stored chunk is
            retrieved. Scan both: a chunk poisoned before this endpoint existed,
            or written through another path, is only catchable on read.
          default: write
        memory_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Memory Id
          description: Your identifier for the chunk
      type: object
      required:
        - content
      title: AgentMemoryRequest
      description: Content being written to, or read back from, an agent's memory.
    AgentMemoryResponse:
      properties:
        decision:
          type: string
          title: Decision
        detected:
          type: boolean
          title: Detected
        reason:
          type: string
          title: Reason
          default: ''
        confidence:
          type: number
          title: Confidence
          default: 0
        match_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Match Type
        content_hash:
          anyOf:
            - type: string
            - type: 'null'
          title: Content Hash
        event_id:
          type: string
          title: Event Id
      type: object
      required:
        - decision
        - detected
        - event_id
      title: AgentMemoryResponse
      description: Verdict on one memory chunk.
    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
    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.

````