Use dataBackup
instead.
Creates a new device in your application.
https://help.tago.io/portal/en/kb/articles/3-devices#Adding_devices Adding Devices
If receive an error "Authorization Denied", check policy Device / Create in Access Management.
const TAGOIO_DATABASE_CONNECTOR = "62333bd36977fc001a2990c8";
const TAGOIO_STORAGE_NETWORK = "62336c32ab6e0d0012e06c04";
const newDevice = await Resources.devices.create({
name: "My Device",
connector: TAGOIO_DATABASE_CONNECTOR,
network: TAGOIO_STORAGE_NETWORK,
type: "mutable"
});
console.log(newDevice); // { device: 'device-id-123', token: 'token-123' }
Optional
chunkID: stringSchedule to export the mutable Device's data to TagoIO Files.
https://help.tago.io/portal/en/kb/articles/55-data-export Data Export
If receive an error "Authorization Denied", check policy Device / Export Data in Access Management.
const deviceID = "your-device-id";
const timestamp = Date.now()
const result = await Resources.devices.dataBackup({
deviceID: "device-id-123",
file_address: `/backups/${deviceID}/${timestamp}`,
headers: true
});
console.log(result); // { file_address: 'backups/your-device-id/1736433519380.csv' }
Restores data to a device from a CSV file in TagoIO Files.
https://help.tago.io/portal/en/kb/articles/device-data#Importing Importing
If receive an error "Authorization Denied", check policy Device / Import Data in Access Management.
const result = await Resources.devices.dataRestore({
deviceID: "device-id-123",
file_address: "/backups/backup.csv"
});
console.log(result); // Data import added to the queue successfully!
Deletes a device from your application.
https://help.tago.io/portal/en/kb/articles/3-devices Devices
If receive an error "Authorization Denied", check policy Device / Delete in Access Management.
const result = await Resources.devices.delete("device-id-123");
console.log(result); // Successfully Removed
Experimental
Deletes a chunk from a immutable device.
https://help.tago.io/portal/en/kb/articles/chunk-management#Delete_chunks Delete chunks
If receive an error "Authorization Denied", check policy Device / Manage chunks in Access Management.
const result = await Resources.devices.deleteChunk("device-id-123", "chunk-id-123");
console.log(result); // Chunk chunk-id-123 deleted
Optional
queryParams: DataQueryDelete data records in a mutable device using the profile token and device ID.
See the example to understand how to use this method properly to have full control on what to delete.
! If query parameters are empty, last 15 data for the device will be deleted.
https://help.tago.io/portal/en/kb/articles/device-data#Editing_and_deleting_variables_individually Editing and deleting variables individually
If receive an error "Authorization Denied", check policy Device / Delete data in Access Management.
const result = await Resources.devices.deleteDeviceData("device-id-123", {
ids: ["record-id-1", "record-id-2"]
});
console.log(result); // 1 Data Removed
Modifies properties of an existing device.
https://help.tago.io/portal/en/kb/articles/3-devices#Managing_and_customizing_your_device Managing and Customizing Your Device
If receive an error "Authorization Denied", check policy Device / Edit in Access Management.
const result = await Resources.devices.edit("device-id-123", {
name: "Updated Device Name",
active: true
});
console.log(result); // Successfully Updated
Edit data records in a mutable device using the profile token and device ID.
The updatedData
can be a single data record or an array of records to be updated,
each of the records must have the id
of the record and the fields to be updated.
https://help.tago.io/portal/en/kb/articles/device-data#Editing_and_deleting_variables_individually Editing and deleting variables individually
If receive an error "Authorization Denied", check policy Device / Edit data in Access Management.
const result = await Resources.devices.editDeviceData("myDeviceId", {
id: "idOfTheRecord",
value: "new value",
unit: "new unit"
});
console.log(result); // 1 item(s) updated
Removes all data from a device.
https://help.tago.io/portal/en/kb/articles/device-data#Emptying_your_Device_Data Emptying your Device Data
If receive an error "Authorization Denied", check policy Device / Delete data in Access Management.
const result = await Resources.devices.emptyDeviceData("device-id-123");
console.log(result); // Data Successfully Removed
Experimental
Retrieves chunk information from a immutable device.
https://help.tago.io/portal/en/kb/articles/chunk-management Chunk Management
If receive an error "Authorization Denied", check policy Device / Manage chunks in Access Management.
const chunks = await Resources.devices.getChunk("device-id-123");
console.log(chunks); // [ { amount: 0, id: 'chunk-id-123', from: '2025-01-09T00:00:00.000+00:00', ... } ]
Optional
queryParams: DataQueryRetrieves data from all variables in the device.
https://help.tago.io/portal/en/kb/articles/device-data Device data management
If receive an error "Authorization Denied", check policy Device / Get data in Access Management.
const data = await Resources.devices.getDeviceData("device-id-123", {
qty: 10,
variables: ["temperature"]
});
console.log(data); // [ { id: 'data-id-123', value: 55, variable: 'temperature' ... } ]
Experimental
Optional
params: DataQueryStreamingOptional
options: OptionsStreamingRetrieves data from device using streaming approach.
https://help.tago.io/portal/en/kb/articles/device-data Device data management
If receive an error "Authorization Denied", check policy Device / Get data in Access Management.
for await (const data of await Resources.devices.getDeviceDataStreaming("device-id-123")) {
console.log(data);
}
Retrieves detailed information about a specific device.
https://help.tago.io/portal/en/kb/articles/3-devices Devices
If receive an error "Authorization Denied", check policy Device / Access in Access Management.
const deviceInfo = await Resources.devices.info("device-id-123");
console.log(deviceInfo); // { active: true, bucket: { id: 'device-id-123', name: 'My Device' } ... }
Optional
queryObj: TLists all devices from your application with pagination support.
https://help.tago.io/portal/en/kb/articles/3-devices Devices
If receive an error "Authorization Denied", check policy Device / Access in Access Management.
const list = await Resources.devices.list({
page: 1,
fields: ["id", "name"],
amount: 10,
orderBy: ["name", "asc"]
});
console.log(list); // [ { id: '123', name: 'Device #1' ...}, { id: '456', name: 'Device #2' ...} ]
Optional
queryObj: Omit<DeviceQuery, "page" | "amount">Optional
options: OptionsStreamingGets a streaming list of devices from the application.
https://help.tago.io/portal/en/kb/articles/3-devices Devices
If receive an error "Authorization Denied", check policy Device / Access in Access Management.
for await (const items of await Resources.devices.listStreaming({ name: "*sensor*" })) {
console.log(items);
}
Optional
sentStatus: BooleanLists all parameters for a device.
https://help.tago.io/portal/en/kb/articles/configuration-parameters-for-devices Configuration Parameters for Devices
If receive an error "Authorization Denied", check policy Device / Access in Access Management.
const params = await Resources.devices.paramList("device-id-123");
console.log(params); // [ { id: 'params-id-123', key: 'config-key', value: 'config-value', sent: false } ]
Removes a parameter from a device.
https://help.tago.io/portal/en/kb/articles/configuration-parameters-for-devices Configuration Parameters for Devices
If receive an error "Authorization Denied", check policy Device / Edit in Access Management.
const result = await Resources.devices.paramRemove("device-id-123", "param-id-123");
console.log(result); // Successfully Removed
Optional
paramID: stringCreates or updates device parameters.
https://help.tago.io/portal/en/kb/articles/configuration-parameters-for-devices Configuration Parameters for Devices
If receive an error "Authorization Denied", check policy Device / Edit in Access Management.
const result = await Resources.devices.paramSet("device-id-123", {
key: "config-key",
value: "config-value",
sent: false
});
console.log(result); // Params Successfully Updated
Sends data to a device.
https://help.tago.io/portal/en/kb/articles/95-device-emulator Device Emulator
If receive an error "Authorization Denied", check policy Device / Send data in Access Management.
const result = await Resources.devices.sendDeviceData("device-id-123", {
variable: "temperature",
unit: "F",
value: 55,
location: { lat: 42.2974279, lng: -85.628292 }
});
console.log(result); // 1 Data Added
Experimental
Optional
options: Omit<OptionsStreaming, "neverStop">Streams data to a device in chunks.
https://help.tago.io/portal/en/kb/articles/95-device-emulator Device Emulator
If receive an error "Authorization Denied", check policy Device / Send data in Access Management.
const result = await Resources.devices.sendDeviceDataStreaming("device-id-123",
[{
variable: "temperature",
value: 55,
unit: "F",
}],
{ poolingRecordQty: 1000 }
);
console.log(result);
Creates a new token for a device.
https://help.tago.io/portal/en/kb/articles/4-device-token Device Token
If receive an error "Authorization Denied", check policy Device / Token access in Access Management.
const token = await Resources.devices.tokenCreate("device-id-123", {
name: "My Token",
permission: "full"
});
console.log(token); // { token: 'token-id-123', permission: 'full' }
Deletes a device token.
https://help.tago.io/portal/en/kb/articles/4-device-token Device Token
If receive an error "Authorization Denied", check policy Device / Token access in Access Management.
const result = await Resources.devices.tokenDelete("token-123");
console.log(result); // Token Successfully Removed
Optional
queryObj: TLists all tokens for a device with pagination support.
https://help.tago.io/portal/en/kb/articles/4-device-token Device Token
If receive an error "Authorization Denied", check policy Device / Token access in Access Management.
const tokens = await Resources.devices.tokenList("device-id-123", {
page: 1,
fields: ["name", "token"],
amount: 10
});
console.log(tokens); // [ { name: 'Default', token: 'token-id-123', expire_time: 'never' } ]
Description
Gets the amount of data stored in a device.
See
https://help.tago.io/portal/en/kb/articles/device-data#Amount_of_data_records Amount of data records
Example
If receive an error "Authorization Denied", check policy Device / Access in Access Management.