Why store extracted fields as metadata
- You don’t need a separate table that maps results to file IDs since you apply a metadata instance to a specific file.
- You can filter by date ranges and numeric thresholds as template fields can be
string,float,date,enum,multiSelect, ortaxonomy. See . - Access follows Box permissions. Collaborators who can view an item can view its metadata, and collaborators with upload permission can edit the values. See Using metadata on Box Support.
- Box search indexes the values. People can also filter search results by template in the Box web app.
- Box AI fills the same template. When you pass a metadata template to Box AI, it returns values under the template’s field keys.
Before you start
You need:- A Box app with the Read and write all files and folders stored in Box and Manage AI scopes. See .
- Admin permission to create the metadata template. Only admins, and co-admins with rights to create and edit metadata templates, can create templates.
- The ID of the folder that holds your documents.
Create a metadata template for the fields
Usedate for dates and float for amounts so you can filter by range. Use enum for fields with a fixed set of values.
enterprise_<ENTERPRISE_ID>. The query examples in this guide write it as enterprise_${ENTERPRISE_ID}. To find your scope, . Admins can also create templates in the Admin Console. See Customizing metadata templates.
Extract the fields with the template
Call with the template instead of a list of fields. Theanswer object in the response holds the values under the template’s field keys. The response also includes ai_agent_info, created_at, and completion_reason. Box AI leaves out fields it can’t find, and returns an empty answer when the file contains none of them.
Write the values to the file
Send theanswer object to . Box returns 201 Created with the new metadata instance.
date fields store RFC 3339 timestamps. Box AI returns dates in this format when you extract with a template, so you can write them without conversion.
Update a file that already has the metadata
Update a file that already has the metadata
If the file already has an instance of the template, for example when you extract a file again, Box returns
409 Conflict. Update the instance with and a JSON Patch body. The add operation sets each value whether or not the field already has one.Filter the files with the Box Query API
Call the to find files by their metadata values. This request finds contracts in a folder and its subfolders that renew in the first quarter of 2027 and are worth at least 100,000, sorted by renewal date.id, which you can use to or show it in .
- In
predicate, reference template fields as<scope>:<templateKey>:<fieldKey>and item fields asbox:item:<field>. For operators, see . - Each value in
paramsmust match its field type. Use a number for afloatfield and an RFC 3339 timestamp for adatefield. limitcan be up to 100. Whennext_markerisn’tnull, pass it asmarkerin the next request and keep the other parameters the same.
string fields are case sensitive. Use ILIKE to ignore case, and add % wildcards to match part of a value. Values for enum fields must match an option key exactly. To find files where Box AI didn’t return a value, use EXISTS(:template) AND enterprise_${ENTERPRISE_ID}:contract:contractValue IS NULL with "template": "enterprise_${ENTERPRISE_ID}:contract" in params.
Get totals with the Box Query Insights API
To get totals instead of a list of files, send a predicate to . This request sums the value of contracts that renew in the first quarter of 2027.Choose an API for finding files by metadata
Give your team a filterable view in Box Apps
If the people who work with the contracts don’t write code, build a Box App on the same template. Box Apps is a no-code builder for apps based on metadata. A View block is a saved search based on one template, and the template’s fields become the view’s filters and columns. Box Apps is available on Box Enterprise Advanced plans.- A Box Admin enables Box Apps in Admin Console > Enterprise Settings > Content & Sharing, and chooses who can use Box Apps and who can manage apps. See Enabling Box Apps.
- In Box Apps, select New App and name the app.
- Add a View block, enter a view name, and choose the template, for example Contract. You can’t change the template after you create the view. See Creating an app.
- Open the view and select Edit. On the Filters tab, choose the fields people can filter by, such as Renewal date and Contract value. On the Columns tab, choose the columns to show, then select Save. See Configuring View in Box Apps.
- Share the app with your team. People with Viewer access can’t change the app.
Embed a metadata view in your own app
To show a filterable list of files and their metadata in your own web app, use the Content Explorer metadata view. It takes a Metadata Query API definition and gives each template field filter and edit controls for its type. See .Limits to plan for
- The Box Query API returns
403 Forbiddenwhen a query matches too many items, or too many items the user can’t access. Narrow the query withancestorsand a more specific predicate. - The Box Query API returns
429 Too Many Requestswhen your enterprise exceeds the allowed request rate. Wait and retry. See .