> ## 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.

# Wait for State

> Wait for a Machine to reach a specific state. Specify the desired state with the state parameter. See the [Machine states table](https://fly.io/docs/machines/working-with-machines/#machine-states) for a list of possible states. The default for this parameter is `started`.

This request will block for up to 60 seconds. Set a shorter timeout with the timeout parameter.




## OpenAPI

````yaml /api/machines/openapi.json get /v1/apps/{app_name}/machines/{machine_id}/wait
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}/machines/{machine_id}/wait:
    get:
      tags:
        - Machines
      summary: Wait for State
      description: >
        Wait for a Machine to reach a specific state. Specify the desired state
        with the state parameter. See the [Machine states
        table](https://fly.io/docs/machines/working-with-machines/#machine-states)
        for a list of possible states. The default for this parameter is
        `started`.


        This request will block for up to 60 seconds. Set a shorter timeout with
        the timeout parameter.
      operationId: Machines_wait
      parameters:
        - name: app_name
          in: path
          description: Fly App Name
          required: true
          schema:
            type: string
        - name: machine_id
          in: path
          description: Machine ID
          required: true
          schema:
            type: string
        - name: version
          in: query
          description: 26-character Machine version ID
          schema:
            type: string
        - name: instance_id
          in: query
          description: 26-character Machine version ID (deprecated; use version)
          schema:
            type: string
        - name: from_event_id
          in: query
          description: 26-character Machine event ID to start waiting after
          schema:
            type: string
        - name: timeout
          in: query
          description: Wait timeout in seconds. Defaults to 60.
          schema:
            type: integer
        - name: state
          in: query
          description: >-
            Desired state(s). Supports repeated or comma-separated values.
            settled matches any of started, stopped, suspended, failed,
            destroyed, or archived. Defaults to started.
          schema:
            type: string
            enum:
              - started
              - stopped
              - suspended
              - destroyed
              - failed
              - archived
              - settled
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WaitMachineResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    WaitMachineResponse:
      type: object
      properties:
        event_id:
          type: string
          description: >-
            ID of the event that moved the Machine into `state`. Pass it as
            `from_event_id` to wait

            for a later state change.
        ok:
          type: boolean
          description: Always true.
        state:
          type: string
          description: The state the Machine reached, one of the requested states.
        version:
          type: string
          description: ID of the Machine version that reached `state`.
    ErrorResponse:
      type: object
      properties:
        details:
          type: object
          description: 'Deprecated: details about some errors. Do not rely on its contents.'
        error:
          type: string
          description: >-
            Human-readable description of the error. Its wording may change; use
            `status` to tell

            errors apart.
        status:
          type: object
          description: >-
            Machine-readable error code, set for some errors, such as
            `insufficient_capacity`,

            `volume_placement_capacity`, `name_taken`, `exec_request_too_large`,
            or

            `exec_output_too_large`.
          allOf:
            - $ref: '#/components/schemas/main.statusCode'
    main.statusCode:
      type: string
      enum:
        - unknown
        - insufficient_capacity
        - volume_placement_capacity
        - exec_request_too_large
        - exec_output_too_large
        - name_taken
      x-enum-varnames:
        - unknown
        - capacityErr
        - volumePlacementCapacityErr
        - execRequestTooLargeErr
        - execOutputTooLargeErr
        - nameTakenErr
  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>`.

````