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

# Create Volume

> Create a volume for a specific app using the details provided in the request body.




## OpenAPI

````yaml /api/machines/openapi.json post /v1/apps/{app_name}/volumes
openapi: 3.1.0
info:
  title: Machines API
  description: >-
    This site hosts documentation generated from the Fly.io Machines API OpenAPI
    specification. Visit our complete [Machines API
    docs](https://fly.io/docs/machines/api/) for how to get started, more
    information about each endpoint, parameter descriptions, and examples.
  contact: {}
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
  version: '1.0'
servers:
  - url: https://api.machines.dev
security:
  - FlyBearerAuth: []
tags:
  - name: Apps
    description: >-
      This site hosts documentation generated from the Fly.io Machines API
      OpenAPI specification. Visit our complete [Machines API
      docs](https://fly.io/docs/machines/api/apps-resource/) for details about
      using the Apps resource.
  - name: Machines
    description: >-
      This site hosts documentation generated from the Fly.io Machines API
      OpenAPI specification. Visit our complete [Machines API
      docs](https://fly.io/docs/machines/api/machines-resource/) for details
      about using the Machines resource.
  - name: TLS Certificates
    description: >
      This site hosts documentation generated from the Fly.io Machines API
      OpenAPI specification. Visit our complete [Machines API
      docs](https://fly.io/docs/machines/api/certificates-resource/) for details
      about using the TLS Certificates resource.
  - name: Volumes
    description: >-
      This site hosts documentation generated from the Fly.io Machines API
      OpenAPI specification. Visit our complete [Machines API
      docs](https://fly.io/docs/machines/api/volumes-resource/) for details
      about using the Volumes resource.
  - name: Postgres Clusters
    description: >-
      Create and manage Postgres clusters, including databases, users,
      extensions, backups, and app attachments.
externalDocs:
  url: https://fly.io/docs/machines/working-with-machines/
paths:
  /v1/apps/{app_name}/volumes:
    post:
      tags:
        - Volumes
      summary: Create Volume
      description: >
        Create a volume for a specific app using the details provided in the
        request body.
      operationId: Volumes_create
      parameters:
        - name: app_name
          in: path
          description: Fly App Name
          required: true
          schema:
            type: string
      requestBody:
        description: Request body
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateVolumeRequest'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Volume'
components:
  schemas:
    CreateVolumeRequest:
      type: object
      properties:
        auto_backup_enabled:
          type: boolean
          description: Take daily automatic snapshots of the volume. Defaults to `true`.
        compute:
          type: object
          description: >-
            Requirements of the Machine that will use the volume, so that the
            volume is placed on a

            host that can run it. Uses `cpus`, `memory_mb`, `cpu_kind`,
            `host_dedication_id`, and

            `required_host_features`.
          allOf:
            - $ref: '#/components/schemas/fly.MachineGuest'
        compute_image:
          type: string
          description: Ignored.
        encrypted:
          type: boolean
          description: >-
            Encrypt the volume at rest. Defaults to true. When forking, the
            source volume's setting

            is used.
        fstype:
          type: string
          description: >-
            Filesystem to format the volume with: `ext4`, or `raw` for an
            unformatted block device.
          enum:
            - ext4
            - raw
        name:
          type: string
          description: >-
            Name of the volume: at most 30 lowercase letters, digits, and
            underscores. Required.
        region:
          type: string
          description: >-
            Region to create the volume in. Accepts the same values as the
            `region` of Create

            Machine. When forking, defaults to the source volume's region;
            otherwise defaults to the

            region of the API server handling the request.
        require_unique_zone:
          type: boolean
          description: >-
            Place the volume on a host that has no other volume of the app with
            the same name in the

            region, so that Machines using these volumes don't share a host.
            Fails with 400 if no

            such host is available.
        size_gb:
          type: integer
          description: >-
            Size of the volume in GiB, from 1 to the organization's maximum (500
            by default).

            Required unless forking, in which case it must be omitted and the
            source volume's size

            is used.
        snapshot_id:
          type: string
          description: >-
            ID of a snapshot to restore into the new volume. Mutually exclusive
            with

            `source_volume_id`.
        snapshot_retention:
          type: integer
          description: >-
            Number of days to keep snapshots of the volume, from 1 to 60.
            Defaults to 5.
        source_volume_id:
          type: string
          description: >-
            ID of a volume to fork: the new volume starts as a copy of it. The
            volume must belong to

            an app in the same organization.
        unique_zone_app_wide:
          type: boolean
          description: >-
            With `require_unique_zone`, avoid hosts with any volume of the app
            in the region, not

            just volumes with the same name.
    Volume:
      type: object
      properties:
        attached_alloc_id:
          type: string
          description: |-
            Always null.

            Deprecated: volumes are no longer attached to Nomad allocations.
        attached_machine_id:
          type: string
          description: >-
            ID of the Machine the volume is attached to, or null if it is not
            attached.
        auto_backup_enabled:
          type: boolean
          description: Whether daily automatic snapshots are taken.
        block_size:
          type: integer
          description: Size of a filesystem block, in bytes. See `blocks`.
        blocks:
          type: integer
          description: >-
            Size of the volume's filesystem, in blocks of `block_size` bytes, as
            last reported by a

            Machine that mounted the volume. 0 if never reported, if the host
            could not be reached,

            or with `summary=true`.
        blocks_avail:
          type: integer
          description: >-
            Number of filesystem blocks available to unprivileged users. See
            `blocks`.
        blocks_free:
          type: integer
          description: >-
            Number of free filesystem blocks, including blocks reserved for the
            root user. See

            `blocks`.
        bytes_total:
          type: integer
          description: >-
            Size of the volume, in bytes. 0 if the host could not be reached or
            with `summary=true`.
        bytes_used:
          type: integer
          description: >-
            Bytes of storage the volume occupies on its host. Volumes are thinly
            provisioned, so this

            grows as blocks are written and does not shrink when files are
            deleted. It is not the

            filesystem's usage; use `blocks` and `blocks_free` for that. 0 if
            the host could not be

            reached or with `summary=true`.
        created_at:
          type: string
          description: When the volume was created.
        encrypted:
          type: boolean
          description: Whether the volume is encrypted at rest.
        fstype:
          type: string
          description: >-
            Filesystem the volume was formatted with: `ext4`, or `raw` for an
            unformatted block

            device.
        host_features:
          type: array
          description: >-
            Features of the volume's host. Only returned when the request sets
            the

            `fly-include-host-features: true` header.
          items:
            type: string
        host_status:
          type: string
          description: >-
            Whether Fly.io could reach the volume's host: `ok` if it could,
            `unreachable` or

            `unknown` if it could not, in which case host-reported fields are
            missing.
          enum:
            - ok
            - unknown
            - unreachable
        id:
          type: string
          description: Unique ID of the volume, such as `vol_1234567890abcdef`.
        name:
          type: string
          description: Name of the volume. Several volumes of an app can share a name.
        region:
          type: string
          description: Code of the region the volume is in.
        required_host_features:
          type: array
          description: >-
            Host features the volume's host was required to have; see
            `compute.required_host_features`

            in the create request.
          items:
            type: string
        size_gb:
          type: integer
          description: Size of the volume, in GiB.
        snapshot_retention:
          type: integer
          description: Number of days snapshots of the volume are kept.
        state:
          type: string
          description: >-
            State of the volume, such as `creating`, `created`, `extending`,
            `restoring`,

            `hydrating`, `scheduling_destroy`, `pending_destroy`, `destroying`,
            `destroyed`, or

            `failed`.
        type:
          type: string
          description: >-
            Kind of volume: `local` for regular volumes, or `cache` for volumes
            that hold

            disposable data and support neither snapshots nor restores.
          enum:
            - local
            - cache
        zone:
          type: string
          description: >-
            Identifies the host the volume is on. Volumes with different zones
            are on different

            hosts.
    fly.MachineGuest:
      type: object
      properties:
        cpu_kind:
          type: string
          description: >-
            Kind of CPU: shared or performance. Performance CPUs must be enabled
            for the organization.

            Defaults to shared when `guest` is omitted
        cpus:
          type: integer
          description: >-
            Number of CPUs: 1, 2, 4, 6, 8, 10, 12, 14, 16, 32, 64 or 128, up to
            8 for shared and 16 for

            performance CPUs unless the organization's limit is higher. Defaults
            to 1 when `guest` is

            omitted
        gpu_kind:
          type: string
          description: No longer supported. Requests that set it are rejected
        gpus:
          type: integer
          description: No longer supported. Requests that set it are rejected
        host_dedication_id:
          type: string
          description: >-
            Place the Machine on hosts dedicated to the organization under this
            ID. Only available to

            organizations with dedicated hosts
        kernel_args:
          type: array
          description: Extra arguments appended to the guest kernel command line
          items:
            type: string
        max_memory_mb:
          type: integer
          description: >-
            Memory in MiB that the Machine's memory limit can later be raised to
            without a restart, using

            the memory endpoints. Must be at least memory_mb and at most the
            per-CPU maximum. The Machine

            starts with a limit of memory_mb
        memory_mb:
          type: integer
          description: >-
            Memory in MiB. Must be a multiple of 256 for shared and 1024 for
            performance CPUs, and

            between 256 and 2048 (shared) or 2048 and 8192 (performance) per
            CPU. Defaults to 256 when

            `guest` is omitted
        persist_rootfs:
          type: string
          description: 'Deprecated: use MachineConfig.Rootfs instead'
          enum:
            - never
            - always
            - restart
        required_host_features:
          type: array
          description: >-
            Host features the Machine's host must have, such as
            `storage-tier-1`. At most 16, each made

            of lowercase letters, digits and dashes. Each feature must be
            enabled for the organization
          items:
            type: string
  securitySchemes:
    FlyBearerAuth:
      type: http
      scheme: bearer
      description: >-
        A Fly API token with access to the requested organization or resource.
        Send it as `Authorization: Bearer <Fly API token>`.

````