> ## Documentation Index
> Fetch the complete documentation index at: https://docs.case.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Privilege Detection Overview

> Detect attorney-client privilege and work product protection in documents for e-discovery

## The Problem

E-discovery teams review thousands of documents manually to identify privileged content. Miss one privileged document in production, and you've waived protection. Over-designate, and you face sanctions for obstruction.

## The Solution

An AI-powered privilege detection API that analyzes documents for attorney-client privilege, work product doctrine, and other protected communications. Get confidence scores, category breakdowns, and actionable recommendations for each document.

```mermaid theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
flowchart TD
    A["Ingest<br/>Upload documents to Vault or send content directly"] --> B["Analyze<br/>privilege.detect(...) scores privilege and rationale"]
    B --> C["Triage<br/>Act on the recommendation: withhold, redact, produce, or review"]
```

## Quick start

<CodeGroup>
  ```bash title="cURL" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  # Analyze content for privilege
  curl -X POST https://api.case.dev/privilege/v1/detect \
    -H "Authorization: Bearer $CASEDEV_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "content": "Attorney memo: Confidential legal advice regarding...",
      "categories": ["attorney_client", "work_product"],
      "include_rationale": true
    }'
  ```

  ```bash title="CLI" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  casedev privilege:v1 detect \
    --content "Attorney memo: Confidential legal advice regarding..." \
    --category attorney_client,work_product \
    --include-rationale
  ```

  ```typescript title="Typescript" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  import Casedev from 'casedev';

  const client = new Casedev({ apiKey: process.env.CASEDEV_API_KEY });

  // Analyze document content for privilege
  const result = await client.privilege.detect({
    content: 'Attorney memo: Confidential legal advice regarding...',
    categories: ['attorney_client', 'work_product'],
    include_rationale: true,
  });

  if (result.privileged) {
    console.log(`Privileged (${result.confidence * 100}% confidence)`);
    console.log(`Recommendation: ${result.recommendation}`);
    
    // Review detected categories
    for (const cat of result.categories) {
      if (cat.detected) {
        console.log(`  ${cat.type}: ${cat.rationale}`);
      }
    }
  } else {
    console.log('No privilege detected - safe to produce');
  }

  // Or analyze a document already in your Vault
  const vaultResult = await client.privilege.detect({
    document_id: 'doc_abc123',
    vault_id: 'vault_xyz789',
  });
  ```

  ```python title="Python" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  import casedev

  client = casedev.Casedev(api_key=os.environ['CASEDEV_API_KEY'])

  # Analyze document content for privilege
  result = client.privilege.v1.detect(
      content='Attorney memo: Confidential legal advice regarding...',
      categories=['attorney_client', 'work_product'],
      include_rationale=True,
  )

  if result.privileged:
      print(f'Privileged ({result.confidence * 100}% confidence)')
      print(f'Recommendation: {result.recommendation}')
      
      # Review detected categories
      for cat in result.categories:
          if cat.detected:
              print(f'  {cat.type}: {cat.rationale}')
  else:
      print('No privilege detected - safe to produce')

  # Or analyze a document already in your Vault
  vault_result = client.privilege.v1.detect(
      document_id='doc_abc123',
      vault_id='vault_xyz789',
  )
  ```

  ```go title="Go" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  result, _ := client.Privilege.V1.Detect(ctx, casedev.PrivilegeV1DetectParams{
  	Content:          casedev.F("Attorney memo: Confidential legal advice regarding..."),
  	Categories:       casedev.F([]string{"attorney_client", "work_product"}),
  	IncludeRationale: casedev.F(true),
  })

  if result.Privileged {
  	fmt.Printf("Privileged (%0.f%% confidence)\n", result.Confidence*100)
  	fmt.Printf("Recommendation: %s\n", result.Recommendation)

  	for _, cat := range result.Categories {
  		if cat.Detected {
  			fmt.Printf("  %s: %s\n", cat.Type, cat.Rationale)
  		}
  	}
  } else {
  	fmt.Println("No privilege detected - safe to produce")
  }
  ```
</CodeGroup>

## Endpoints

<CardGroup cols={2}>
  <Card title="detect" href="/api-reference/privilege/detect-privileged-content">
    Analyze document content for privilege indicators across multiple categories
  </Card>
</CardGroup>

## Privilege categories

| Category          | Description                                                 |
| ----------------- | ----------------------------------------------------------- |
| `attorney_client` | Communications between attorney and client for legal advice |
| `work_product`    | Materials prepared in anticipation of litigation            |
| `common_interest` | Shared communications under joint defense agreements        |
| `litigation_hold` | Documents subject to preservation obligations               |

## Recommendations

The API returns one of four recommendations based on analysis:

| Recommendation | When returned                      | Suggested action                             |
| -------------- | ---------------------------------- | -------------------------------------------- |
| `withhold`     | High confidence privilege detected | Do not produce; log for privilege log        |
| `redact`       | Partial privilege or mixed content | Redact privileged portions before production |
| `produce`      | No privilege indicators found      | Safe for production                          |
| `review`       | Ambiguous or borderline cases      | Requires attorney review                     |

## Vault integration

When you provide a `document_id` and `vault_id`, the API:

1. Retrieves the document content from your Vault
2. Analyzes it for privilege indicators
3. Stores the analysis results in the document's `privilege_analysis` metadata field

This enables bulk privilege review workflows where results are persisted alongside documents.

<CodeGroup>
  ```bash title="CLI" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  # Analyze and store results in Vault metadata
  casedev privilege:v1 detect \
    --document-id doc_abc123 \
    --vault-id vault_xyz789

  # Retrieve the document with stored analysis
  casedev vault:objects retrieve --id vault_xyz789 --object-id doc_abc123
  ```

  ```typescript title="Typescript" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  // Analyze and store results in Vault metadata
  const result = await client.privilege.detect({
    document_id: 'doc_abc123',
    vault_id: 'vault_xyz789',
  });

  // Results are now stored in the document metadata
  // Retrieve later with vault.get()
  const doc = await client.vault.get({ 
    vault_id: 'vault_xyz789',
    object_id: 'doc_abc123' 
  });
  console.log(doc.metadata.privilege_analysis);
  ```

  ```python title="Python" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  # Analyze and store results in Vault metadata
  result = client.privilege.v1.detect(
      document_id='doc_abc123',
      vault_id='vault_xyz789',
  )

  # Results are now stored in the document metadata
  # Retrieve later with vault.get()
  doc = client.vault.get(vault_id='vault_xyz789', object_id='doc_abc123')
  print(doc.metadata.privilege_analysis)
  ```

  ```go title="Go" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  // Analyze and store results in Vault metadata
  result, _ := client.Privilege.V1.Detect(ctx, casedev.PrivilegeV1DetectParams{
      DocumentID: casedev.F("doc_abc123"),
      VaultID:    casedev.F("vault_xyz789"),
  })

  // Results are now stored in the document metadata
  // Retrieve later with vault.get()
  doc, _ := client.Vault.Get(ctx, "vault_xyz789", "doc_abc123")
  fmt.Println(doc.Metadata.PrivilegeAnalysis)
  ```
</CodeGroup>

## Permissions

| Input Type                     | Required Permissions |
| ------------------------------ | -------------------- |
| Raw text (`content`)           | `chat`               |
| Vault document (`document_id`) | `chat` + `vault`     |

## Limits

* **Maximum document size:** 200,000 characters
* For larger documents, split into logical sections and analyze separately

## Supported jurisdictions

Currently supports **US-Federal** privilege standards. Additional jurisdictions coming soon.

## Related services

<CardGroup>
  <Card title="Vault" href="/vault">
    Store documents and run bulk privilege detection workflows
  </Card>

  <Card title="Legal Research" href="/legal-research">
    Verify citations in privileged documents before logging
  </Card>

  <Card title="OCR" href="/ocr">
    Extract text from scanned documents before privilege analysis
  </Card>
</CardGroup>
