Skip to main content

Using the Confidential File Reader

This tutorial shows how to use the Cape API to extract text confidentially from a variety of document types, including pdf, markdown, csv, docx, pptx, and xlsx. The file type will be determined using the file extension. Cape processes the request inside of an enclave so that no inputs or output can be seen by anyone but you.


To see the latest list of all supported file types please reference the API docs.

Get a Cape API Key

This tutorial assumes you have an environment variable CAPE_API_KEY that contains an API Key. You will need to signup for a Cape account, and then you can get an API key here.

Using the Cape API to call the Confidential File Reader

Here's how to use Python to make a request to the Cape API file reader endpoint. This assumes you've downloaded this file and placed it in the same directory as your code (but feel free to experiment with your own files).

import os
import requests
from requests_toolbelt.multipart.encoder import MultipartEncoder

url = ""

m = MultipartEncoder(
fields={'file': ('credit_card_app.pdf', open('credit_card_app.pdf', 'rb'))}

headers = {
"Content-Type": m.content_type,
"Authorization": f"Bearer {os.getenv('CAPE_API_KEY')}"

response =, data=m, headers=headers)

data = response.json()

You should see output similar to:

{'text': 'VISA® and MasterCard® Consumer Credit Card Application\nPlease print, sign, and fax this completed application (page 1 only) to: 972.650.7054.\nPage 1 of 2...}

For more details on this endpoint, please visit our API docs.