Using DocuPipe from Claude Code, Codex or Cursor

Give a coding agent your API key and it can upload documents and extract data with DocuPipe on its own.

Coding agents such as Claude Code, Codex and Cursor can use DocuPipe in two ways. Install the DocuPipe MCP server and the agent gets ready-made tools, or skip the install and the agent reads these docs and writes the API calls itself. Either way, all they need from you is an API key.

1. Get an API key

Sign up, then copy your API key from the Developers card on the Settings page.

Put the key in an environment variable before you start the agent:

export DOCUPIPE_API_KEY="your-api-key"
🚧

Your API key gives full access to your account. Keep it in an environment variable instead of pasting it into the chat or into code the agent writes to disk.

2. Install the MCP server (optional)

The DocuPipe MCP server gives the agent an extract tool that goes from a file to structured JSON in one call, so it doesn't have to write upload and polling code. It needs Node.js 18 or newer. Replace your-api-key with your key.

Claude Code:

claude mcp add docupipe --scope user -e DOCUPIPE_API_KEY=your-api-key -- npx -y @docupipe/mcp

Codex:

codex mcp add docupipe --env DOCUPIPE_API_KEY=your-api-key -- npx -y @docupipe/mcp

Cursor and other clients that use an mcp.json file:

{
  "mcpServers": {
    "docupipe": {
      "command": "npx",
      "args": ["-y", "@docupipe/mcp"],
      "env": { "DOCUPIPE_API_KEY": "your-api-key" }
    }
  }
}

3. Ask the agent

Start the agent in the folder that holds your documents and say what you want, for example:

Use DocuPipe to extract the invoice number, invoice date, vendor name, total amount and line items from invoice.pdf, and save the result to invoice.json. My API key is in DOCUPIPE_API_KEY. The API docs are at docs.docupipe.ai/llms.txt.

The agent uploads the file, writes a Schema for the fields you named, runs the extraction, waits for it to finish and saves the result.

📘

docs.docupipe.ai/llms.txt lists every endpoint with a link to its reference page in plain markdown. Agents can find it through a web search, but naming it in the prompt saves them the search.

What the agent needs

If the agent gets stuck, or you are writing the calls yourself, these are the parts it uses:

StepCall
Base URLhttps://app.docupipe.ai
Authenticationyour key in the X-API-Key header on every request
Upload a filePOST /document with the file base64-encoded, or a URL. Returns a documentId and a jobId
Wait for jobsPOST /jobs/wait returns as soon as the listed jobs finish (up to 300 seconds per call), or poll GET /job/{jobId}
ExtractPOST /v3/standardize with the documentId and an optional schemaId. Returns a jobId and a standardizationId
Get the resultGET /standardization/{standardizationId}. The extracted fields are in data

Here is the whole flow in Python, using a draft schema that DocuPipe writes from the document:

import base64
import os
import requests

API = "https://app.docupipe.ai"
HEADERS = {"X-API-Key": os.environ["DOCUPIPE_API_KEY"]}


def wait(job_id):
    while True:
        res = requests.post(f"{API}/jobs/wait", json={"jobIds": [job_id], "maxWaitSeconds": 60}, headers=HEADERS).json()
        if res["allComplete"]:
            if res["anyError"]:
                raise RuntimeError(res["jobs"][0]["errorMessage"])
            return


with open("invoice.pdf", "rb") as f:
    contents = base64.b64encode(f.read()).decode()
upload = requests.post(f"{API}/document", json={"document": {"file": {"contents": contents, "filename": "invoice.pdf"}}}, headers=HEADERS).json()
wait(upload["jobId"])

run = requests.post(f"{API}/v3/standardize", json={"documentId": upload["documentId"]}, headers=HEADERS).json()
wait(run["jobId"])

result = requests.get(f"{API}/standardization/{run['standardizationId']}", headers=HEADERS).json()
print(result["data"])

To control which fields come back, pass a schemaId, or guidelines that say what to extract.

👍

When you run the same kind of document again and again, reuse one schema. A run without a schemaId returns the schemaId of the draft it wrote, so you can pass that on later calls, or create your own with POST /schema. Every document then comes back with the same fields.

Credits

Uploads and extractions use credits from your account. A run without a schemaId also uses credits to write the draft schema. See Understanding Credits and Billing for the cost of each operation.