collections module manages a user’s saved-content collections. Every user has a single root collection, under which they can nest sub-collections and into which they can save entities.
Collections are always scoped to a specific user. Pass that user’s Sublay ID as
userId on every call — your service key performs the operation on behalf of
that named user.fetchRootCollection
Fetches a user’s root collection, creating it on first access if it does not yet exist.The Sublay user ID whose root collection to fetch.
Promise<Collection>
fetchSubCollections
Fetches the direct child collections nested under a given collection.The parent collection ID.
The Sublay user ID who owns the collection.
Promise<Collection[]>
createNewCollection
Creates a new sub-collection under an existing parent collection.The parent collection under which to create the sub-collection.
The name of the new collection.
The Sublay user ID who will own the collection.
Promise<Collection>
fetchCollectionEntities
Fetches a paginated list of entities saved in a collection.The collection ID.
The Sublay user ID who owns the collection.
Page number (1-indexed). Defaults to
1.Results per page. Defaults to
20.Sort order:
"new", "added" (when saved), "top", or "hot".Sort direction:
"asc" or "desc".Comma-separated list of associations to populate (e.g.
"user").Promise<PaginatedResponse<Entity>>
addEntityToCollection
Saves an entity into a collection.The collection to add the entity to.
The Sublay entity ID to save.
The Sublay user ID who owns the collection.
Promise<Collection>
removeEntityFromCollection
Removes an entity from a collection.The collection to remove the entity from.
The Sublay entity ID to remove.
The Sublay user ID who owns the collection.
Promise<void>
updateCollection
Renames a collection.The collection ID to update.
The Sublay user ID who owns the collection.
The new collection name.
Promise<Collection>
deleteCollection
Deletes a collection.The collection ID to delete.
The Sublay user ID who owns the collection.
Promise<void>
