# Entity object

## Definition

An `entityObject` reflects the JSON representation of an [entity](/sdks/javascript/overview.md#supported-entities) from the API, but it also provides 3 methods that let you interact with that instance.

## Example

Suppose you retrieve data from a device as follows:

```javascript
const firstDevice = await Ubidots.devices.first();
```

Here, `firstDevice` is an object that contains all the properties from the API representation of a device:

```json
{
  "properties": {
    "_color": "#EA6F4C",
    "_icon": "cloud-sun",
    "_location_fixed": {
      "lat": 6.2486,
      "lng": 75.5742
    }
  },
  "createdAt": "2019-11-25T19:35:08.975270Z",
  "description": "some description",
  "id": "6e309da44fc8455a9cceb5aa",
  "isActive": true,
  "label": "first-device",
  "lastActivity": null,
  "name": "First Device",
  "organization": {
    "id": "af92e4c82bf1d39cc21882f5b",
    "label": "my-first-customer",
    "name": "My First Customer",
    "url": "http://industrial.ubidots.com/api/v2.0/organizations/af92e4c82bf1d39cc21882f5b"
  },
  "tags": ["first"],
  "url": "http://industrial.ubidots.com/api/v2.0/devices/6e309da44fc8455a9cceb5aa",
  "variables": "http://industrial.ubidots.com/api/v2.0/devices/6e309da44fc8455a9cceb5aa/variables",
  "variablesNumber": 1
}
```

In addition to the properties shown above, you can also invoke the following methods on `firstDevice`:

```javascript
firstDevice.refresh();
firstDevice.update(args);
firstDevice.save(args);
```

## Entity object methods <a href="#entity-object-methods" id="entity-object-methods"></a>

<table data-full-width="true"><thead><tr><th align="center">Method</th><th align="center">Description</th><th align="center">Usage</th><th align="center">Arguments</th><th align="center">Response</th></tr></thead><tbody><tr><td align="center"><code>refresh</code></td><td align="center">Returns the most recent state of the <code>entityObject</code> from the server.</td><td align="center"><code>Ubidots.&#x3C;entity>.&#x3C;get-method>(, [args]).refresh()</code></td><td align="center">None</td><td align="center"><code>entityObject</code></td></tr><tr><td align="center"><code>update</code></td><td align="center">Updates the <code>entityObject</code> fields on the server with the values in the object passed as an argument.</td><td align="center"><code>Ubidots.&#x3C;entity>.&#x3C;get-method>(, [args]).update(props)</code></td><td align="center"><code>props: object</code> An object with at least 1 valid property of the given <code>entity</code></td><td align="center"><code>entityObject</code></td></tr><tr><td align="center"><code>save</code></td><td align="center">Updates the entire <code>entityObject</code> on the server with the values in the object passed as an argument.</td><td align="center"><code>Ubidots.&#x3C;entity>.&#x3C;get-method>(, [args]).save(props)</code></td><td align="center"><code>props: object</code> An object containing all the properties of the given <code>entity</code></td><td align="center"><code>entityObject</code></td></tr></tbody></table>

<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dev.ubidots.com/sdks/javascript/ubidots-class/ubidots-objects/entity-object.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
