> ## 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 many sandboxes

> Creates up to 500 sandboxes in one request. Give each item the fields of a create. The API creates the items one after the other. It returns a result for each item, in the sequence of the items: the ID of the new sandbox, or the error message. Needs the `sandboxes:write` scope.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/sandboxes/create-many
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/create-many:
    post:
      tags:
        - Sandboxes
      summary: Create many sandboxes
      description: >-
        Creates up to 500 sandboxes in one request. Give each item the fields of
        a create. The API creates the items one after the other. It returns a
        result for each item, in the sequence of the items: the ID of the new
        sandbox, or the error message. Needs the `sandboxes:write` scope.
      operationId: createManySandboxes
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateManySandboxesBody'
      responses:
        '200':
          description: A result for each item.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SandboxBulkResult'
        '400':
          description: The request 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'
        '429':
          description: The API key sent more than 1,200 requests in one minute.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    CreateManySandboxesBody:
      type: object
      properties:
        items:
          minItems: 1
          maxItems: 500
          type: array
          items:
            $ref: '#/components/schemas/CreateSandboxBody'
      required:
        - items
    SandboxBulkResult:
      type: object
      properties:
        succeeded:
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
        failed:
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
        message:
          type:
            - string
            - 'null'
        data:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
                minimum: -9007199254740991
                maximum: 9007199254740991
              id:
                type:
                  - string
                  - 'null'
              error:
                type:
                  - string
                  - 'null'
            required:
              - index
              - id
              - error
            additionalProperties: false
      required:
        - succeeded
        - failed
        - message
        - data
      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
    CreateSandboxBody:
      type: object
      properties:
        size:
          $ref: '#/components/schemas/SandboxSize'
          description: >-
            The size of the sandbox. Send it for each new sandbox. A fork
            without size has the size of its source.
        fromSandbox:
          description: >-
            The ID of a running or stopped sandbox to fork. The fork gets the
            files and the environment variables of this sandbox, and a new name,
            hostname, SSH host keys, IPv6 address, and agent key.
          example: sbx_06d8k3m7q2v9x4b1n5c0e8f2ja
          type: string
          minLength: 1
        freshSnapshot:
          description: >-
            Send it only with fromSandbox. When the source runs, true (the
            default) takes a new snapshot of the source first, so that the fork
            has the latest files. false starts the fork from the last snapshot
            of the source. A stopped source has no new files, so this field has
            no effect on it.
          type: boolean
        count:
          description: >-
            Send it only with fromSandbox: the number of forks to make, 1 to
            100. The answer is the first fork, with each fork in batch. If one
            fork cannot start, the API makes no fork. Do not send name with a
            count of more than 1.
          example: 10
          type: integer
          minimum: 1
          maximum: 100
        name:
          type: string
          pattern: ^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$
          description: >-
            A name that is unique in the workspace: 1 to 63 lowercase letters,
            digits, and hyphens. It cannot start or end with a hyphen.
          example: agent-42
        labels:
          type: object
          propertyNames:
            type: string
            pattern: ^[A-Za-z0-9](?:[A-Za-z0-9._/-]{0,61}[A-Za-z0-9])?$
          additionalProperties:
            type: string
            maxLength: 255
          description: >-
            Up to 50 labels. A key has 1 to 63 letters, digits, and the
            characters . _ / -, and starts and ends with a letter or a digit. A
            value has up to 255 characters.
          example:
            project: web
            agent: reviewer
        env:
          $ref: '#/components/schemas/SandboxEnvironment'
        files:
          maxItems: 20
          type: array
          items:
            $ref: '#/components/schemas/SandboxFile'
          description: >-
            Files to write when the sandbox starts the first time: up to 20,
            with up to 65536 characters of content in total. The owner of a file
            in /home/user is user.
        template:
          description: >-
            The ID or the name of a ready template, or a share code of a
            template of another workspace. The sandbox starts with the files of
            the template.
          example: node-22-base
          type: string
          minLength: 1
        stopAfterSeconds:
          anyOf:
            - type: integer
              minimum: 60
              maximum: 2592000
            - type: 'null'
          description: >-
            The seconds that the sandbox runs after each start before it stops
            on its own: 60 to 2592000 (30 days). The default is 3600 (1 hour).
            Send null to turn off auto-stop. Do not send it with stopAt.
          example: 3600
        stopAt:
          anyOf:
            - 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))$
            - type: 'null'
          description: >-
            The time when the sandbox stops on its own. It must be in the
            future. Send null to turn off auto-stop. Do not send it with
            stopAfterSeconds.
          example: '2026-11-16T12:00:00Z'
        failFast:
          description: >-
            Answer within 1.5 seconds. If the API cannot answer in time, it
            answers 503 no_capacity.
          type: boolean
    SandboxSize:
      type: string
      enum:
        - small
        - medium
        - large
        - xlarge
      description: The vCPU, RAM, and disk of a sandbox.
    SandboxEnvironment:
      type: object
      propertyNames:
        type: string
        pattern: ^[A-Za-z_][A-Za-z0-9_]{0,127}$
      additionalProperties:
        type: string
        maxLength: 4096
      description: >-
        Environment variables for each command, shell, and SSH session of the
        sandbox: up to 100. A name has letters, digits, and _, and does not
        start with a digit. A value has up to 4096 characters. The API does not
        show the values again.
      example:
        NODE_ENV: production
    SandboxFile:
      type: object
      properties:
        path:
          type: string
          minLength: 1
          maxLength: 4096
          pattern: ^\/
          description: The absolute path of the file in the sandbox.
          example: /home/user/.npmrc
        content:
          type: string
        encoding:
          description: The encoding of content. The default is utf8.
          type: string
          enum:
            - utf8
            - base64
        mode:
          description: An octal mode, such as 0644.
          example: '0644'
          type: string
          pattern: ^0[0-7]{3,4}$
      required:
        - path
        - content
  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.