# Devices

This command allows you to perform CRUD operations over devices in Ubidots. Its subcommands are:

```
Usage: ubidots devices [OPTIONS] COMMAND [ARGS]...

 Device management and operations.

╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --help          Show this message and exit.                                  │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────╮
│ add        Adds a new device.                                                │
│ delete     Deletes a specific device using its id or label.                  │
│ get        Retrieves a specific device using its id or label.                │
│ list       Lists all available devices.                                      │
│ update     Update a device.                                                  │
╰──────────────────────────────────────────────────────────────────────────────╯
```

## Create a device

Create a device in your Ubidots account.

```bash
Usage: ubidots devices add [OPTIONS] LABEL

╭─ Arguments ──────────────────────────────────────────────────────────────────╮
│  label      TEXT  The label for the device. [required]                       │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --name                TEXT  The name of the device.                          │
│ --description         TEXT  A brief description of the device.               │
│ --organization        TEXT  The organization associated with the device. Its │
│                             id or key must be provided.                      │
│ --type                TEXT  The device type associated with the device. Its  │
│                             id or key must be provided.                      │
│ --tags                TEXT  Comma-separated tags for the device. e.g.        │
│                             tag1,tag2,tag3                                   │
│ --properties          TEXT  Device properties in JSON format.                │
│                             [default: {}]                                    │
│ --help                      Show this message and exit.                      │
╰──────────────────────────────────────────────────────────────────────────────╯
```

## Get a device <a href="#get-a-device" id="get-a-device"></a>

Retrieve a device from Ubidots.

```bash
 Usage: ubidots devices get [OPTIONS]

╭─ Options ────────────────────────────────────────────────────────────────────╮
│    --id            TEXT  Unique identifier for the device. If both id and   │
│                          label are provided, the id takes precedence.       │
│    --label         TEXT  Descriptive label identifier for the device.       │
│                          Ignored if id is provided.                         │
│    --fields        TEXT  Comma-separated fields to process. e.g.            │
│                          field1,field2,field3                               │
│                          [default: id,label,name]                           │
│    --help                Show this message and exit.                        │
╰──────────────────────────────────────────────────────────────────────────────╯
```

## Update a device <a href="#update-a-device" id="update-a-device"></a>

Update a device in Ubidots.

```bash
 Usage: ubidots devices update [OPTIONS]

╭─ Options ────────────────────────────────────────────────────────────────────╮
│    --id                 TEXT  Unique identifier for the device. If both id  │
│                               and label are provided, the id takes          │
│                               precedence.                                   │
│    --label              TEXT  Descriptive label identifier for the device.  │
│                               Ignored if id is provided.                    │
│    --new-label          TEXT  The label for the device.                     │
│    --new-name           TEXT  The name of the device.                       │
│    --description        TEXT  A brief description of the device.            │
│    --organization       TEXT  The organization associated with the device.  │
│                               Its id or key must be provided.               │
│    --type               TEXT  The device type associated with the device.   │
│                               Its id or key must be provided.               │
│    --tags               TEXT  Comma-separated tags for the device. e.g.     │
│                               tag1,tag2,tag3                                │
│    --properties         TEXT  Device properties in JSON format.             │
│                               [default: {}]                                 │
│    --help                     Show this message and exit.                   │
╰──────────────────────────────────────────────────────────────────────────────╯
```

## Delete a device <a href="#delete-a-device" id="delete-a-device"></a>

Delete a device from your Ubidots account.

```bash
 Usage: ubidots devices delete [OPTIONS]

╭─ Options ────────────────────────────────────────────────────────────────────╮
│    --id           TEXT  Unique identifier for the device. If both id and    │
│                         label are provided, the id takes precedence.        │
│    --label        TEXT  Descriptive label identifier for the device.        │
│                         Ignored if id is provided.                          │
│    --help               Show this message and exit.                         │
╰──────────────────────────────────────────────────────────────────────────────╯
```

{% hint style="warning" %}
This command permanently deletes the device, just like removing it through the platform, thus special care is advised.
{% endhint %}

## List all devices

List all devices on your Ubidots account.

```bash
 Usage: ubidots devices list [OPTIONS]

╭─ Options ───────────────────────────────────────────────────────────────────────────────────────────╮
│ --fields           TEXT          Comma-separated fields to process * e.g. field1,field2,field3. *   │
│                                  Available fields: (id, label, name, createdAt, description,        │
│                                  isActive, lastActivity, organization, properties, tags, url,       │
│                                  variableCount, variablesUrl). For more details, visit the          │
│                                  documentation at:                                                  │
│                                  https://docs.ubidots.com/reference/device-object                   │
│                                  [default: id,label,name]                                           │
│ --filter           TEXT          Filter results by attributes. e.g.                                 │
│                                  'key1=val1&key2__in=val20,val21' or                                │
│                                  key1=val1\&key2__in=val20,val21                                    │
│ --sort-by          TEXT          Attribute to sort the result set by.                               │
│ --page-size        INTEGER       Defines the page number to be retrieved.                           │
│ --page             INTEGER       Defines how many items per page are retrieved.                     │
│ --format           [table|json]  [default: table]                                                   │
│ --help                           Show this message and exit.                                        │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────╯
```
