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

# Get Lease

> Retrieve the current lease of a specific Machine within an app. Machine leases can be used to obtain an exclusive lock on modifying a Machine.




## OpenAPI

````yaml /api/machines/openapi.json get /v1/apps/{app_name}/machines/{machine_id}/lease
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}/lease:
    get:
      tags:
        - Machines
      summary: Get Lease
      description: >
        Retrieve the current lease of a specific Machine within an app. Machine
        leases can be used to obtain an exclusive lock on modifying a Machine.
      operationId: Machines_show_lease
      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
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LeaseResponse'
        '404':
          description: The Machine has no lease.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LeaseErrorResponse'
components:
  schemas:
    LeaseResponse:
      type: object
      properties:
        data:
          type: object
          description: The lease.
          allOf:
            - $ref: '#/components/schemas/Lease'
        status:
          type: string
          description: Always `success`.
          enum:
            - success
    LeaseErrorResponse:
      type: object
      properties:
        message:
          type: string
          description: What went wrong.
        status:
          type: string
          description: Always `error`.
          enum:
            - error
    Lease:
      type: object
      properties:
        description:
          type: string
          description: Description or reason for the lease.
        expires_at:
          type: integer
          description: When the lease expires, in Unix seconds.
        nonce:
          type: string
          description: >-
            Unique ID generated for the lease. Pass it in the
            `fly-machine-lease-nonce` header to

            act on the leased Machine, refresh the lease, or release it.
        owner:
          type: string
          description: Email address of the user who acquired the lease.
        version:
          type: string
          description: ID of the Machine's version at the time of the request.
  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>`.

````