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

# Create a URL for a port

> Gives a port of the sandbox an HTTPS URL, such as `https://agent-42-3000-k3m7q2v9.vmsdev.run`. The URL needs its token, unless you send `public: true`. A sandbox has up to 20 URLs. Needs the `sandboxes:write` scope.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/sandboxes/{id}/urls
openapi: 3.1.0
info:
  title: VMS API
  version: 1.0.0
  description: >-
    The public API of a VMS workspace. Each request needs an API key of the
    workspace in the Authorization header.
servers:
  - url: https://vms.dev/api
    description: The VMS API
security:
  - apiKey: []
paths:
  /v1/sandboxes/{id}/urls:
    post:
      tags:
        - Sandboxes
      summary: Create a URL for a port
      description: >-
        Gives a port of the sandbox an HTTPS URL, such as
        `https://agent-42-3000-k3m7q2v9.vmsdev.run`. The URL needs its token,
        unless you send `public: true`. A sandbox has up to 20 URLs. Needs the
        `sandboxes:write` scope.
      operationId: createSandboxUrl
      parameters:
        - in: path
          name: id
          schema:
            type: string
            example: sbx_06d8k3m7q2v9x4b1n5c0e8f2ja
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSandboxUrlBody'
      responses:
        '201':
          description: The new URL.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SandboxUrl'
        '400':
          description: The body is not valid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: The API key is missing, not correct, revoked, or expired.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: The API key does not have the scope of the endpoint.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: The workspace has no sandbox with this ID.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: The sandbox has a URL for this port, or it has 20 URLs.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: The API key sent more than 1,200 requests in one minute.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    CreateSandboxUrlBody:
      type: object
      properties:
        port:
          type: integer
          minimum: 1
          maximum: 65535
          description: >-
            The port in the sandbox, 1 to 65535. Port 22, port 7911, and port
            7912 are not permitted.
          example: 3000
        public:
          description: >-
            Send true to open the URL to everyone, with no token. The default is
            false.
          type: boolean
      required:
        - port
    SandboxUrl:
      type: object
      properties:
        id:
          type: string
          example: url_06d8k3m7q2v9x4b1n5c0e8f2jb
        sandboxId:
          type: string
          example: sbx_06d8k3m7q2v9x4b1n5c0e8f2ja
        port:
          type: integer
          minimum: 1
          maximum: 65535
          example: 3000
        url:
          type: string
          format: uri
          description: >-
            The HTTPS address of the port. It contains the sandbox name, so it
            changes when you rename the sandbox.
          example: https://agent-42-3000-k3m7q2v9.vmsdev.run
        public:
          type: boolean
          description: True if the URL works without the token.
        token:
          description: >-
            Open the URL one time with ?_token=<token>. The browser then keeps a
            cookie for the URL. It is null for an API key without
            sandboxes:write.
          example: vmsu_Gq3n0Yb1c2d3e4f5g6h7i8j9k0l1m2n3o4p5q6r7s8t
          type:
            - string
            - 'null'
        createdAt:
          type: string
          format: date-time
          pattern: >-
            ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$
        updatedAt:
          type: string
          format: date-time
          pattern: >-
            ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$
      required:
        - id
        - sandboxId
        - port
        - url
        - public
        - token
        - createdAt
        - updatedAt
      additionalProperties: false
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: no_capacity
            message:
              type: string
            requestId:
              type:
                - string
                - 'null'
            retryAfterSeconds:
              type: integer
              minimum: 0
              maximum: 9007199254740991
            sandboxId:
              description: The sandbox that the error is about.
              type: string
          required:
            - code
            - message
            - requestId
          additionalProperties: false
      required:
        - error
      additionalProperties: false
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: An API key that starts with vms_. Make one in Settings > API keys.

````

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