API Documentation

Classify legal documents with AI. Extract dates, case numbers, parties, and more.

Quick Start

Get started in three simple steps.

1

Get Your API Key

Create an API key from the Console.

2

Encode Your PDF

Base64 encode your PDF document.

3

Send Request

POST to the classify endpoint and get structured JSON back.

cURL
# Encode PDF and send to API
curl -X POST https://api.mailroomagent.com/v1/classify \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "document": "'$(base64 -i document.pdf)'",
    "options": {
      "extract_dates": true,
      "extract_adj": true
    }
  }'

Endpoints

POST /v1/classify

Classify a document and extract structured data.

Request Headers

AuthorizationBearer YOUR_API_KEYRequired
Content-Typeapplication/jsonRequired

Request Body

documentBase64 encoded PDF contentRequired
document_typeFile type (default: "pdf")Optional
options.extract_datesExtract dates (default: true)Optional
options.extract_adjExtract ADJ numbers (default: true)Optional

Example Request

{
  "document": "JVBERi0xLjQK...",
  "document_type": "pdf",
  "options": {
    "extract_dates": true,
    "extract_adj": true
  }
}
POST /v1/analyze-batch

Analyze a batch-scanned PDF containing multiple documents separated by barcode separator sheets.

Request Body

documentBase64 encoded batch PDFRequired
casesArray of cases for matchingOptional
activity_typesArray of activity types for classificationOptional

Example Response

{
  "success": true,
  "data": {
    "separator_pages": [4, 8, 12],
    "documents": [
      {
        "start_page": 1,
        "end_page": 3,
        "doc_type": "Notice of Hearing",
        "applicant_name": "John Smith",
        "adj_numbers": ["ADJ13226857"],
        "document_date": "20260122",
        "suggested_filename": "20260122-notice-of-hearing-smith",
        "calendar_dates": [
          {
            "date": "2026-02-15",
            "time": "09:30",
            "type": "hearing",
            "location": "123 Main St, Riverside CA"
          }
        ]
      }
    ]
  }
}
GET /health

Check API health status.

// Response
{
  "status": "ok",
  "timestamp": "2026-02-02T18:30:00Z"
}

Rate Limits

Trial5 requests total, 60 requests/minute
Pro10,000 requests/month, 300 requests/minute
EnterpriseUnlimited requests, 1,000 requests/minute

Rate limit headers are included in 429 responses: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset

MCP Integration

Connect Mailroom Agent directly to Claude Code as an MCP server.

1. Add to Claude Code Settings

Edit ~/.claude/settings.json:

{
  "mcpServers": {
    "mailroom": {
      "type": "url",
      "url": "https://api.mailroomagent.com/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_API_KEY"
      }
    }
  }
}

2. Available Tools

classify_documentClassify document from base64 content
classify_fileClassify document from file path

3. Example Usage

# In Claude Code, just ask:

> Classify this PDF: /path/to/document.pdf

> What type of document is this and extract the hearing dates

> Extract all ADJ numbers from this legal document

Response Format

{
  "success": true,
  "data": {
    "document_type": "wcab_form",
    "confidence": 0.95,
    "summary": "Notice of Hearing from WCAB...",
    "page_count": 6,
    "parties": ["ANA GUEVARA", "ASCENA RETAIL GROUP"],
    "case_numbers": ["ADJ13226857"],
    "dates": [
      {
        "date": "2026-01-22",
        "type": "hearing",
        "description": "Date of Hearing",
        "location": "3737 MAIN ST, RIVERSIDE CA"
      }
    ],
    "adj_numbers": [
      {
        "number": "ADJ13226857",
        "claimant_name": "ANA GUEVARA",
        "employer": "ASCENA RETAIL GROUP INC"
      }
    ]
  }
}

Document Types

medical_report wcab_form correspondence deposition subpoena court_order billing unknown

Date Types

hearing deadline appointment trial injury other

Error Codes

400Bad Request - Invalid request body or missing required fields
401Unauthorized - Invalid or missing API key
403Forbidden - API key lacks required permissions
429Too Many Requests - Rate limit exceeded
500Internal Server Error - Something went wrong on our end
// Error Response
{
  "success": false,
  "error": "Invalid API key",
  "code": "UNAUTHORIZED"
}

Ready to Get Started?

Create your API key and start classifying documents in minutes.

Get API Key