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

# Update Custom Rule

> Project-scoped operation. Successful JSON and status-only responses vary by operation. The service does not declare a stable response schema for this operation; do not assume a collection envelope or undocumented fields.



## OpenAPI

````yaml /openapi-shield.json patch /shield/domains/{domain_id}/custom-rules/{rule_id}
openapi: 3.1.0
info:
  title: Aptranet Cloud Shield API
  version: 1.0.0
  description: >-
    Public project-scoped API. Use the access key and secret together.
    Browser-only organization administration is documented separately. Request
    schemas and query parameters follow the service operation allowlist. Plan
    entitlements apply in addition to API permissions. Some analytics and action
    responses have operation-specific JSON shapes; where the implementation
    provides no stable response contract, the reference deliberately does not
    invent one.
servers:
  - url: https://api.aptranet.com
security:
  - bearerAuth: []
    apiSecret: []
paths:
  /shield/domains/{domain_id}/custom-rules/{rule_id}:
    patch:
      tags:
        - Cloud Shield Custom Rules
      summary: Update Custom Rule
      description: >-
        Project-scoped operation. Successful JSON and status-only responses vary
        by operation. The service does not declare a stable response schema for
        this operation; do not assume a collection envelope or undocumented
        fields.
      operationId: PATCH_shield_domains_domain_id_custom_rules_rule_id_
      parameters:
        - name: domain_id
          in: path
          required: true
          schema:
            type: integer
            title: Domain Id
        - name: rule_id
          in: path
          required: true
          schema:
            type: integer
            title: Rule Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              title: UpdateCustomRule
              properties:
                name:
                  title: Name
                  anyOf:
                    - type: string
                      minLength: 1
                      maxLength: 100
                      example: Block foobar bot
                    - type: 'null'
                description:
                  title: Description
                  anyOf:
                    - type: string
                      maxLength: 100
                    - type: 'null'
                enabled:
                  title: Enabled
                  anyOf:
                    - type: boolean
                    - type: 'null'
                action:
                  anyOf:
                    - type: object
                      additionalProperties: false
                      title: CustomerRuleAction
                      properties:
                        allow:
                          type: object
                          additionalProperties: true
                          title: RuleAllowAction
                          properties: {}
                        block:
                          type: object
                          additionalProperties: false
                          title: RuleBlockAction
                          properties:
                            status_code:
                              type: integer
                              enum:
                                - 403
                                - 405
                                - 418
                                - 429
                              title: RuleBlockStatusCode
                            action_duration:
                              type: string
                              minLength: 1
                              maxLength: 10
                              example: 12h
                              title: Action Duration
                        captcha:
                          type: object
                          additionalProperties: true
                          title: RuleCaptchaAction
                          properties: {}
                        handshake:
                          type: object
                          additionalProperties: true
                          title: RuleHandshakeAction
                          properties: {}
                        monitor:
                          type: object
                          additionalProperties: true
                          title: RuleMonitorAction
                          properties: {}
                        tag:
                          type: object
                          required:
                            - tags
                          title: RuleTagAction
                          properties:
                            tags:
                              type: array
                              minItems: 1
                              maxItems: 5
                              title: Tags
                              items:
                                type: string
                    - type: 'null'
                conditions:
                  title: Conditions
                  anyOf:
                    - type: array
                      minItems: 1
                      maxItems: 5
                      items:
                        type: object
                        additionalProperties: false
                        title: CustomRuleCondition
                        properties:
                          ip:
                            type: object
                            required:
                              - ip_address
                            title: IpCondition
                            properties:
                              negation:
                                type: boolean
                                default: false
                                title: Negation
                              ip_address:
                                type: string
                                format: ipvanyaddress
                                title: Ip Address
                          ip_range:
                            type: object
                            required:
                              - lower_bound
                              - upper_bound
                            title: IpRangeCondition
                            properties:
                              negation:
                                type: boolean
                                default: false
                                title: Negation
                              lower_bound:
                                type: string
                                format: ipvanyaddress
                                title: Lower Bound
                              upper_bound:
                                type: string
                                format: ipvanyaddress
                                title: Upper Bound
                          url:
                            type: object
                            required:
                              - url
                            title: UrlCondition
                            properties:
                              negation:
                                type: boolean
                                default: false
                                title: Negation
                              match_type:
                                type: string
                                enum:
                                  - Exact
                                  - Contains
                                  - Regex
                                default: Contains
                                title: Match Type
                              url:
                                type: string
                                minLength: 1
                                maxLength: 500
                                example: /wp-admin/
                                title: Url
                          user_agent:
                            type: object
                            required:
                              - user_agent
                            title: UserAgentCondition
                            properties:
                              negation:
                                type: boolean
                                default: false
                                title: Negation
                              user_agent:
                                type: string
                                maxLength: 300
                                example: curl/
                                title: User Agent
                              match_type:
                                type: string
                                enum:
                                  - Exact
                                  - Contains
                                default: Contains
                                title: Match Type
                          header:
                            type: object
                            required:
                              - header
                              - value
                            title: HeaderCondition
                            properties:
                              negation:
                                type: boolean
                                default: false
                                title: Negation
                              header:
                                type: string
                                minLength: 1
                                maxLength: 50
                                example: Origin
                                title: Header
                              value:
                                type: string
                                maxLength: 100
                                title: Value
                              match_type:
                                type: string
                                enum:
                                  - Exact
                                  - Contains
                                default: Contains
                                title: Match Type
                          header_exists:
                            type: object
                            required:
                              - header
                            title: HeaderExistsCondition
                            properties:
                              negation:
                                type: boolean
                                default: false
                                title: Negation
                              header:
                                type: string
                                minLength: 1
                                maxLength: 50
                                example: Origin
                                title: Header
                          http_method:
                            type: object
                            required:
                              - http_method
                            title: HttpMethodCondition
                            properties:
                              negation:
                                type: boolean
                                default: false
                                title: Negation
                              http_method:
                                type: string
                                enum:
                                  - CONNECT
                                  - DELETE
                                  - GET
                                  - HEAD
                                  - OPTIONS
                                  - PATCH
                                  - POST
                                  - PUT
                                  - TRACE
                                title: HTTPMethod
                          file_extension:
                            type: object
                            required:
                              - file_extension
                            title: FileExtensionCondition
                            properties:
                              negation:
                                type: boolean
                                default: false
                                title: Negation
                              file_extension:
                                type: array
                                minItems: 1
                                maxItems: 20
                                title: File Extension
                                items:
                                  type: string
                                  minLength: 1
                                  maxLength: 10
                                  example: pdf
                          content_type:
                            type: object
                            required:
                              - content_type
                            title: ContentTypeCondition
                            properties:
                              negation:
                                type: boolean
                                default: false
                                title: Negation
                              content_type:
                                type: array
                                minItems: 1
                                maxItems: 10
                                title: Content Type
                                items:
                                  type: string
                                  minLength: 1
                                  maxLength: 50
                                  example: application/xml
                          country:
                            type: object
                            required:
                              - country_code
                            title: CountryCondition
                            properties:
                              negation:
                                type: boolean
                                default: false
                                title: Negation
                              country_code:
                                type: array
                                minItems: 1
                                maxItems: 100
                                example: CN
                                title: Country Code
                                items:
                                  type: string
                          organization:
                            type: object
                            required:
                              - organization
                            title: OrganizationCondition
                            properties:
                              negation:
                                type: boolean
                                default: false
                                title: Negation
                              organization:
                                type: string
                                maxLength: 100
                                example: UptimeRobot s.r.o
                                title: Organization
                          request_rate:
                            type: object
                            required:
                              - path_pattern
                              - requests
                              - time
                            additionalProperties: false
                            title: RequestRateCondition
                            properties:
                              ips:
                                type: array
                                maxItems: 10
                                title: Ips
                                items:
                                  type: string
                                  format: ipvanyaddress
                              http_methods:
                                type: array
                                title: Http Methods
                                items:
                                  type: string
                                  enum:
                                    - CONNECT
                                    - DELETE
                                    - GET
                                    - HEAD
                                    - OPTIONS
                                    - PATCH
                                    - POST
                                    - PUT
                                    - TRACE
                                  title: HTTPMethod
                              path_pattern:
                                type: string
                                minLength: 1
                                maxLength: 500
                                example: /
                                title: Path Pattern
                              requests:
                                type: integer
                                minimum: 20
                                title: Requests
                              time:
                                type: integer
                                minimum: 1
                                maximum: 3600
                                title: Time
                              user_defined_tag:
                                type: string
                                minLength: 1
                                maxLength: 50
                                title: User Defined Tag
                          owner_types:
                            type: object
                            title: OwnerTypesCondition
                            properties:
                              negation:
                                type: boolean
                                default: false
                                title: Negation
                              owner_types:
                                type: array
                                minItems: 1
                                title: Owner Types
                                items:
                                  type: string
                                  enum:
                                    - COMMERCIAL
                                    - EDUCATIONAL
                                    - GOVERNMENT
                                    - HOSTING_SERVICES
                                    - ISP
                                    - MOBILE_NETWORK
                                    - NETWORK
                                    - RESERVED
                          tags:
                            type: object
                            required:
                              - tags
                            title: TagsCondition
                            properties:
                              negation:
                                type: boolean
                                default: false
                                title: Negation
                              tags:
                                type: array
                                minItems: 1
                                maxItems: 5
                                example: botnetclient
                                title: Tags
                                items:
                                  type: string
                          session_request_count:
                            type: object
                            required:
                              - request_count
                            title: SessionRequestCountCondition
                            properties:
                              negation:
                                type: boolean
                                default: false
                                title: Negation
                              request_count:
                                type: integer
                                title: Request Count
                          user_defined_tags:
                            type: object
                            required:
                              - tags
                            title: UserDefinedTagsCondition
                            properties:
                              negation:
                                type: boolean
                                default: false
                                title: Negation
                              tags:
                                type: array
                                minItems: 1
                                maxItems: 10
                                title: Tags
                                items:
                                  type: string
                                  minLength: 1
                                  maxLength: 50
                          ja3:
                            type: object
                            required:
                              - ja3_fingerprints
                            title: Ja3Condition
                            properties:
                              negation:
                                type: boolean
                                default: false
                                title: Negation
                              ja3_fingerprints:
                                type: array
                                minItems: 1
                                maxItems: 10
                                title: Ja3 Fingerprints
                                items:
                                  type: string
                                  example: e7d705a3286e19ea42f587b344ee6865
                          ja4:
                            type: object
                            required:
                              - ja4_fingerprints
                            title: Ja4Condition
                            properties:
                              negation:
                                type: boolean
                                default: false
                                title: Negation
                              ja4_fingerprints:
                                type: array
                                minItems: 1
                                maxItems: 10
                                title: Ja4 Fingerprints
                                items:
                                  type: string
                                  example: t13d3113h2_e8f1e7e78f70_ce5650b735ce
                    - type: 'null'
      responses:
        2XX:
          description: Successful response.
        default:
          description: >-
            Request rejected or service unavailable. See the error code and
            description; refresh before retrying a mutation whose result is
            uncertain.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
        error_description:
          type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Project API access key.
    apiSecret:
      type: apiKey
      in: header
      name: Aptranet-Secret
      description: Current secret for the access key.

````

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