Document Models - Analyze Document

Analyzes document with document model.

POST {endpoint}/documentintelligence/documentModels/{modelId}:analyze?_overload=analyzeDocument&api-version=2024-02-29-preview
POST {endpoint}/documentintelligence/documentModels/{modelId}:analyze?_overload=analyzeDocument&api-version=2024-02-29-preview&pages={pages}&locale={locale}&stringIndexType={stringIndexType}&features={features}&queryFields={queryFields}&outputContentFormat={outputContentFormat}

URI Parameters

Name In Required Type Description
endpoint
path True

string

The Document Intelligence service endpoint.

modelId
path True

string

Unique document model name.

Regex pattern: ^[a-zA-Z0-9][a-zA-Z0-9._~-]{1,63}$

api-version
query True

string

The API version to use for this operation.

features
query

DocumentAnalysisFeature[]

List of optional analysis features.

locale
query

string

Locale hint for text recognition and document analysis. Value may contain only the language code (ex. "en", "fr") or BCP 47 language tag (ex. "en-US").

outputContentFormat
query

ContentFormat

Format of the analyze result top-level content.

pages
query

string

List of 1-based page numbers to analyze. Ex. "1-3,5,7-9"

Regex pattern: ^(\d+(-\d+)?)(,\s*(\d+(-\d+)?))*$

queryFields
query

string[]

List of additional fields to extract. Ex. "NumberOfGuests,StoreNumber"

stringIndexType
query

StringIndexType

Method used to compute string offset and length.

Request Body

Name Type Description
base64Source

string

Base64 encoding of the document to analyze. Either urlSource or base64Source must be specified.

urlSource

string

Document URL to analyze. Either urlSource or base64Source must be specified.

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

ErrorResponse

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

Analyze Document from Base64
Analyze Document from Url

Analyze Document from Base64

Sample Request

POST https://myendpoint.cognitiveservices.azure.com/documentintelligence/documentModels/prebuilt-layout:analyze?_overload=analyzeDocument&api-version=2024-02-29-preview&pages=1-2,4&locale=en-US&stringIndexType=textElements

{
  "base64Source": "e2Jhc2U2NEVuY29kZWRQZGZ9"
}

Sample Response

Operation-Location: https://myendpoint.cognitiveservices.azure.com/documentintelligence/documentModels/prebuilt-layout/analyzeResults/3b31320d-8bab-4f88-b19c-2322a7f11034?api-version=2024-02-29-preview

Analyze Document from Url

Sample Request

POST https://myendpoint.cognitiveservices.azure.com/documentintelligence/documentModels/customModel:analyze?_overload=analyzeDocument&api-version=2024-02-29-preview&pages=1-2,4&locale=en-US&stringIndexType=textElements

{
  "urlSource": "http://host.com/doc.pdf"
}

Sample Response

Operation-Location: https://myendpoint.cognitiveservices.azure.com/documentintelligence/documentModels/customModel/analyzeResults/3b31320d-8bab-4f88-b19c-2322a7f11034?api-version=2024-02-29-preview

Definitions

Name Description
AnalyzeDocumentRequest

Document analysis parameters.

ContentFormat

Format of the content in analyzed result.

DocumentAnalysisFeature

List of optional analysis features.

Error

The error object.

ErrorResponse

Error response object.

InnerError

An object containing more specific information about the error.

StringIndexType

Method used to compute string offset and length.

AnalyzeDocumentRequest

Document analysis parameters.

Name Type Description
base64Source

string

Base64 encoding of the document to analyze. Either urlSource or base64Source must be specified.

urlSource

string

Document URL to analyze. Either urlSource or base64Source must be specified.

ContentFormat

Format of the content in analyzed result.

Name Type Description
markdown

string

Markdown representation of the document content with section headings, tables, etc.

text

string

Plain text representation of the document content without any formatting.

DocumentAnalysisFeature

List of optional analysis features.

Name Type Description
barcodes

string

Enable the detection of barcodes in the document.

formulas

string

Enable the detection of mathematical expressions in the document.

keyValuePairs

string

Enable the detection of general key value pairs (form fields) in the document.

languages

string

Enable the detection of the text content language.

ocrHighResolution

string

Perform OCR at a higher resolution to handle documents with fine print.

queryFields

string

Enable the extraction of additional fields via the queryFields query parameter.

styleFont

string

Enable the recognition of various font styles.

Error

The error object.

Name Type Description
code

string

One of a server-defined set of error codes.

details

Error[]

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

innererror

InnerError

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.

ErrorResponse

Error response object.

Name Type Description
error

Error

Error info.

InnerError

An object containing more specific information about the error.

Name Type Description
code

string

One of a server-defined set of error codes.

innererror

InnerError

Inner error.

message

string

A human-readable representation of the error.

StringIndexType

Method used to compute string offset and length.

Name Type Description
textElements

string

User-perceived display character, or grapheme cluster, as defined by Unicode 8.0.0.

unicodeCodePoint

string

Character unit represented by a single unicode code point. Used by Python 3.

utf16CodeUnit

string

Character unit represented by a 16-bit Unicode code unit. Used by JavaScript, Java, and .NET.