---
title: "Update Authorized Device"
method: PUT
path: "/api/v1/devices/{device_id}"
tags: ["authorized_devices"]
---

# Update Authorized Device

`PUT /api/v1/devices/{device_id}`

Updates a specific OAuth2 authorized device using its unique ID.

Args:
    device_id: The ID of the OAuth2 authorized device to update.
    update: The model containing the attributes to update.
    auth_context: The current auth context.

Returns:
    The updated OAuth2 authorized device object.

Raises:
    KeyError: If the device with the given ID does not exist or does not
        belong to the current user.

## Path parameters

- `device_id` string, uuid, required

## Request body

- OAuthDeviceUpdate — OAuth2 device update model.
  - `locked` boolean, nullable — Whether to lock or unlock the OAuth2 device. A locked device cannot be used for authentication.

## Response `200`

Successful Response

- OAuthDeviceResponse — Response model for OAuth2 devices.
  - `body` OAuthDeviceResponseBody — Response body for OAuth2 devices.
    - `created` string, date-time, required
    - `updated` string, date-time, required
    - `user` UserResponse — Response model for user and service accounts. This returns the activation_token that is required for the user-invitation-flow of the frontend. The email is returned optionally as well for use by the analytics on the client-side.
      - `body` UserResponseBody — Response body for users.
        - `created` string, date-time, required
        - `updated` string, date-time, required
        - `active` boolean
        - `activation_token` string, nullable
        - `full_name` string
        - `email_opted_in` boolean, nullable — `null` if not answered, `true` if agreed, `false` if skipped.
        - `is_service_account` boolean, required
        - `is_admin` boolean, required
      - `metadata` UserResponseMetadata — Response metadata for users.
        - `email` string, nullable
        - `external_user_id` string, uuid, nullable
        - `user_metadata` object
      - `resources` UserResponseResources — Class for all resource models associated with the user entity.
      - `id` string, uuid, required
      - `permission_denied` boolean
      - `name` string, required
    - `client_id` string, uuid, required — The client ID of the OAuth2 device.
    - `expires` string, date-time, nullable — The expiration date of the OAuth2 device after which the device is no longer valid and cannot be used for authentication.
    - `trusted_device` boolean, required — Whether the OAuth2 device was marked as trusted. A trusted device has a much longer validity time.
    - `status` 'pending' | 'verified' | 'active' | 'locked', required — The OAuth device status.
    - `os` string, nullable — The operating system of the device used for authentication.
    - `ip_address` string, nullable — The IP address of the device used for authentication.
    - `hostname` string, nullable — The hostname of the device used for authentication.
  - `metadata` OAuthDeviceResponseMetadata — Response metadata for OAuth2 devices.
    - `python_version` string, nullable — The Python version of the device used for authentication.
    - `zenml_version` string, nullable — The ZenML version of the device used for authentication.
    - `city` string, nullable — The city where the device is located.
    - `region` string, nullable — The region where the device is located.
    - `country` string, nullable — The country where the device is located.
    - `failed_auth_attempts` integer, required — The number of failed authentication attempts.
    - `last_login` string, date-time, nullable, required — The date of the last successful login.
  - `resources` OAuthDeviceResponseResources — Class for all resource models associated with the OAuthDevice entity.
  - `id` string, uuid, required
  - `permission_denied` boolean

## Other responses

- `401` — Unauthorized
- `404` — Not Found
- `422` — Unprocessable Entity

---

[API](https://skmtc.net/zenml-io/apis/zenml-2.md) · [All operations](https://skmtc.net/zenml-io/apis/zenml-2/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/zenml-io/zenml-2/versions/febb01b8bce3/schema)
