Attributes
Attributes in Anchorpoint are custom metadata that can be attached to files, folders, and tasks to add context and organization to your assets. The Attributes API provides comprehensive functionality to read, write, and manage different types of attributes including tags, text fields, ratings, links, dates, and checkboxes.
Usage
import apsync
import anchorpoint
from datetime import datetime
ctx = anchorpoint.get_context()
api = anchorpoint.get_api()
# Set a text attribute by name
api.attributes.set_attribute_value(ctx.path, "Description", "Hero character artwork")
# Get a text attribute
description = api.attributes.get_attribute_value(ctx.path, "Description")
print(description) # Output: "Hero character artwork"
# Set a date attribute
api.attributes.set_attribute_value(ctx.path, "Created At", datetime.now())
# Work with attribute objects for more control
attribute = api.attributes.get_attribute("Status")
if not attribute:
attribute = api.attributes.create_attribute("Status", apsync.AttributeType.single_choice_tag)
# Set attribute value using attribute object
api.attributes.set_attribute_value(ctx.path, attribute, "In Progress")
Attribute Types
Anchorpoint supports several attribute types defined in the AttributeType class:
import apsync
# Available attribute types
apsync.AttributeType.single_choice_tag # Select one tag from predefined options
apsync.AttributeType.multiple_choice_tag # Select multiple tags from predefined options
apsync.AttributeType.text # Free text input
apsync.AttributeType.rating # Numeric rating
apsync.AttributeType.hyperlink # URL or file path links
apsync.AttributeType.date # Date/timestamp values
apsync.AttributeType.checkbox # Boolean true/false values
apsync.AttributeType.user # User attribute
AttributeType Class
The AttributeType class identifies the type of an attribute.
Members
single_choice_tagSelect one tag from predefined options.multiple_choice_tagSelect multiple tags from predefined options.textFree text input.ratingNumeric rating.hyperlinkURL or file path link.dateDate value.checkboxBoolean true/false value.userUser attribute.
Attributes API
The Attributes API is accessed through api.attributes and provides methods for creating, managing, and working with attributes.
import anchorpoint
api = anchorpoint.get_api()
attributes = api.attributes
Getting and Setting Attribute Values
-
api.attributes.get_attribute_value(target, attribute)Retrieves the value of an attribute for a file, folder, or task.Arguments
target(str or class: Task): Path to the file or folder, or a Task objectattribute(class: Attribute or str): The attribute object or attribute name
Returns: The attribute value, or None
-
api.attributes.set_attribute_value(target, attribute, value, update_timeline=False)Sets the value of an attribute for a file, folder, or task. Creates the attribute if it cannot be found.Arguments
target(str or class: Task): Path to the file or folder, or a Task objectattribute(class: Attribute or str): The attribute object or attribute namevalue(int, str, list, class: AttributeTag, class: AttributeTagList, bool): Value to setupdate_timeline(bool, optional): True if the timeline should be notified about the update. Default is False
Managing Attributes
-
api.attributes.get_attribute(name, type=None)Returns an attribute by name, or None if not found.Arguments
name(str): Name of the attribute (e.g., "Status")type(class: AttributeType, optional): Attribute type to filter by, or None
Returns: class: Attribute or None
-
api.attributes.get_attribute_by_id(id)Returns an attribute with a given id.Arguments
id(str): The id of the attribute
Returns: class: Attribute
-
api.attributes.get_attributes(type=None)Returns all attributes in the workspace or project, optionally filtered by type.Arguments
type(class: AttributeType, optional): Attribute type to filter for, or None
Returns: list[class: Attribute]
-
api.attributes.create_attribute(name, type, tags=None, rating_max=None)Creates a new attribute in the workspace or project.Arguments
name(str): Name of the attribute (e.g., "Status")type(class: AttributeType): The attribute typetags(class: AttributeTagList or list, optional): List of tags to create, or Nonerating_max(int, optional): The maximum rating value. Only valid for rating attributes
Returns: class: Attribute
-
api.attributes.rename_attribute(attribute, name)Renames an attribute.Arguments
attribute(class: Attribute): The attribute to renamename(str): The new name
Managing Tags
-
api.attributes.set_attribute_tags(attribute, tags)Sets the available tags for a single or multiple choice tag attribute.Arguments
attribute(class: Attribute): The attribute to updatetags(class: AttributeTagList): The list of tags
-
api.attributes.set_attribute_rating_max(attribute, max)Sets the maximum rating for a rating attribute.Arguments
attribute(class: Attribute): The attribute to updatemax(int): The new maximum rating value
Searching Attributes
-
api.attributes.search(filter, projects=None, types=None, batch_size=100, changed_since=None, attributes=None, case_insensitive=True, strict=True, workspace_id=None, skip_archived=False)Searches attributes across one, several, or all projects in a workspace. The search is lazy: nothing runs until you iterate. Each iteration yields one AttributeSearchBatch scoped to a single project, with at most
batch_sizeitems, sorted files first, then folders, then tasks. Projects that match nothing are skipped, so every batch you receive has at least one item.Arguments
filter(class: AttributeFilter): Built withapsync.attr(...)projects(sequence of str or class: Project, optional): Project ids, project names, or Project objects, in any mix.Nonesearches every project in the workspace. An empty list raisesValueErrorrather than doing so silently. Pass Project objects built from a local path (apsync.get_project(path)orapsync.create_project(path, ...)) to getbatch.project_pathanditem.absolute_pathfilled in — ids, names, and the Project objects fromget_projects()/get_project_by_id()carry no local root and leave both empty. The same project listed twice is searched oncetypes(list[str], optional): Any of"file","folder","task".Nonemeans all threebatch_size(int, optional): Maximum number of items per batch. Default is 100changed_since(int, optional): Restricts the results to objects that have at least one attribute cell synced at or after this watermark. It selects which objects qualify — the filter is always evaluated against the object's complete set of attribute cells, not only the changed ones. Pass thenext_changed_sinceof a previous searchattributes(str or list[str], optional): Which attribute values to return.Nonereturns only the attributes named in the filter,"all"returns every attribute (one extra query per project), and a list returns those attributes. A listed name that no searched project has is reported once insearch.warnings, whateverstrictsays: the argument picks which values come back, never what matches, so naming a superset across projects that hold different attributes is a legitimate way to use itcase_insensitive(bool, optional): Fall back to case-insensitive matching when an attribute or tag name has no exact match. Default is Truestrict(bool, optional): Raise if an attribute, tag, or member name the filter uses is found in no searched project. When False, such a name is reported insearch.warningsinstead. A name that is merely missing from some projects is neither an error nor a warning — attributes are per project, so most projects of a workspace not having the one you filtered on is normal. Default is Trueworkspace_id(str, optional): Defaults to the workspace set on the APIskip_archived(bool, optional): Leave archived projects out of the search, including ones listed explicitly inprojects. Default is False, so archived projects are searched
Returns: class: AttributeSearch
What the search can match:
- Only objects that already have at least one attribute value are considered. A file, folder or task with no attribute values at all is never a candidate, so conditions satisfied by absence —
is_empty(),not_contains(),equals(False)— return the objects whose other attributes are set and silently omit the untouched ones. There is no way to enumerate "every file without a Status" with this API - An
|(or) branch naming an attribute that does not exist in a project makes the whole filter unresolvable for that project, so its other branch reports nothing there either. A warning is emitted; withstrict=Falsethe search still succeeds. An&(and) behaves the same way, so a filter naming several attributes only reports from projects that have all of them - A name that matches two attributes of the same project is ambiguous, and that raises whatever
strictsays — unlike a name that is merely missing, it is a question the search cannot answer. Scope such a filter withprojectsto the projects that hold the name once, or rename one of the two attributes - Archived projects are searched by default, unlike
apsync.get_projects(), which skips them. Passskip_archived=Trueto leave them out - Relative hyperlink values are returned verbatim unless
absolute_pathis populated for that item.api.attributes.get_attribute_valuealways resolves them against the containing folder, so the two can disagree for one cell - With
strict=True, a name that resolves in no project raises only after the last project has been visited — real batches are yielded first, then the error
Change detection is limited by what has been synced to this computer:
- Your own edits are not stamped as they happen. A cell's sync watermark is written during a full resync (on client start, for example), not at the moment of the edit, so a
changed_sincepoll can miss a change this client just made until the next full resync. Changes arriving from other clients are stamped as they sync and are seen normally - Deleted objects and deleted cells are removed from the local database, so a
changed_sincepoll can never report a deletion - Only attribute cells are matched — renaming or moving a file surfaces nothing
- Results reflect what has been synced to this computer, not the state on the server
- The first poll of a pair sees a narrower watermark than the second. Without
changed_sinceonly the filtered fields are fetched, sonext_changed_sincecovers just those cells; a follow-up poll fetches every cell and can therefore return an item again because an unrelated attribute of it was newer. Polling never misses a change; it can repeat one
See Attribute Search below for the filter builder and the result classes.
AttributeTag Class
The AttributeTag class represents a single or multiple choice tag.
import apsync
tag = apsync.AttributeTag("In Progress", apsync.TagColor.yellow)
Constructor
-
apsync.AttributeTag(name)Creates a new attribute tag with a default color.Arguments
name(str): Name of the tag
-
apsync.AttributeTag(name, color)Creates a new attribute tag with a specified color.Arguments
name(str): Name of the tagcolor(class: TagColor or str): The color of the tag
Properties
id(str): Unique identifier of the tag.name(str): Name of the tag.color(class: TagColor): The color of the tag.
Attribute Class
The Attribute class represents an attribute definition. Attributes are not created directly — use api.attributes.get_attribute() or api.attributes.create_attribute() to obtain one.
import apsync
import anchorpoint
api = anchorpoint.get_api()
attribute = api.attributes.get_attribute("Status")
if not attribute:
attribute = api.attributes.create_attribute("Status", apsync.AttributeType.single_choice_tag)
Properties
id(str): Unique identifier for the attribute. Read-only.name(str): Name of the attribute.type(class: AttributeType): Type of the attribute. Read-only.tags(class: AttributeTagList): Available tags for tag-type attributes.rating_max(int or None): Maximum rating value. Only valid for rating attributes.
TagColor Class
The TagColor class represents the color of a single or multiple choice tag. Use the provided class members instead of raw strings.
import apsync
color = apsync.TagColor.green
Members
redRed color.orangeOrange color.yellowYellow color.greenGreen color.turkTurquoise color.blueBlue color.purplePurple color.greyGrey color.
Constructor
-
apsync.TagColor()Creates a default TagColor. -
apsync.TagColor(color)Creates a TagColor from a string value.Arguments
color(str): Color string (e.g.,"blue","red")