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

# Create a named volume



## OpenAPI

````yaml /api-reference/openapi.json post /v1/volumes
openapi: 3.1.0
info:
  title: microsandbox cloud API
  description: >-
    REST API for microsandbox cloud: sandbox and volume lifecycle, organization
    context, quotas, usage, and audit events, authenticated with an organization
    API key.
  version: 0.1.0
servers:
  - url: https://api.microsandbox.dev
security:
  - api_key: []
paths:
  /v1/volumes:
    post:
      tags:
        - Volumes
      summary: Create a named volume
      operationId: create_volume
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateVolumeRequest'
        required: true
      responses:
        '200':
          description: Volume created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VolumeResponse'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: invalid_request
                  message: invalid request
                  details: null
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: invalid_api_key
                  message: unauthorized
                  details: null
        '409':
          description: Volume name already in use
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: name_already_exists
                  message: '''name'' already exists'
                  details: null
      security:
        - api_key: []
components:
  schemas:
    CreateVolumeRequest:
      type: object
      description: POST /v1/orgs/{slug}/volumes
      required:
        - name
      properties:
        capacity_gib:
          type:
            - integer
            - 'null'
          format: int32
          description: >-
            Optional per-volume storage cap in GiB (#496). Omitted/`null` = no

            per-volume limit (the org's plan cap still governs). Must be `>= 1`
            and

            `<= the org's storage cap`.
          minimum: 0
        labels:
          type: object
          description: >-
            User-defined labels (free-form string map). Omitted = none. Keys
            using a

            platform-reserved prefix are rejected.
          additionalProperties:
            type: string
          propertyNames:
            type: string
        name:
          type: string
          description: >-
            Volume name, unique within the org. Lowercase alphanumeric with
            single

            internal hyphens (e.g. `team-ml`). Creates a `managed` volume; the
            host

            disk is system-provisioned and has no name.
        storage:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/VolumeType'
              description: >-
                Physical backing for the volume. Omitted = `block` (the default
                and only

                value today).
    VolumeResponse:
      type: object
      description: >-
        Volume metadata returned in list/create responses. The GCS storage path
        is

        derived (not stored) and never exposed.
      required:
        - id
        - kind
        - storage
        - status
        - labels
        - created_at
        - updated_at
      properties:
        capacity_bytes:
          type:
            - integer
            - 'null'
          format: int64
          description: >-
            The volume's configured per-volume storage cap in bytes, or `null`
            when

            no cap is set (#496). Derived from the stored `capacity_gib` (the
            user's

            configured intent) - the effective ceiling is `min(this, org cap)`.
          minimum: 0
        created_at:
          type: string
          format: date-time
        id:
          type: string
          format: uuid
        kind:
          $ref: '#/components/schemas/VolumeKind'
          description: |-
            `host` - the org's shared host disk (not deletable); `managed` - a
            user-created named volume.
        labels:
          type: object
          description: User-defined labels (empty object when none set).
          additionalProperties:
            type: string
          propertyNames:
            type: string
        name:
          type:
            - string
            - 'null'
          description: |-
            User-facing name. `null` for the host volume (it has no name; it's
            identified by `kind`).
        status:
          $ref: '#/components/schemas/VolumeStatus'
        storage:
          $ref: '#/components/schemas/VolumeType'
          description: How the volume is physically backed (`block` today).
        updated_at:
          type: string
          format: date-time
        used_bytes:
          type:
            - integer
            - 'null'
          format: int64
          description: >-
            Bytes currently used under this volume's subtree. `null` when usage
            is

            unavailable - the usage service is disabled or unreachable (list
            degrades

            gracefully rather than failing) - or on create/delete, which don't
            sample

            it.
          minimum: 0
    ErrorResponse:
      type: object
      description: Error envelope returned by every non-2xx response.
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              description: Stable machine-readable error code, e.g. `invalid_api_key`.
            message:
              type: string
              description: Human-readable description of the error.
            details:
              type:
                - object
                - 'null'
              description: Optional structured context for the error.
    VolumeType:
      type: string
      description: >-
        How a volume is physically backed - distinct from [`VolumeKind`]
        (ownership).

        Every volume is `Block` today; the enum exists so future backings can be
        added

        (and reported to the SDK) without another schema change.
      enum:
        - block
    VolumeKind:
      type: string
      description: >-
        What kind of volume this is - its storage source / role. The host volume
        is

        the org's single shared "host disk"; managed volumes are user-created,
        named,

        platform-provisioned (JuiceFS over our object store). (A future
        `External`

        variant - bring-your-own S3/GCS - is intentionally out of scope for
        now.)
      enum:
        - host
        - managed
    VolumeStatus:
      type: string
      description: Lifecycle status of a volume.
      enum:
        - active
        - deleting
  securitySchemes:
    api_key:
      type: http
      scheme: bearer
      description: Organization API key (msb_…) - org-scoped programmatic access.

````