# Device state

## Device state

<mark style="color:blue;">`GET`</mark> `https://api.connect.jfrog.io/v1/get_device_state`

Using this call you will get the current device state - `Online` or `Offline`.

#### Request Body

| Name                                          | Type   | Description                                                                               |
| --------------------------------------------- | ------ | ----------------------------------------------------------------------------------------- |
| user\_token<mark style="color:red;">\*</mark> | string | This is your account token. You can find it under the Settings category on the dashboard. |
| device\_token                                 | string | This is the device token. (See Notes below.)                                              |
| device\_id                                    | String | This is the device ID or device UUID. (See Notes below.)                                  |

{% tabs %}
{% tab title="200  The value of the "message" parameter is a JSON object with the keys:

1. device\_status - String - can be either online or offline values.
2. device\_token - String - This is the token of the device which you have sent at the request." %}

```
{"message": {"device_status": "online",
            {"device_id": "d-1234-abcd"}}
```

{% endtab %}

{% tab title="400 Error occurred." %}

```
{"error_message": "<ERROR_MESSAGE>"}
```

{% endtab %}

{% tab title="429 Rate limit reached." %}

```
{}
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
**Notes**:

1. Either the `device_token` or the `device_id` must be provided.
2. You may use either **`device_id`** or **`device_uuid`** in the **`device_id`** field. Either one will adequately function as an identifier.
   {% endhint %}

#### Example

{% tabs %}
{% tab title="Python" %}

```python
import json
import requests

json_content = {'device_id': 'd-1234-abcd',
                'user_token': 'YYYYYYYYYYYYYYY'}

call_request = requests.get("https://api.connect.jfrog.io/v1/get_device_state", json=json_content)
call_response = json.loads(call_request.text)

if call_request.status_code != 200:
    if call_request.status_code == 429:
        error = "API limit reached"
    else:
        error = call_response["error_message"]
    print(error)

else:
    device_status = call_response["message"]["device_status"]
    device_id = call_response["message"]["device_id"]


```

{% endtab %}

{% tab title="Curl" %}

```shell
curl --location --request GET 'https://api.connect.jfrog.io/v1/get_device_state' \
--header 'Content-Type: application/json' \
--data-raw '{
    "user_token": "YYYYYYYYYYYYYYY",
    "device_id": "d-1234-abcd"
    }'
```

{% endtab %}
{% endtabs %}
