Skip to main content
Use this page when you need document text without an intelligent document processing (IDP) agent. Examples include indexing documents in a knowledge base and connecting the Document Retrieval Model Context Protocol (MCP) server to an MCP client such as Cursor. To build an agent that classifies documents and extracts values, see Build an intelligent document processing agent.

Prerequisites

  • Subscription key: A key for the API you plan to use. The optical character recognition (OCR) API and the Document Retrieval MCP API have separate subscriptions. To get a key, contact your Backbase support team.
  • Document URL: A URL that the service can download. Use a public HTTPS URL, an Azure Blob Storage shared access signature (SAS) URL, or a blob in a container that your installation allows. To confirm which containers your installation allows, contact your Backbase support team. For details, see Document sources.
Set your gateway URL and keys as environment variables so that you can copy the examples on this page:

Call the OCR API

Use the following operations to get document text.

Convert a PDF or image

To convert a PDF or image to markdown, send the file URL to the /convert endpoint:
The response contains the markdown and metadata about the run:
If the default mode fails, the service retries with the premium mode, and metadata.mode shows the mode that produced the result.

Fetch a text file

To fetch a TXT, JSON, CSV, MD, or XML file, send the file URL to the /text endpoint:
The response contains the file content. Text files don’t go through OCR, so metadata is null:

Connect an MCP client

The Document Retrieval MCP server uses the Streamable HTTP transport at $GATEWAY_URL/document-retrieval-mcp/v0/mcp. Send your Document Retrieval MCP API key in the api-key header.
For other clients, such as Claude Desktop and Agno agents, see MCP starters.

Troubleshooting

Cause: The request has no api-key header, or the key belongs to a different API.Solution: Send the key for the API you’re calling. The OCR API and the Document Retrieval MCP API use separate subscriptions.
Cause: The path is missing the version segment.Solution: Include /v0 in the path, for example /ocr/v0/convert or /document-retrieval-mcp/v0/mcp.
Cause: The file extension isn’t supported by the endpoint. POST /text also returns 400 when the blob container isn’t allowed and the URL has no SAS token.Solution: Check Supported file formats. Use /convert for PDFs and images and /text for text files. For blobs in other containers, pass a SAS URL. On POST /convert, a failed download of that blob returns 500.
Cause: The file is larger than 50 MB.Solution: Split or compress the document before you send it.
Cause: Your subscription exceeded its rate limit.Solution: Wait for the period in the Retry-After header and retry. If you need higher throughput, contact your Backbase support team.
Cause: The service couldn’t download the file, or both OCR modes failed. Common reasons are a URL that isn’t publicly reachable, an expired SAS token, or a file that doesn’t exist. On POST /convert, a blob outside the allowlist returns 500 when the HTTPS download fails.Solution: Check that you can download the file from the URL yourself. If the URL works and the error persists, contact your Backbase support team.