Document Classifiers - Build Classifier

Builds a custom document classifier.

POST {endpoint}/documentintelligence/documentClassifiers:build?api-version=2024-11-30

URI Parameters

Name In Required Type Description
endpoint
path True

string

uri

The Document Intelligence service endpoint.

api-version
query True

string

The API version to use for this operation.

Request Body

Name Required Type Description
classifierId True

string

Unique document classifier name.

docTypes True

<string,  ClassifierDocumentTypeDetails>

List of document types to classify against.

allowOverwrite

boolean

Allow overwriting an existing classifier with the same name.

baseClassifierId

string

Base classifierId on top of which to train the classifier.

description

string

Document classifier description.

Responses

Name Type Description
202 Accepted

The request has been accepted for processing, but processing has not yet completed.

Headers

  • Operation-Location: string
  • Retry-After: integer
Other Status Codes

DocumentIntelligenceErrorResponse

An unexpected error response.

Security

Ocp-Apim-Subscription-Key

Type: apiKey
In: header

OAuth2Auth

Type: oauth2
Flow: accessCode
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize
Token URL: https://login.microsoftonline.com/common/oauth2/token

Scopes

Name Description
https://cognitiveservices.azure.com/.default

Examples

Build Document Classifier

Sample request

POST https://myendpoint.cognitiveservices.azure.com/documentintelligence/documentClassifiers:build?api-version=2024-11-30

{
  "classifierId": "myClassifier",
  "description": "Classifier description",
  "docTypes": {
    "formA": {
      "azureBlobSource": {
        "containerUrl": "https://myStorageAccount.blob.core.windows.net/myContainer?mySasToken",
        "prefix": "formADocs/"
      }
    },
    "formB": {
      "azureBlobFileListSource": {
        "containerUrl": "https://myStorageAccount.blob.core.windows.net/myContainer?mySasToken",
        "fileList": "formB.jsonl"
      }
    }
  }
}

Sample response

Operation-Location: https://myendpoint.cognitiveservices.azure.com/documentintelligence/operations/b704bb00-d130-4f3f-a1d8-ca96de3eabb4?api-version=2024-11-30

Definitions

Name Description
AzureBlobContentSource

Azure Blob Storage content.

AzureBlobFileListContentSource

File list in Azure Blob Storage.

BuildDocumentClassifierRequest

Request body to build a new custom document classifier.

ClassifierDocumentTypeDetails

Classifier document type info.

ContentSourceKind

Type of content source.

DocumentIntelligenceError

The error object.

DocumentIntelligenceErrorResponse

Error response object.

DocumentIntelligenceInnerError

An object containing more specific information about the error.

AzureBlobContentSource

Azure Blob Storage content.

Name Type Description
containerUrl

string

Azure Blob Storage container URL.

prefix

string

Blob name prefix.

AzureBlobFileListContentSource

File list in Azure Blob Storage.

Name Type Description
containerUrl

string

Azure Blob Storage container URL.

fileList

string

Path to a JSONL file within the container specifying a subset of documents.

BuildDocumentClassifierRequest

Request body to build a new custom document classifier.

Name Type Default value Description
allowOverwrite

boolean

False

Allow overwriting an existing classifier with the same name.

baseClassifierId

string

Base classifierId on top of which to train the classifier.

classifierId

string

Unique document classifier name.

description

string

Document classifier description.

docTypes

<string,  ClassifierDocumentTypeDetails>

List of document types to classify against.

ClassifierDocumentTypeDetails

Classifier document type info.

Name Type Description
azureBlobFileListSource

AzureBlobFileListContentSource

Azure Blob Storage file list specifying the training data for a classifier document type. Either azureBlobSource or azureBlobFileListSource must be specified.

azureBlobSource

AzureBlobContentSource

Azure Blob Storage location containing the training data for a classifier document type. Either azureBlobSource or azureBlobFileListSource must be specified.

sourceKind

ContentSourceKind

Type of training data source.

ContentSourceKind

Type of content source.

Name Type Description
azureBlob

string

Files in a path within an Azure Blob Storage container.

azureBlobFileList

string

A file list specifying individual files in an Azure Blob Storage container.

base64

string

Content represented via Base64 encoding.

url

string

Content at a specific URL.

DocumentIntelligenceError

The error object.

Name Type Description
code

string

One of a server-defined set of error codes.

details

DocumentIntelligenceError[]

An array of details about specific errors that led to this reported error.

innererror

DocumentIntelligenceInnerError

An object containing more specific information than the current object about the error.

message

string

A human-readable representation of the error.

target

string

The target of the error.

DocumentIntelligenceErrorResponse

Error response object.

Name Type Description
error

DocumentIntelligenceError

Error info.

DocumentIntelligenceInnerError

An object containing more specific information about the error.

Name Type Description
code

string

One of a server-defined set of error codes.

innererror

DocumentIntelligenceInnerError

Inner error.

message

string

A human-readable representation of the error.