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

# Verify Authorized Device

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

Verifies a specific OAuth2 authorized device using its unique ID.

This endpoint implements the OAuth2 device authorization grant flow as
defined in https://tools.ietf.org/html/rfc8628. It is called to verify
the user code for a given device ID.

If the user code is valid, the device is marked as verified and associated
with the user that authorized the device. This association is required to
be able to issue access tokens or revoke the device later on.

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

Returns:
    The updated OAuth2 authorized device object.

Raises:
    ValueError: If the device verification request fails.

## Path parameters

- `device_id` string, uuid, required

## Request body

- OAuthDeviceVerificationRequest — OAuth2 device authorization verification request.
  - `user_code` string, required
  - `trusted_device` boolean

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