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

# Update Sandbox Egress Policy Endpoint

> Replace the egress policy of a running or paused VM sandbox.

The replacement is complete, never a merge. The request returns 202 after
the desired generation is persisted; durable action dispatch continues
asynchronously until accepted. A paused sandbox receives it on resume. The applied callback updates the status
endpoint; new connections follow the replacement once applied and
established flows are not revoked.

## Rate Limit

120 requests per 60 seconds per IP and token per sandbox.


## OpenAPI

````yaml https://api.primeintellect.ai/api/v1/sandbox/openapi.json put /api/v1/sandbox/{sandbox_id}/egress-policy
openapi: 3.1.0
info:
  title: PI API
  version: 0.1.0
servers:
  - url: https://api.primeintellect.ai
security: []
paths:
  /api/v1/sandbox/{sandbox_id}/egress-policy:
    put:
      tags:
        - Sandbox
      summary: Update Sandbox Egress Policy Endpoint
      description: >-
        Replace the egress policy of a running or paused VM sandbox.


        The replacement is complete, never a merge. The request returns 202
        after

        the desired generation is persisted; durable action dispatch continues

        asynchronously until accepted. A paused sandbox receives it on resume.
        The applied callback updates the status

        endpoint; new connections follow the replacement once applied and

        established flows are not revoked.
      operationId: >-
        update_sandbox_egress_policy_endpoint_api_v1_sandbox__sandbox_id__egress_policy_put
      parameters:
        - name: sandbox_id
          in: path
          required: true
          schema:
            type: string
            title: Sandbox Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateSandboxEgressPolicyRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SandboxEgressPolicyStatusResponse'
        '401':
          description: Authorization failed
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    UpdateSandboxEgressPolicyRequest:
      properties:
        allowlist:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Allowlist
        denylist:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Denylist
        rules:
          anyOf:
            - additionalProperties:
                $ref: '#/components/schemas/VmHeaderRule'
              type: object
            - type: 'null'
          title: Rules
      type: object
      title: UpdateSandboxEgressPolicyRequest
      description: >-
        Full replacement of a running VM sandbox's egress policy.


        Exactly one of allowlist or denylist must be non-null. An empty
        allowlist

        denies all egress; an empty denylist restores allow-all. ``rules`` is
        part

        of the same complete replacement: omitting it clears the rules.
    SandboxEgressPolicyStatusResponse:
      properties:
        policy:
          $ref: '#/components/schemas/SandboxEgressPolicyBody'
        generation:
          type: integer
          minimum: 0
          title: Generation
          description: Desired policy generation persisted by the platform.
        applied_generation:
          type: integer
          minimum: -1
          title: Applied Generation
          description: >-
            Generation last reported applied by the sandbox's node, or -1 when
            no network policy has been successfully applied.
        applied:
          type: boolean
          title: Applied
          description: >-
            Whether the node reports the exact desired generation as applied.
            Never derived from the platform database alone.
      type: object
      required:
        - policy
        - generation
        - applied_generation
        - applied
      title: SandboxEgressPolicyStatusResponse
      description: Desired vs applied egress policy state for a VM sandbox.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    VmHeaderRule:
      properties:
        headers:
          additionalProperties:
            type: string
          type: object
          title: Headers
      type: object
      required:
        - headers
      title: VmHeaderRule
      description: |-
        Headers to set on HTTPS requests to one rule host.

        Each value is a template that may contain "${prime.secrets.<name>}"
        references; a set header replaces any same-name header the sandbox sent.
    SandboxEgressPolicyBody:
      properties:
        allowlist:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Allowlist
        denylist:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Denylist
        rules:
          anyOf:
            - additionalProperties:
                $ref: '#/components/schemas/VmHeaderRule'
              type: object
            - type: 'null'
          title: Rules
      type: object
      title: SandboxEgressPolicyBody
      description: 'The desired egress policy: at most one list is non-null.'
    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

````