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

# Get Project Guardrails

> Return the effective guardrail config for one of the caller's projects.

Guide: [Manage guardrails as code](https://docs.promptguard.co/security/policy-as-code)



## OpenAPI

````yaml /api-reference/openapi-developer.json get /api/v1/projects/{project_id}/guardrails
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/projects/{project_id}/guardrails:
    get:
      tags:
        - guardrails
      summary: Get Project Guardrails
      description: >-
        Return the effective guardrail config for one of the caller's projects.


        Guide: [Manage guardrails as
        code](https://docs.promptguard.co/security/policy-as-code)
      operationId: get_project_guardrails_api_v1_projects__project_id__guardrails_get
      parameters:
        - name: project_id
          in: path
          required: true
          schema:
            type: string
            title: Project Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GuardrailsResponse'
              example:
                guardrails:
                  prompt_injection:
                    warn_threshold: null
                    block_threshold: null
                    enabled: true
                    level: moderate
                  pii_detection:
                    enabled: true
                    level: moderate
                    mode: redact
                    entities: null
                  toxicity:
                    warn_threshold: null
                    block_threshold: null
                    enabled: true
                    threshold: 0.7
                    categories: null
                  data_exfiltration:
                    enabled: true
                    level: moderate
                  secret_key_detection:
                    enabled: true
                    level: moderate
                  url_filtering:
                    enabled: false
                  fraud_detection:
                    enabled: true
                  malware_detection:
                    enabled: true
                  jailbreak_detection:
                    enabled: true
                  tool_injection:
                    enabled: true
                  multi_turn_drift:
                    enabled: true
                  hallucination:
                    enabled: true
                    action: metadata
                    block_threshold: 0.6
                  mcp_security:
                    enabled: false
                    server_allowlist: []
                    server_blocklist: []
                    enforce_schema_validation: true
                    max_argument_size_bytes: 10000
        '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 `policies:read` 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: Per-minute rate limit reached; retry after `retry_after` seconds
          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
              schema:
                $ref: '#/components/schemas/RateLimitErrorEnvelope'
      externalDocs:
        description: 'Guide: Manage guardrails as code'
        url: https://docs.promptguard.co/security/policy-as-code
components:
  schemas:
    GuardrailsResponse:
      properties:
        guardrails:
          $ref: '#/components/schemas/GuardrailsConfig'
      type: object
      required:
        - guardrails
      title: GuardrailsResponse
    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
    GuardrailsConfig:
      properties:
        prompt_injection:
          $ref: '#/components/schemas/PromptInjectionConfig'
        pii_detection:
          $ref: '#/components/schemas/PIIDetectionConfig'
        toxicity:
          $ref: '#/components/schemas/ToxicityConfig'
        data_exfiltration:
          $ref: '#/components/schemas/LevelConfig'
        secret_key_detection:
          $ref: '#/components/schemas/LevelConfig'
        url_filtering:
          $ref: '#/components/schemas/ToggleOnlyConfig'
        fraud_detection:
          $ref: '#/components/schemas/ToggleOnlyConfig'
        malware_detection:
          $ref: '#/components/schemas/ToggleOnlyConfig'
        jailbreak_detection:
          $ref: '#/components/schemas/ToggleOnlyConfig'
        tool_injection:
          $ref: '#/components/schemas/ToggleOnlyConfig'
        multi_turn_drift:
          $ref: '#/components/schemas/ToggleOnlyConfig'
        hallucination:
          $ref: '#/components/schemas/HallucinationConfig'
        mcp_security:
          $ref: '#/components/schemas/MCPSecurityConfig'
      type: object
      title: GuardrailsConfig
      description: Full per-guardrail configuration for a project.
    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
    PromptInjectionConfig:
      properties:
        warn_threshold:
          anyOf:
            - type: number
              maximum: 1
              minimum: 0
            - type: 'null'
          title: Warn Threshold
          description: >-
            A score at or above this and below `block_threshold` flags: the
            request is allowed and the finding is reported. Needs
            `block_threshold`.
        block_threshold:
          anyOf:
            - type: number
              maximum: 1
              minimum: 0
            - type: 'null'
          title: Block Threshold
          description: >-
            A score at or above this blocks. Null: the detector decides as
            before.
        enabled:
          type: boolean
          title: Enabled
          default: true
        level:
          type: string
          enum:
            - strict
            - moderate
            - permissive
          title: Level
          default: moderate
      type: object
      title: PromptInjectionConfig
      description: 'The prompt-injection guardrail: a level, and optionally bands.'
    PIIDetectionConfig:
      properties:
        enabled:
          type: boolean
          title: Enabled
          default: true
        level:
          type: string
          enum:
            - strict
            - moderate
            - permissive
          title: Level
          default: moderate
        mode:
          type: string
          enum:
            - redact
            - mask
            - block
            - tokenize
          title: Mode
          default: redact
        entities:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Entities
      type: object
      title: PIIDetectionConfig
    ToxicityConfig:
      properties:
        warn_threshold:
          anyOf:
            - type: number
              maximum: 1
              minimum: 0
            - type: 'null'
          title: Warn Threshold
          description: >-
            A score at or above this and below `block_threshold` flags: the
            request is allowed and the finding is reported. Needs
            `block_threshold`.
        block_threshold:
          anyOf:
            - type: number
              maximum: 1
              minimum: 0
            - type: 'null'
          title: Block Threshold
          description: >-
            A score at or above this blocks. Null: the detector decides as
            before.
        enabled:
          type: boolean
          title: Enabled
          default: true
        threshold:
          type: number
          maximum: 1
          minimum: 0
          title: Threshold
          default: 0.7
        categories:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Categories
      type: object
      title: ToxicityConfig
    LevelConfig:
      properties:
        enabled:
          type: boolean
          title: Enabled
          default: true
        level:
          type: string
          enum:
            - strict
            - moderate
            - permissive
          title: Level
          default: moderate
      type: object
      title: LevelConfig
      description: Guardrail with a strict/moderate/permissive sensitivity level.
    ToggleOnlyConfig:
      properties:
        enabled:
          type: boolean
          title: Enabled
          default: true
      type: object
      title: ToggleOnlyConfig
    HallucinationConfig:
      properties:
        enabled:
          type: boolean
          title: Enabled
          default: true
        action:
          type: string
          enum:
            - metadata
            - flag
            - block
          title: Action
          default: metadata
        block_threshold:
          type: number
          maximum: 1
          minimum: 0
          title: Block Threshold
          default: 0.6
      type: object
      title: HallucinationConfig
    MCPSecurityConfig:
      properties:
        enabled:
          type: boolean
          title: Enabled
          default: false
        server_allowlist:
          items:
            type: string
          type: array
          title: Server Allowlist
        server_blocklist:
          items:
            type: string
          type: array
          title: Server Blocklist
        enforce_schema_validation:
          type: boolean
          title: Enforce Schema Validation
          default: true
        max_argument_size_bytes:
          type: integer
          maximum: 1000000
          minimum: 100
          title: Max Argument Size Bytes
          default: 10000
      type: object
      title: MCPSecurityConfig
  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.