box-node-sdk

SearchManager

Query files/folders by metadata

Create a search using SQL-like syntax to return items that match specific metadata.

By default, this endpoint returns only the most basic info about the items for which the query matches. To get additional fields for each item, including any of the metadata, use the fields attribute in the query.

This operation is performed by calling function searchByMetadataQuery.

See the endpoint docs at API Reference.

await client.search.searchByMetadataQuery({
  ancestorFolderId: '0',
  from: searchFrom,
  query:
    'name = :name AND age < :age AND birthDate >= :birthDate AND countryCode = :countryCode AND sports = :sports',
  queryParams: {
    ['name']: 'John',
    ['age']: 50,
    ['birthDate']: '2001-01-01T02:20:10.120Z',
    ['countryCode']: 'US',
    ['sports']: ['basketball', 'tennis'],
  },
} satisfies MetadataQuery);

Arguments

Returns

This function returns a value of type MetadataQueryResults.

Returns a list of files and folders that match this metadata query.

Search for content

Searches for files, folders, web links, and shared files across the users content or across the entire enterprise.

This operation is performed by calling function searchForContent.

See the endpoint docs at API Reference.

await client.search.searchForContent({
  ancestorFolderIds: ['0'],
  mdfilters: [
    {
      filters: searchFilters,
      scope: 'enterprise' as MetadataFilterScopeField,
      templateKey: templateKey,
    } satisfies MetadataFilter,
  ],
} satisfies SearchForContentQueryParams);

Arguments

Returns

This function returns a value of type SearchResultsResponse.

Returns a collection of search results. If there are no matching search results, the entries array will be empty.