metadata.update()

Adds/updates the Metadata for an existing Group or User entity.

This only replaces metadata keys which are present in the partialData argument.

See client.metadata.fullUpdate() for a version which will also erase keys that are not specified.

Definition

client.metadata.update(
entityId: string|Group|User,
partialData: Object,
organizationId: string
):Promise<Metadata,Error>

Parameters

ParameterTypeDescription
entityIdstring|Group|UserThe entity that the metadata is associated with
partialDataObjectAn object where each key in the existing metadata will have its value updated to match the value contained in the object
organizationIdstringThe Organization of the entity that the metadata is associated with; entities may have different metadata per organization

Returns

An error will be thrown if any of the arguments are invalid.

If the entity is not found, an error will be thrown with err.code equal to client.errors.NotFoundError.code.

Once the returned Promise is resolved, we will have access to the updated Metadata object.

Examples

try {
const entireData = await client.metadata.update(
'some-group-id',
{ 'new_key': 'new_value' },
'some-org-id'
);
console.log('metadata for some-group-id updated and is now:', entireData);
} catch (err) {
if (err.code == client.errors.NotFoundError.code) {
console.log('Entity not found');
} else {
console.log('Error');
}
}