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

# Expose a sandbox port

> Expose a sandbox port on a managed domain. POST /sandboxes/{id}/ports in the Ravion API reference.



## OpenAPI

````yaml https://api.ravion.com/openapi.yaml post /sandboxes/{id}/ports
openapi: 3.0.0
info:
  title: Ravion
  version: 0.0.0
servers:
  - url: https://api.ravion.com
security:
  - BearerAuth: []
tags:
  - name: Projects
  - name: Environments
  - name: FeatureFlags
  - name: Pipelines
  - name: PipelineRuns
  - name: TerraformResources
  - name: TerraformExecutionSummaries
  - name: PipelineStepExecutions
  - name: AwsCloudWatch
  - name: AwsAmp
  - name: PipelineVersions
  - name: Organizations
  - name: Stacks
  - name: StackWorkspaces
  - name: Auth
  - name: OAuth
  - name: User
  - name: Health
  - name: Memberships
  - name: ServiceAccounts
  - name: Integrations
  - name: AwsDefaultNetworks
  - name: AwsAccounts
  - name: ApiKeys
  - name: EksPrometheus
  - name: EksLoki
  - name: ExecutionEnvironments
  - name: ModuleDefinitions
  - name: ModuleCategories
  - name: ModuleVersions
  - name: ModuleInstances
  - name: DefaultValueDefinitions
  - name: DefaultValues
  - name: CodeSources
  - name: Github
  - name: GitHub Actions
  - name: Alerts
  - name: Gitlab
  - name: Slack
  - name: Git
  - name: MergeQueues
  - name: Values
  - name: Deployments
  - name: DeploymentResources
  - name: InfrastructureEvents
  - name: WebSocket
  - name: Domains
  - name: AcmCertificates
  - name: NotificationDestinations
  - name: NotificationDispatches
  - name: NotificationEvents
  - name: NotificationRules
  - name: Activity
  - name: Describe
  - name: Reports
  - name: BillingPlans
  - name: BillingAccounts
  - name: BillingCycles
  - name: BillingUsageSummaries
  - name: BillingAddOns
  - name: BillingInvoices
  - name: Authorization
  - name: Sandboxes
  - name: SandboxCommands
  - name: SandboxPorts
  - name: Apps
paths:
  /sandboxes/{id}/ports:
    post:
      tags:
        - SandboxPorts
      summary: Expose a sandbox port
      description: >-
        Expose a sandbox port on a managed domain. The sandbox must have a
        module instance, and the domain must be a new label under a wildcard
        managed domain in that module instance's environment or, with `replace`,
        a domain the module instance serves today. Returns 201 with the port
        once its route is set up, which can take up to 90 seconds. Fails with
        409 when the domain is already in use and 422 when the domain is not
        eligible.
      operationId: CreateSandboxPort
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              additionalProperties: false
              properties:
                data:
                  $ref: '#/components/schemas/SandboxPortCreateRequest'
              required:
                - data
              type: object
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                additionalProperties: false
                properties:
                  data:
                    $ref: '#/components/schemas/SandboxPort'
                required:
                  - data
                type: object
          description: >-
            The request has succeeded and a new resource has been created as a
            result.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors.UserFacingErrorData'
          description: The request is invalid or malformed.
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors.UserFacingErrorData'
          description: You are not authenticated
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors.UserFacingErrorData'
          description: You do not have permission to access this resource.
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors.UserFacingErrorData'
          description: The server cannot find the requested resource.
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors.UserFacingErrorData'
          description: The request conflicts with the current state of the server.
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors.UserFacingErrorData'
          description: Client error
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors.UserFacingErrorData'
          description: Server error
components:
  schemas:
    SandboxPortCreateRequest:
      additionalProperties: false
      description: A port to expose on a managed domain.
      properties:
        domain:
          description: >-
            Fully-qualified domain name to serve the port on. Either a new label
            under a wildcard managed domain of the sandbox's module instance's
            environment (such as `dev.api.example.com` under
            `*.api.example.com`), or, with `replace`, a domain the sandbox's
            module instance serves today.
          type: string
        port:
          description: Port the sandbox listens on.
          format: int32
          maximum: 65535
          minimum: 1
          type: integer
        replace:
          description: >-
            Take over `domain` from the sandbox's module instance: requests to
            it reach the sandbox instead of the module until the port is closed.
            Default false.
          type: boolean
      required:
        - port
        - domain
      type: object
    SandboxPort:
      additionalProperties: false
      description: A sandbox port exposed on one of your managed domains.
      properties:
        domain:
          description: Fully-qualified domain name the port is served on.
          type: string
        error:
          description: Why the route could not be set up, when `status` is `ERROR`.
          type: string
        port:
          description: Port the sandbox listens on.
          format: int32
          maximum: 65535
          minimum: 1
          type: integer
        status:
          allOf:
            - $ref: '#/components/schemas/Sandbox.PortStatus'
          description: Whether traffic reaches the port yet.
        takeover:
          description: >-
            True when the domain was taken over from the module instance that
            normally serves it. Closing the port gives the domain back.
          type: boolean
        url:
          description: URL that reaches the port, always `https://`.
          type: string
      required:
        - port
        - domain
        - url
        - status
        - takeover
      type: object
    Errors.UserFacingErrorData:
      additionalProperties: false
      description: |-
        User-facing error presentation data.
        This is what the API returns to the frontend after formatting ErrorData
        using CEL templates from the error registry.

        Used for both:
        - Error fields on domain models (e.g., PipelineRun.error)
        - API error response bodies (HTTP 4xx/5xx responses)
      properties:
        action:
          allOf:
            - $ref: '#/components/schemas/Errors.Action'
          description: Optional action to help resolve the error
        code:
          description: Full error code, e.g., "Ravion:Pipeline:NOT_FOUND"
          type: string
        description:
          description: Additional description with more details
          type: string
        details:
          description: Structured details rendered as user-facing sections.
          items:
            $ref: '#/components/schemas/Errors.UserFacingErrorDetailSection'
          type: array
        isInternal:
          description: >-
            Indicates whether this error is internal (only set when
            ShowInternal=true).

            This allows SUPERADMINs to identify internal errors while viewing
            full details.
          type: boolean
        message:
          description: Main error message (required)
          type: string
        metadata:
          additionalProperties: {}
          description: >-
            Error params/metadata. Stripped for internal errors unless
            superadmin.
          type: object
        requestId:
          description: Request ID for correlating errors with server logs.
          type: string
      required:
        - code
        - message
      type: object
    Sandbox.PortStatus:
      description: >-
        Whether traffic reaches an exposed port. `PENDING`: the route is being
        set up. `ACTIVE`: the URL serves the sandbox. `ERROR`: the route could
        not be set up; see `error`.
      enum:
        - PENDING
        - ACTIVE
        - ERROR
      type: string
    Errors.Action:
      additionalProperties: false
      description: Action to help user resolve the error
      properties:
        label:
          description: Button/link label text
          type: string
        url:
          description: URL to navigate to for resolution
          type: string
      required:
        - label
        - url
      type: object
    Errors.UserFacingErrorDetailSection:
      additionalProperties: false
      description: Structured user-facing error detail section.
      properties:
        items:
          description: List of detail values for this section.
          items:
            type: string
          type: array
        object:
          additionalProperties: {}
          description: Structured detail payload for object rendering.
          type: object
        render:
          description: Rendering hint for clients. Valid values are list or object.
          type: string
        title:
          description: Detail section title shown in the UI.
          type: string
      required:
        - title
        - render
      type: object
  securitySchemes:
    BearerAuth:
      scheme: Bearer
      type: http

````

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