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

# Replace Rules

> Replace the network's rules. Rules are directed and allow-only: a member
may start a connection when any rule matches its tags, the peer's tags, and
the port.



## OpenAPI

````yaml https://api.primeintellect.ai/api/v1/sandbox/openapi.json put /api/v1/sandbox/networks/{network_id}/rules
openapi: 3.1.0
info:
  title: PI API
  version: 0.1.0
servers:
  - url: https://api.primeintellect.ai
security: []
paths:
  /api/v1/sandbox/networks/{network_id}/rules:
    put:
      tags:
        - Sandbox Networks
      summary: Replace Rules
      description: >-
        Replace the network's rules. Rules are directed and allow-only: a member

        may start a connection when any rule matches its tags, the peer's tags,
        and

        the port.
      operationId: replace_rules_api_v1_sandbox_networks__network_id__rules_put
      parameters:
        - name: network_id
          in: path
          required: true
          schema:
            type: string
            title: Network Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReplaceRulesRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NetworkResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    ReplaceRulesRequest:
      properties:
        rules:
          items:
            $ref: '#/components/schemas/LanRule'
          type: array
          maxItems: 256
          title: Rules
      type: object
      required:
        - rules
      title: ReplaceRulesRequest
    NetworkResponse:
      properties:
        id:
          type: string
          title: Id
        name:
          type: string
          title: Name
        team_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Team Id
        rules:
          items:
            type: object
          type: array
          title: Rules
        version:
          type: integer
          title: Version
        synced:
          type: boolean
          title: Synced
        created_at:
          type: string
          format: date-time
          title: Created At
        members:
          anyOf:
            - items:
                $ref: '#/components/schemas/NetworkMemberResponse'
              type: array
            - type: 'null'
          title: Members
      type: object
      required:
        - id
        - name
        - team_id
        - rules
        - version
        - synced
        - created_at
      title: NetworkResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    LanRule:
      properties:
        from:
          type: string
          pattern: ^(\*|internet|tag:[a-z0-9][a-z0-9_.-]{0,62})$
          title: From
        to:
          type: string
          pattern: ^(\*|tag:[a-z0-9][a-z0-9_.-]{0,62})$
          title: To
        ports:
          anyOf:
            - items:
                type: integer
                maximum: 65535
                minimum: 1
              type: array
              maxItems: 64
            - type: 'null'
          title: Ports
      type: object
      required:
        - from
        - to
      title: LanRule
      description: >-
        Lets members matching ``from`` start TCP connections to members

        matching ``to`` on ``ports`` (all ports when omitted). A ``from`` of

        ``internet`` instead exposes the listed ``ports`` of members matching

        ``to`` publicly over HTTP at ``https://<port>-<sandbox-id>.<gateway
        domain>``.
    NetworkMemberResponse:
      properties:
        sandbox_id:
          type: string
          title: Sandbox Id
        tags:
          items:
            type: string
          type: array
          title: Tags
        synced:
          type: boolean
          title: Synced
      type: object
      required:
        - sandbox_id
        - tags
        - synced
      title: NetworkMemberResponse
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````