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

# Set a Cloud Defender country rule

> Create or change a domain's country rule. `action: block` refuses the listed `countries`, `action: allow` accepts only them; `tor` and `unknown` decide what happens to Tor exits and addresses with no known country. A new rule starts in `test`, counting what it would have refused, until you set `mode: enforced`. Whitelisted addresses always pass. Applied within about two minutes. Owners and security officers with a live licence.



## OpenAPI

````yaml put /api/v1/cloud-defender/{id}/countries
openapi: 3.1.0
info:
  title: Aegister API
  version: 2.10.0
servers: []
security: []
paths:
  /api/v1/cloud-defender/{id}/countries:
    put:
      tags:
        - cloud-defender
      summary: Set a Cloud Defender domain's country rule
      description: >-
        Creates the rule (in test mode) or changes it. A change to the countries
        or the action of a rule in test

        restarts its "would have refused" count; back to test does too. Applied
        by the host proxy within about two

        minutes. Whitelisted addresses always pass.
      operationId: cloud_defender_countries_update
      parameters:
        - in: path
          name: id
          schema:
            type: integer
          required: true
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                action:
                  type: string
                  enum:
                    - block
                    - allow
                countries:
                  type: array
                  items:
                    type: string
                  description: ISO 3166-1 alpha-2 codes.
                tor:
                  type: boolean
                unknown:
                  type: boolean
                mode:
                  type: string
                  enum:
                    - test
                    - enforced
            examples:
              RefuseTwoCountriesAndTor(startsInTest):
                value:
                  action: block
                  countries:
                    - KP
                    - RU
                  tor: true
                summary: Refuse two countries and Tor (starts in test)
              EnforceIt:
                value:
                  mode: enforced
                summary: Enforce it
      responses:
        '200':
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: integer
                    description: |-
                      Any value different from 0 indicates an error.  
                      More details can be found in `messages`.
                    minimum: 0
                    maximum: 0
                    examples:
                      - 0
                  messages:
                    type: array
                    description: >-
                      If `error` is `1`, contains zero or more details on the
                      error.
                    examples:
                      - []
                  data:
                    type:
                      - object
                      - 'null'
                    description: Null when the domain has no country rule.
                    properties:
                      action:
                        type: string
                        enum:
                          - block
                          - allow
                        description: >-
                          `block`: refuse the countries listed. `allow`: accept
                          only them.
                      countries:
                        type: array
                        items:
                          type: string
                        description: ISO 3166-1 alpha-2 codes.
                      tor:
                        type: boolean
                        description: Also refuse the Tor network.
                      unknown:
                        type: boolean
                        description: Also refuse addresses whose country is unknown.
                      mode:
                        type: string
                        enum:
                          - test
                          - enforced
                        description: >-
                          `test`: requests it would refuse are counted and let
                          through.
                      test_hits:
                        type: integer
                        description: Requests it would have refused since `test_since`.
                      test_since:
                        type:
                          - string
                          - 'null'
                        format: date-time
                      created_at:
                        type: string
                        format: date-time
                      edited_at:
                        type:
                          - string
                          - 'null'
                        format: date-time
              examples:
                Set:
                  value:
                    error: 0
                    messages: []
                    data:
                      action: block
                      countries:
                        - KP
                        - RU
                      tor: true
                      unknown: false
                      mode: test
                      test_hits: 0
                      test_since: '2026-10-28T09:30:00Z'
                      created_at: '2026-10-28T09:30:00Z'
                      edited_at: '2026-10-28T09:30:00Z'
          description: ''
        '400':
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: integer
                    description: |-
                      Any value different from 0 indicates an error.  
                      More details can be found in `messages`.
                    minimum: 0
                    maximum: 0
                    examples:
                      - 1
                  messages:
                    type: array
                    description: >-
                      If `error` is `1`, contains zero or more details on the
                      error.
                    examples:
                      - - Invalid data provided
                        - country_invalid
          description: ''
        '404':
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: integer
                    description: |-
                      Any value different from 0 indicates an error.  
                      More details can be found in `messages`.
                    minimum: 0
                    maximum: 0
                    examples:
                      - 1
                  messages:
                    type: array
                    description: >-
                      If `error` is `1`, contains zero or more details on the
                      error.
                    examples:
                      - []
          description: ''
      security:
        - ApiKeyAuth: []
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-Aegister-Token

````

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