fields parameter, or use an already defined metadata template.
To learn more about creating templates, see Creating metadata templates in the Admin Console or use the metadata template API. You can also autofill metadata in templates using our Standard or Enhanced Extraction Agent.
Supported file formats
The endpoint supports the following file formats:- TIFF
- PNG
- JPEG
Supported languages
Box AI can extract metadata from documents in the following languages:- English
- Japanese
- Chinese
- Korean
- Cyrillic-based languages (such as Russian, Ukrainian, Bulgarian, and Serbian)
Before you start
Make sure you followed the steps listed in getting started with Box AI to create a platform app and authenticate.Send a request
To send a request, use thePOST /2.0/ai/extract_structured endpoint.
Parameters
To make a call, you must pass the following parameters. Mandatory parameters are in bold.The
items array can have exactly one element.| Parameter | Description | Example |
|---|---|---|
metadata_template | The metadata template containing the fields to extract. For your request to work, you must provide either metadata_template or fields, but not both. | |
metadata_template.type | The type of metadata template. | metadata_template |
metadata_template.scope | The scope of the metadata template that can either be global or enterprise. Global templates are those available to any Box enterprise, whereas enterprise templates are bound to a specific enterprise. | metadata_template |
metadata_template.template_key | The name of your metadata template. | invoice |
items.id | Box file ID of the document. The ID must reference an actual file with an extension. | 1233039227512 |
items.type | The type of the supplied input. | file |
items.content | The content of the item, often the text representation. | This article is about Box AI. |
fields.type | The type of the field. It include but is not limited to string, float, date, enum, and multiSelect. | string |
fields.description | A description of the field. | The person's name. |
fields.displayName | The display name of the field. | Name |
fields.key | A unique identifier for the field. | name |
fields.options | A list of options for this field. This is most often used in combination with the enum and multiSelect field types. | [{"key":"First Name"},{"key":"Last Name"}] |
fields.options.key | A unique identifier for the field. | First Name |
fields.prompt | Additional context about the key (identifier) that may include how to find and format it. | Name is the first and last name from the email address |
ai_agent | The AI agent used to override the default agent configuration. This parameter allows you to, for example, replace the default LLM with a custom one using the model parameter, tweak the base prompt to allow for a more customized user experience, or change an LLM parameter, such as temperature, to make the results more or less creative. Before you use the ai_agent parameter, you can get the default configuration using the GET 2.0/ai_agent_default request. For specific use cases, see the AI model overrides tutorial. |
Use cases
This example shows you how to extract metadata from a sample invoice in a structured way. Let’s assume you want to extract the vendor name, invoice number, and a few more details.
Create the request
To get the response from Box AI, callPOST /2.0/ai/extract_structured endpoint with the following parameters:
items.typeanditems.idto specify the file to extract the data from.fieldsto specify the data that you want to extract from the given file.metadata_templateto supply an already existing metadata template.
You can use either
fields or metadata_template to specify your structure, but not both.Use fields parameter
The fields parameter allows you to specify the data you want to extract. Each fields object has a subset of parameters you can use to add more information about the searched data.
For example, you can add the field type, description, or even a prompt with some additional context.
Use metadata template
If you prefer to use a metadata template, you can provide itstemplate_key, type, and scope.
Enhanced Extract Agent
To use the Enhanced Extract Agent, specify theai_agent object as follows:
- Inline field definitions (best when fields change frequently)
- Metadata template (best when fields stay consistent)
