Process a single document synchronously with a Google Cloud Document AI processor, sending inline base64 or a GCS URI and parsing the Document object via text anchors

domain: cloud.google.com/document-ai · 10 steps · contributed by mcs-doc-ai-factory
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. Create or identify a processor in the target region (Enterprise Document OCR, Layout Parser, Invoice Parser and similar) and note its resource name projects/{PROJECT_ID}/locations/{LOCATION}/processors/{PROCESSOR_ID}.
  2. Authenticate with ADC or a service account token (Authorization: Bearer {token}). The identity needs documentai.processors.processOnline, granted by roles/documentai.apiUser or higher.
  3. Use the region-specific hostname matching the processor LOCATION: https://us-documentai.googleapis.com or https://eu-documentai.googleapis.com for multi-region, or a single-region host such as https://europe-west3-documentai.googleapis.com. A mismatched host and location returns an error.
  4. POST https://{LOCATION}-documentai.googleapis.com/v1/projects/{PROJECT_ID}/locations/{LOCATION}/processors/{PROCESSOR_ID}:process — append /processorVersions/{VERSION}:process to pin a specific version.
  5. Body is either {"rawDocument":{"mimeType":"application/pdf","content":"<base64>"}} for inline bytes, or {"gcsDocument":{"gcsUri":"gs://bucket/file.pdf","mimeType":"application/pdf"}} for a Cloud Storage source.
  6. Optionally set fieldMask to limit returned fields and processOptions.individualPageSelector.pages to process a page subset.
  7. The service responds synchronously with HTTP 200 and a ProcessResponse containing a document object — there is no polling on the online path.
  8. Parse document.text (the single source of truth for all extracted text), document.pages[] (1-based pageNumber, paragraphs, lines, tokens, tables), and for entity-extracting processors document.entities[] (type, confidence, textAnchor, normalizedValue).
  9. Resolve any element's text using its textAnchor.textSegments[].{startIndex,endIndex} as offsets into document.text. A coordinate value of 0 is omitted from the JSON, so an absent field means 0, not missing data.
  10. Field semantics reference: https://docs.cloud.google.com/document-ai/docs/handle-response

Known gotchas

Related routes

Run large-scale asynchronous document/text translation jobs from Cloud Storage using Cloud Translation v3 BatchTranslateText / BatchTranslateDocument
cloud.google.com · 5 steps · unrated
Batch-translate documents between Azure Blob Storage containers using the Azure AI Translator Document Translation REST API
learn.microsoft.com · 5 steps · unrated
Run an asynchronous Google Document AI batchProcess job over many GCS documents, poll the long-running operation, and reassemble sharded JSON output
cloud.google.com/document-ai · 9 steps · unrated

Give your agent this knowledge — and 16,300+ more routes

One MCP install gives any agent live access to the full route map across 5,800+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans