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

# Add correspondent policy rule

> Add one allow/block rule for a direction of a scope's policy. Requires an account-wide API key.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/policy/rules
openapi: 3.0.3
info:
  title: OpenMail API
  description: >-
    Email infrastructure API for AI agents. Create inboxes, send and receive
    email, and get real-time notifications via webhooks.
  version: 1.0.0
  license:
    name: Proprietary
servers:
  - url: https://api.openmail.sh
security:
  - bearerAuth: []
tags:
  - name: pods
    description: Isolated sub-accounts for your end users or tenants
  - name: inboxes
    description: Email inboxes and their webhook configuration
  - name: messages
    description: Sending and listing messages
  - name: threads
    description: Conversation threads and read status
  - name: attachments
    description: Downloading and extracting text from attachments
  - name: policy
    description: >-
      Correspondent policy — provider-enforced allow/block rules and allowlist
      mode, scoped per account, pod, or inbox. Account-wide key only.
  - name: feedback
    description: Reporting bugs, friction, and feature requests to the OpenMail team
paths:
  /v1/policy/rules:
    post:
      tags:
        - policy
      summary: Add correspondent policy rule
      description: >-
        Add one allow/block rule for a direction of a scope's policy. Requires
        an account-wide API key.
      operationId: addPolicyRule
      parameters:
        - schema:
            type: string
          in: query
          name: podId
          required: false
          description: >-
            Confine the operation to one pod's policy. Accepts the pod ID.
            Mutually exclusive with `inboxId`.
        - schema:
            type: string
          in: query
          name: inboxId
          required: false
          description: >-
            Confine the operation to one inbox's policy. Mutually exclusive with
            `podId`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
                - type
                - value
              properties:
                type:
                  type: string
                  enum:
                    - allow
                    - block
                value:
                  type: string
                  minLength: 3
                  maxLength: 253
                  description: >-
                    An email address (user@example.com) or a whole domain
                    (example.com).
                direction:
                  type: string
                  enum:
                    - inbound
                    - outbound
                  description: >-
                    `inbound` governs who may send to the inbox; `outbound`
                    governs who the inbox may send to (enforced across To, Cc,
                    and Reply-To on every send path).
      responses:
        '201':
          description: Rule created
          content:
            application/json:
              schema:
                description: Rule created
                type: object
                additionalProperties: true
        '403':
          description: The authenticating key is scoped and cannot manage policy
          content:
            application/json:
              schema:
                description: The authenticating key is scoped and cannot manage policy
                allOf:
                  - $ref: '#/components/schemas/Error'
        '404':
          description: Pod or inbox not found
          content:
            application/json:
              schema:
                description: Pod or inbox not found
                allOf:
                  - $ref: '#/components/schemas/Error'
        '409':
          description: An identical rule already exists (`rule_exists`)
          content:
            application/json:
              schema:
                description: An identical rule already exists (`rule_exists`)
                allOf:
                  - $ref: '#/components/schemas/Error'
        '422':
          description: The value is not a valid email or domain
          content:
            application/json:
              schema:
                description: The value is not a valid email or domain
                allOf:
                  - $ref: '#/components/schemas/Error'
components:
  schemas:
    Error:
      type: object
      additionalProperties: true
      properties:
        error:
          type: string
        message:
          type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API key

````