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

# Terminate a device

> Terminates the device and releases its resources. For a personal (BYOD) device the owner (API key or user) can instead remove the phone from the account so anyone can pair it again; the phone must be disconnected first, otherwise the request is rejected with 409 BYOD_DEVICE_CONNECTED. Other subscription-billed devices cannot be terminated with this request; it is rejected with 401. The `terminateAt` and `previousDeviceId` body fields are reserved for internal use; requests that set them are rejected with 401.

Terminates the device and releases its resources.

## Personal (BYOD) devices

A personal device is your own phone, connected through the Mobilerun app. It
cannot be terminated: it reconnects on its own. Instead, `DELETE` removes the
phone from your account. Afterwards anyone can pair it again, including you.

The phone must be disconnected first. If it is still connected, the request
fails with `409 BYOD_DEVICE_CONNECTED`:

```json
{
  "code": "BYOD_DEVICE_CONNECTED",
  "message": "BYOD device is connected; disconnect the phone before removing it"
}
```

Close the app or log out on the phone, wait until the device shows as
offline, then send the request again.


## OpenAPI

````yaml /api-reference/phones.yaml delete /devices/{deviceId}
openapi: 3.1.0
info:
  title: Devices
  version: v1
servers:
  - description: Droidrun Cloud API
    url: https://api.mobilerun.ai/v1
security:
  - bearerAuth: []
paths:
  /devices/{deviceId}:
    delete:
      tags:
        - Devices
      summary: Terminate a device
      description: >-
        Terminates the device and releases its resources. For a personal (BYOD)
        device the owner (API key or user) can instead remove the phone from the
        account so anyone can pair it again; the phone must be disconnected
        first, otherwise the request is rejected with 409 BYOD_DEVICE_CONNECTED.
        Other subscription-billed devices cannot be terminated with this
        request; it is rejected with 401. The `terminateAt` and
        `previousDeviceId` body fields are reserved for internal use; requests
        that set them are rejected with 401.
      operationId: terminate-device
      parameters:
        - in: path
          name: deviceId
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TerminateInputBody'
      responses:
        '204':
          description: No Content
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ErrorModel'
          description: Conflict
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ErrorModel'
          description: Unprocessable Entity
        '500':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ErrorModel'
          description: Internal Server Error
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Mobilerun from '@mobilerun/sdk';

            const client = new Mobilerun({
              apiKey: process.env['MOBILERUN_CLOUD_API_KEY'], // This is the default and can be omitted
            });

            await client.devices.terminate('deviceId');
        - lang: Python
          source: |-
            import os
            from mobilerun_sdk import Mobilerun

            client = Mobilerun(
                api_key=os.environ.get("MOBILERUN_CLOUD_API_KEY"),  # This is the default and can be omitted
            )
            client.devices.terminate(
                device_id="deviceId",
            )
components:
  schemas:
    TerminateInputBody:
      additionalProperties: false
      properties:
        $schema:
          description: A URL to the JSON Schema for this object.
          examples:
            - https://example.com/schemas/TerminateInputBody.json
          format: uri
          readOnly: true
          type: string
        previousDeviceId:
          type: string
        terminateAt:
          format: date-time
          type: string
      type: object
    ErrorModel:
      additionalProperties: false
      properties:
        $schema:
          description: A URL to the JSON Schema for this object.
          examples:
            - https://example.com/schemas/ErrorModel.json
          format: uri
          readOnly: true
          type: string
        detail:
          description: >-
            A human-readable explanation specific to this occurrence of the
            problem.
          examples:
            - Property foo is required but is missing.
          type: string
        errors:
          description: Optional list of individual error details
          items:
            $ref: '#/components/schemas/ErrorDetail'
          type:
            - array
            - 'null'
        instance:
          description: >-
            A URI reference that identifies the specific occurrence of the
            problem.
          examples:
            - https://example.com/error-log/abc123
          format: uri
          type: string
        status:
          description: HTTP status code
          examples:
            - 400
          format: int64
          type: integer
        title:
          description: >-
            A short, human-readable summary of the problem type. This value
            should not change between occurrences of the error.
          examples:
            - Bad Request
          type: string
        type:
          default: about:blank
          description: A URI reference to human-readable documentation for the error.
          examples:
            - https://example.com/errors/example
          format: uri
          type: string
      type: object
    ErrorDetail:
      additionalProperties: false
      properties:
        location:
          description: >-
            Where the error occurred, e.g. 'body.items[3].tags' or
            'path.thing-id'
          type: string
        message:
          description: Error message text
          type: string
        value:
          description: The value at the given location
      type: object
  securitySchemes:
    bearerAuth:
      bearerFormat: Opaque
      description: Bearer token via Authorization header
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.