Creates a new entity in the account.
https://help.tago.io/portal/en/kb/articles/entities#Creating_an_Entity Creating an Entity
If receive an error "Authorization Denied", check policy Entity / Create in Access Management.
const result = await Resources.entities.create({
name: "Temperature Sensors",
schema: {
temperature: { action: "create", type: "float", required: true } }
});
console.log(result); // { id: 'entity-id-123' }
Permanently removes an entity from the account.
https://help.tago.io/portal/en/kb/articles/entities#Managing_fields Managing Fields
If receive an error "Authorization Denied", check policy Entity / Delete in Access Management.
const result = await Resources.entities.delete("entity-id-123");
console.log(result); // Entity Successfully Removed
Delete data records in a entity using the profile token and entity ID.
See the example to understand how to use this method properly to have full control on what to delete.
https://help.tago.io/portal/en/kb/articles/entities#Managing_the_data_in_your_Entity Managing the data in your Entity
const resources = new Resources({ token: "YOUR-PROFILE-TOKEN" });
const result = await resources.entities.deleteEntityData("myEntityID", { ids: ["idOfTheRecord1"] });
console.log(result); // 1 item(s) deleted
Removes a field from the entity schema.
https://help.tago.io/portal/en/kb/articles/entities#Managing_fields Managing Fields
If receive an error "Authorization Denied", check policy Entity / Edit in Access Management.
const result = await Resources.entities.deleteField("entity-id-123", "old_field");
console.log(result); // { message: 'Entity Successfully Updated' }
Removes an index from the entity schema.
https://help.tago.io/portal/en/kb/articles/entities#Indexing_fields_to_improve_searching_and_sorting Indexing fields to improve searching and sorting
If receive an error "Authorization Denied", check policy Entity / Edit in Access Management.
const result = await Resources.entities.deleteIndex("entity-id-123", "temp_idx");
console.log(result); // { message: 'Entity Successfully Updated' }
Updates an existing entity's properties.
https://help.tago.io/portal/en/kb/articles/entities#Managing_fields Managing Fields
If receive an error "Authorization Denied", check policy Entity / Edit in Access Management.
const result = await Resources.entities.edit("entity-id-123", { name: "Updated Entity Name" });
console.log(result); // { message: 'Entity Successfully Updated' }
Updates existing data records in an entity.
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/entities#Managing_the_data_in_your_Entity Managing the data in your Entity
const resources = new Resources({ token: "YOUR-PROFILE-TOKEN" });
const result = await resources.entities.editEntityData("entity-id-123", {
id: "record-id-123",
temperature: 30.1
});
console.log(result); // 1 item(s) updated
Optional
index?: Record<string, { Optional
schema?: EntitySchemaModifies the entity schema by adding new fields or managing indexes.
https://help.tago.io/portal/en/kb/articles/entities#Indexing_fields_to_improve_searching_and_sorting Indexing fields to improve searching and sorting
If receive an error "Authorization Denied", check policy Entity / Edit in Access Management.
const result = await Resources.entities.editSchemaIndex("entity-id-123", {
schema: { unit: { action: "create", type: "float", required: false } },
index: { temp_idx: { action: "create", fields: ["temperature"] } }
});
console.log(result); // { message: 'Entity Successfully Updated' }
Removes all data records from an entity while preserving its structure and configuration.
https://help.tago.io/portal/en/kb/articles/entities#Managing_the_data_in_your_Entity Managing the data in your Entity
If receive an error "Authorization Denied", check policy Entity / Delete in Access Management.
const result = await Resources.entities.emptyEntityData("entity-id-123");
console.log(result); // Data Successfully Removed
Optional
queryParams: EntityDataQueryOptional
options: { Optional
paramsRetrieves data records stored in a specific entity with optional filtering parameters.
https://help.tago.io/portal/en/kb/articles/entities#Managing_the_data_in_your_Entity Managing the data in your Entity
If receive an error "Authorization Denied", check policy Entity / Access in Access Management.
const result = await Resources.entities.getEntityData("entity-id-123", { amount: 10, orderBy: "created_at,desc" });
console.log(result); // [ { id: 'record-id-123', created_at: 2025-01-22T13:45:30.913Z, ... }, ... ]
// Filtering by a specific field
const result = await Resources.entities.getEntityData("entity-id-123", {
filter: { temperature: "30" },
index: "temp_idx",
amount: 9999,
});
console.log(result); // [ { id: 'record-id-123', created_at: 2025-01-22T13:45:30.913Z, ... }, ... ]
Retrieves detailed information about a specific entity.
https://help.tago.io/portal/en/kb/articles/entities Entities
If receive an error "Authorization Denied", check policy Entity / Access in Access Management.
const result = await Resources.entities.info("entity-id-123");
console.log(result); // { schema: { id: { type: 'uuid', required: true }, ... }, ... }
Optional
queryObj: EntityQueryOptional
options: { Optional
paramsRetrieves a paginated list of all entities from the account with filtering and sorting options.
https://help.tago.io/portal/en/kb/articles/entities Entities
If receive an error "Authorization Denied", check policy Entity / Access in Access Management.
const result = await Resources.entities.list({
page: 1,
fields: ["id", "name", "tags"],
amount: 20
});
console.log(result); // [ { id: 'entity-id-123', name: 'test', tags: [] }, ... ]
Renames a field in the entity schema.
https://help.tago.io/portal/en/kb/articles/entities#Managing_fields Managing Fields
If receive an error "Authorization Denied", check policy Entity / Edit in Access Management.
const result = await Resources.entities.renameField("entity-id-123", "old_name", "new_name");
console.log(result); // { message: 'Entity Successfully Updated' }
Sends new data records to an entity.
The data
can be a single data record or an array of records to be sent.
https://help.tago.io/portal/en/kb/articles/entities#Managing_the_data_in_your_Entity Managing the data in your Entity
If receive an error "Authorization Denied", check policy Entity / Edit in Access Management.
const result = await Resources.entities.sendEntityData("entity-id-123", { temperature: 25.5 });
console.log(result); // 1 Data Added
Updates a field's configuration in the entity schema.
https://help.tago.io/portal/en/kb/articles/entities#Managing_fields Managing Fields
If receive an error "Authorization Denied", check policy Entity / Edit in Access Management.
const result = await Resources.entities.updateField("entity-id-123", "temperature", { required: false });
console.log(result); // { message: 'Entity Successfully Updated' }
Description
Gets the total amount of data records stored in the entity.
See
https://help.tago.io/portal/en/kb/articles/entities Entities
Example
If receive an error "Authorization Denied", check policy Entity / Delete in Access Management.