Document Models - Analyze Document

Analyzes document with document model.

POST {endpoint}/formrecognizer/documentModels/{modelId}:analyze?api-version=2022-08-31
POST {endpoint}/formrecognizer/documentModels/{modelId}:analyze?pages={pages}&locale={locale}&stringIndexType={stringIndexType}&api-version=2022-08-31

URI Parameters

Name In Required Type Description
endpoint
path True

string

Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus2.api.cognitive.microsoft.com).

modelId
path True

string

Unique document model name.

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

api-version
query True

ApiVersion

Requested API version.

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").

pages
query

string

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

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

stringIndexType
query

StringIndexType

Method used to compute string offset and length.

Request Header

Media Types: "application/json", "application/octet-stream", "application/pdf", "image/jpeg", "image/png", "image/tiff", "image/bmp", "image/heif"

Name Required Type Description
Ocp-Apim-Subscription-Key True

string

Request Body

Media Types: "application/json", "application/octet-stream", "application/pdf", "image/jpeg", "image/png", "image/tiff", "image/bmp", "image/heif"

Name Type Description
base64Source

string

Base64 encoding of the document to analyze

urlSource

string

Document URL to analyze

Responses

Name Type Description
202 Accepted

Request is queued successfully.

Headers

Operation-Location: string

Other Status Codes

ErrorResponse

Error encountered.

Security

Ocp-Apim-Subscription-Key

Type: apiKey
In: header

Examples

AnalyzeDocument_Base64
AnalyzeDocument_Url

AnalyzeDocument_Base64

Sample request

POST {endpoint}/formrecognizer/documentModels/prebuilt-layout:analyze?pages=1-2,4&locale=en-US&stringIndexType=textElements&api-version=2022-08-31

{
  "base64Source": ""
}

Sample response

Operation-Location: {endpoint}/formrecognizer/documentModels/prebuilt-layout/analyzeResults/{resultId}?api-version=2022-08-31

AnalyzeDocument_Url

Sample request

POST {endpoint}/formrecognizer/documentModels/customModel:analyze?pages=1-2,4&locale=en-US&stringIndexType=textElements&api-version=2022-08-31

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

Sample response

Operation-Location: {endpoint}/formrecognizer/documentModels/customModel/analyzeResults/{resultId}?api-version=2022-08-31

Definitions

Name Description
AnalyzeDocumentRequest

Document analysis parameters.

ApiVersion

API version.

Error

Error info.

ErrorResponse

Error response object.

InnerError

Detailed 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

urlSource

string

Document URL to analyze

ApiVersion

API version.

Name Type Description
2022-08-31

string

Error

Error info.

Name Type Description
code

string

Error code.

details

Error[]

List of detailed errors.

innererror

InnerError

Detailed error.

message

string

Error message.

target

string

Target of the error.

ErrorResponse

Error response object.

Name Type Description
error

Error

Error info.

InnerError

Detailed error.

Name Type Description
code

string

Error code.

innererror

InnerError

Detailed error.

message

string

Error message.

StringIndexType

Method used to compute string offset and length.

Name Type Description
textElements

string

unicodeCodePoint

string

utf16CodeUnit

string