API Reference

gotcontext.ai compresses text and code before it enters an AI context window — saving up to 95% of input tokens. The REST API is simple: send text, get back a compressed skeleton plus token stats.

Quick Start#

Get your API key from the dashboard, then make your first compression call:

"color:#7dd3fc">curl "color:#fca5a5">-X POST https://api.gotcontext.ai/v1/compress \
  "color:#fca5a5">-H "Authorization: Bearer YOUR_API_KEY" \
  "color:#fca5a5">-H "Content-Type: application/json" \
  "color:#fca5a5">-d '{"text": "Your document text here...", "fidelity": "balanced"}'

MCP Server#

gotcontext.ai hosts a remote MCP (Model Context Protocol) server at https://api.gotcontext.ai/mcp. Connect any MCP-compatible AI tool to get compression, ingestion, and context management tools without running anything locally.

Free plans include 17 core tools (compression, advisory, budget awareness). Pro plans unlock 97 tools (everything in Free plus memory, CLI filter, meta-tokens, prompt cache, connectors, handoffs, experiments, and more). Enterprise plans include 126+ tools (all tools including ACE framework, detection, temporal graph, and multimodal).

Claude Code

{
  "mcpServers": {
    "gotcontext": {
      "url": "https://api.gotcontext.ai/mcp",
      "headers": {
        "Authorization": "Bearer gc_your_key_here"
      }
    }
  }
}

Cursor

{
  "mcpServers": {
    "gotcontext": {
      "url": "https://api.gotcontext.ai/mcp",
      "headers": {
        "Authorization": "Bearer gc_your_key_here"
      }
    }
  }
}

VS Code (settings.json)

{
  "mcp": {
    "servers": {
      "gotcontext": {
        "url": "https://api.gotcontext.ai/mcp",
        "headers": {
          "Authorization": "Bearer gc_your_key_here"
        }
      }
    }
  }
}

Gemini CLI (settings.json)

{
  "mcpServers": {
    "gotcontext": {
      "url": "https://api.gotcontext.ai/mcp",
      "type": "http",
      "headers": {
        "Authorization": "Bearer gc_your_key_here"
      },
      "timeout": 30000
    }
  }
}

Authentication

All MCP connections require a gc_-prefixed API key passed in the Authorization header. Create one from your dashboard.

For custom MCP clients

The MCP endpoint uses Streamable HTTP transport. Requests must include Accept: application/json, text/event-stream and carry the Mcp-Session-Id header from the initialize response on all subsequent calls. Claude Code, Cursor, and VS Code handle this automatically.

Recommended: Add project instructions

For best results, add a CLAUDE.md (or AGENTS.md) to your project root so the AI knows when and how to use gotcontext compression. Without this, the AI may not use the tools effectively. Copy this starter:

# gotcontext.ai Compression

This project uses gotcontext.ai for semantic compression via MCP.

## When to compress
- Before sending large files or docs to the AI context window
- When terminal output is verbose (git diff, test results, logs)
- When reviewing code across many files

## Compression workflow
1. Use `ingest_context` to add a document (give it a unique file_id)
2. Use `read_skeleton` to get the compressed version
3. Use `search_semantic` to find specific sections by query
4. Use `filter_cli_output` to compress git diffs, pytest output, etc.

## Tips
- Use `estimate_tokens` first to see if compression is worthwhile
- For code files, the compressor understands function/class boundaries
- Use `get_compression_presets` to see available fidelity levels
- Call `tool_help` for documentation on any specific tool

Authentication#

All API requests require a Bearer token in the Authorization header. Two token types are supported:

API Keys (recommended)

Prefixed with gc_. Create keys in the dashboard or viaPOST /v1/keys. Keys are permanent until revoked and can be rotated at any time.

Authorization: Bearer gc_a1b2c3d4e5f6...

Clerk JWT (session tokens)

Short-lived tokens issued by Clerk after sign-in. Used automatically by the dashboard frontend. For programmatic access, API keys are preferred.

Authorization: Bearer eyJhbGciOi...

Compression#

POST/v1/compress

Compress any text document using graph-based semantic compression. Achieves 80–95% token reduction on medium-to-large documents. Optionally supply a query to guide the compressor toward sections most relevant to your question.

AuthBearer token required
Fidelity levels: abstract (5% kept), outline (10%), balanced (20%), detailed (40%), raw (100% — no compression). Small documents under 100 tokens may expand slightly due to skeleton overhead.

Request body

{
  "text": string,       // required — document to compress (min 1 char)
  "fidelity": string,   // optional — "abstract" | "outline" | "balanced" | "detailed" | "raw"
                        //            default: "balanced"
  "query": string|null, // optional — query-guided mode; prioritises relevant sections
  "cost_model": string|null // optional — model name for cost estimate (e.g. "claude-opus-4")
}

Response

{
  "compressed": string,   // compressed skeleton text
  "stats": {
    "original_tokens": number,
    "compressed_tokens": number,
    "savings_pct": number,        // e.g. 87.4
    "compression_ratio": number,  // e.g. 7.9
    "estimated_cost_saved": string|null  // e.g. "$0.042" — only when cost_model supplied
  }
}
"color:#7dd3fc">curl "color:#fca5a5">-X POST https://api.gotcontext.ai/v1/compress \
  "color:#fca5a5">-H "Authorization: Bearer YOUR_API_KEY" \
  "color:#fca5a5">-H "Content-Type: application/json" \
  "color:#fca5a5">-d '{
    "text": "Transformer models fundamentally changed NLP...",
    "fidelity": "balanced",
    "query": "attention mechanism",
    "cost_model": "claude-sonnet-4-6"
  }'

Error responses

400Invalid fidelity value — valid options: abstract, outline, balanced, detailed, raw
422Missing or empty text field (Pydantic validation)
401Missing or invalid Bearer token
429Rate limit exceeded (see Rate Limits section)
POST/v1/compress-code

AST-aware code compression. Parses function/class boundaries, extracts imports and docstrings, ranks symbols by PageRank on the dependency graph. Returns a skeleton preserving signatures and docstrings. Significantly better than plain text compression for code.

AuthBearer token required
Supported languages with AST-native parsing: Python. JavaScript/TypeScript use regex-based chunking. Java, Go, Rust, C++ fall back to line-based chunking.

Request body

{
  "code": string,        // required — source code to compress (min 1 char)
  "language": string|null, // optional — hint: "python"|"javascript"|"typescript"|"java"|"go"|"rust"|"cpp"
                           //             auto-detected from content when omitted
  "fidelity": string,    // optional — same levels as /compress, default: "balanced"
}

Response

{
  "compressed": string,
  "stats": {
    "original_tokens": number,
    "compressed_tokens": number,
    "savings_pct": number,
    "language_detected": string  // e.g. "python", "javascript", "unknown"
  }
}
"color:#7dd3fc">curl "color:#fca5a5">-X POST https://api.gotcontext.ai/v1/compress-code \
  "color:#fca5a5">-H "Authorization: Bearer YOUR_API_KEY" \
  "color:#fca5a5">-H "Content-Type: application/json" \
  "color:#fca5a5">-d '{
    "code": "def process(items):\n    ...",
    "language": "">python",
    "fidelity": "balanced"
  }'

Error responses

400Invalid fidelity or unrecognised language hint
422Missing or empty code field
401Missing or invalid Bearer token
POST/v1/batch-compress

Compress up to 50 documents in a single call. Documents are processed concurrently (max 4 at once to avoid saturating the embedding model). Each document may have its own fidelity and query. Failed documents are reported inline — the overall batch always returns 200.

AuthBearer token required

Request body

{
  "documents": [    // required — 1 to 50 items
    {
      "text": string,       // required
      "fidelity": string,   // optional, default "balanced"
      "query": string|null  // optional
    }
  ]
}

Response

{
  "results": [
    {
      "compressed": string,
      "original_tokens": number,
      "compressed_tokens": number,
      "savings_pct": number,
      "compression_ratio": number,
      "error": string|null   // set when this document failed; other fields are 0
    }
  ],
  "summary": {
    "total_documents": number,
    "successful": number,
    "failed": number,
    "total_tokens_in": number,
    "total_tokens_saved": number,
    "avg_savings_pct": number,
    "avg_compression_ratio": number
  }
}
"color:#7dd3fc">curl "color:#fca5a5">-X POST https://api.gotcontext.ai/v1/batch-compress \
  "color:#fca5a5">-H "Authorization: Bearer YOUR_API_KEY" \
  "color:#fca5a5">-H "Content-Type: application/json" \
  "color:#fca5a5">-d '{
    "documents": [
      {"text": "First document...", "fidelity": "balanced"},
      {"text": "Second document...", "query": "neural networks"},
      {"text": "Third document...", "fidelity": "outline"}
    ]
  }'

Error responses

400Empty documents list, more than 50 documents, or invalid fidelity in any document
401Missing or invalid Bearer token
POST/v1/recommend

Analyse a document and recommend the optimal fidelity level. Considers document size and (optionally) the target model's context window. Use this to automatically pick the right compression level before calling /compress.

AuthBearer token required
Fidelity rules: <500 tokens → detailed, 500–2000 → balanced, 2000–10000 → outline, >10000 → abstract. If the compressed output would exceed 70% of the target model's context window, fidelity is automatically stepped up.

Request body

{
  "text": string,           // required — document to analyse
  "model": string|null,     // optional — target model (e.g. "claude-sonnet-4-6")
  "context_window": number|null  // optional — override context window size in tokens
}

Response

{
  "recommended_fidelity": string,  // e.g. "balanced"
  "estimated_ratio": number,       // fraction of tokens kept (0.0–1.0)
  "estimated_output_tokens": number,
  "original_tokens": number,
  "reasoning": string              // human-readable explanation
}
"color:#7dd3fc">curl "color:#fca5a5">-X POST https://api.gotcontext.ai/v1/recommend \
  "color:#fca5a5">-H "Authorization: Bearer YOUR_API_KEY" \
  "color:#fca5a5">-H "Content-Type: application/json" \
  "color:#fca5a5">-d '{
    "text": "Your long document...",
    "model": "claude-sonnet-4-6"
  }'

API Keys#

Create and manage API keys programmatically. Keys are prefixed gc_ and stored as HMAC-SHA256 hashes. The raw key is returned once on creation and cannot be retrieved again.

POST/v1/keys

Create a new API key. Returns the full raw key — store it immediately.

AuthBearer token required

Request body

{
  "name": string  // required — human-readable label (1–100 chars)
}

Response

{
  "key": string,       // full raw key — shown ONCE, store securely
  "key_id": string,    // 16-char hex ID for management
  "name": string,
  "created_at": string // ISO 8601 UTC
}
"color:#7dd3fc">curl "color:#fca5a5">-X POST https://api.gotcontext.ai/v1/keys \
  "color:#fca5a5">-H "Authorization: Bearer YOUR_CLERK_JWT" \
  "color:#fca5a5">-H "Content-Type: application/json" \
  "color:#fca5a5">-d '{"name": "Production server"}'

Error responses

422Missing name field or name too long (>100 chars)
401Authentication required
503Key storage unavailable (both Postgres and Redis down)
GET/v1/keys

List all API keys for the authenticated user. Returns masked key values — the raw key cannot be retrieved after creation.

AuthBearer token required

Response

{
  "keys": [
    {
      "key_id": string,
      "name": string,
      "masked_key": string,    // e.g. "gc_****ab12"
      "created_at": string,    // ISO 8601 UTC
      "last_used": string|null,
      "status": "active" | "revoked"
    }
  ]
}
"color:#7dd3fc">curl https://api.gotcontext.ai/v1/keys \
  "color:#fca5a5">-H "Authorization: Bearer YOUR_CLERK_JWT"
DELETE/v1/keys/:id

Revoke an API key by ID. Takes effect immediately — the key is rejected by the auth middleware within milliseconds.

AuthBearer token required

Response

{
  "success": true,
  "key_id": string
}
"color:#7dd3fc">curl "color:#fca5a5">-X DELETE https://api.gotcontext.ai/v1/keys/YOUR_KEY_ID \
  "color:#fca5a5">-H "Authorization: Bearer YOUR_CLERK_JWT"

Error responses

404Key ID not found
400Key is already revoked
401Authentication required
GET/v1/usage

Monthly compression statistics for the authenticated user. Returns compression counts, token totals, plan limit, and the next reset timestamp.

AuthBearer token required

Response

{
  "period": string,            // "YYYY-MM", e.g. "2026-04"
  "compressions_used": number,
  "compressions_limit": number, // 1000 (free) or 50000 (pro)
  "pct_used": number,          // 0.0–100.0
  "tokens_in": number,         // total original tokens this month
  "tokens_saved": number,      // total tokens eliminated this month
  "resets_at": string          // ISO 8601 UTC, midnight 1st of next month
}
"color:#7dd3fc">curl https://api.gotcontext.ai/v1/usage \
  "color:#fca5a5">-H "Authorization: Bearer YOUR_API_KEY"

Billing#

Billing is handled by Polar. The checkout and portal endpoints return redirect URLs — do not call these from server-side code without a user session.

POST/v1/billing/checkout

Create a Polar checkout session to upgrade to Pro. Returns a URL to redirect the user to.

AuthBearer token required (Clerk JWT)

Request body

{
  "plan": "pro"   // currently the only valid value
}

Response

{
  "checkout_url": string  // redirect the user to this URL
}
"color:#7dd3fc">curl "color:#fca5a5">-X POST https://api.gotcontext.ai/v1/billing/checkout \
  "color:#fca5a5">-H "Authorization: Bearer YOUR_CLERK_JWT" \
  "color:#fca5a5">-H "Content-Type: application/json" \
  "color:#fca5a5">-d '{"plan": "pro"}'

Error responses

400Unknown plan (only 'pro' is valid)
503Billing service unavailable or POLAR_PRO_PRODUCT_ID not configured
401Authentication required
POST/v1/billing/portal

Get the Polar customer portal URL to manage subscription, payment method, and invoices.

AuthBearer token required (Clerk JWT)

Response

{
  "portal_url": string  // redirect the user to this URL
}
"color:#7dd3fc">curl "color:#fca5a5">-X POST https://api.gotcontext.ai/v1/billing/portal \
  "color:#fca5a5">-H "Authorization: Bearer YOUR_CLERK_JWT"

Error responses

404No billing account found — user has not subscribed yet
503Billing service unavailable
401Authentication required

CLI Filter#

POST/v1/filter-cli

Compress verbose CLI output such as git diffs, test results, and npm install logs. Automatically detects the command type and applies type-specific compression. Typical savings: 80-99% on verbose output.

AuthBearer token required
Auto-detection supports git diff, pytest, jest, npm/yarn install, and other common CLI formats. Provide command_hint to skip detection and use a specific compressor.

Request body

{
  "output": string,        // required — raw CLI output to compress (min 1 char)
  "command_hint": string|null // optional — hint: "git_diff", "test_output", etc.
                              //            auto-detected if omitted
}

Response

{
  "filtered": string,      // compressed CLI output
  "original_chars": number,
  "filtered_chars": number,
  "savings_pct": number,   // e.g. 92.3
  "detected_type": string|null // e.g. "git_diff", "pytest"
}
"color:#7dd3fc">curl "color:#fca5a5">-X POST https://api.gotcontext.ai/v1/filter-cli \
  "color:#fca5a5">-H "Authorization: Bearer YOUR_API_KEY" \
  "color:#fca5a5">-H "Content-Type: application/json" \
  "color:#fca5a5">-d '{
    "output": "diff ">--git a/src/main.py b/src/main.py\n...",
    "command_hint": "git_diff"
  }'

Error responses

422Missing or empty output field
401Missing or invalid Bearer token
503CLI filter engine not available

Savings#

GET/v1/savings

Retrieve your cumulative compression savings across all time. Shows total compressions, tokens processed, tokens saved, and an estimated dollar amount saved based on mid-range model pricing.

AuthBearer token required

Response

{
  "total_compressions": number,
  "total_tokens_in": number,
  "total_tokens_saved": number,
  "savings_pct": number,              // e.g. 87.2
  "estimated_cost_saved_usd": number  // e.g. 12.45
}
"color:#7dd3fc">curl https://api.gotcontext.ai/v1/savings \
  "color:#fca5a5">-H "Authorization: Bearer YOUR_API_KEY"

Error responses

401Authentication required

Cache Audit#

POST/v1/audit-cache

Audit how cache-friendly a prompt is for a specific AI provider. Returns a cacheability score, whether the prompt is cache-friendly, actionable recommendations to improve cache hit rates, and estimated savings.

AuthBearer token required
Use this to optimise prompts for provider-specific caching (e.g. Anthropic prompt caching). Higher scores mean better cache utilisation and lower costs.

Request body

{
  "text": string,      // required — prompt or document text to audit (min 1 char)
  "provider": string   // optional — "anthropic" | "openai" | "google"
                       //            default: "anthropic"
}

Response

{
  "provider": string,
  "cache_friendly": boolean,
  "score": number,                // 0.0 - 1.0 cacheability score
  "recommendations": [string],    // actionable suggestions
  "estimated_savings_pct": number // estimated cache hit savings
}
"color:#7dd3fc">curl "color:#fca5a5">-X POST https://api.gotcontext.ai/v1/audit-cache \
  "color:#fca5a5">-H "Authorization: Bearer YOUR_API_KEY" \
  "color:#fca5a5">-H "Content-Type: application/json" \
  "color:#fca5a5">-d '{
    "text": "You are a helpful assistant that...",
    "provider": "anthropic"
  }'

Error responses

422Missing or empty text field
401Missing or invalid Bearer token
503Cache audit service not available

Budget Check#

POST/v1/check-budget

Check how much of a model's context window a text would consume. Returns token estimates, percentage used, a status indicator (OK / WARNING / CRITICAL), and a recommendation on whether to compress.

AuthBearer token required
Status thresholds: OK (< 50% used), WARNING (50-80%), CRITICAL (> 80%). Use before sending large documents to an AI model to decide whether compression is needed.

Request body

{
  "text": string,            // required — text to check against budget (min 1 char)
  "context_window": number,  // optional — target context window in tokens
                             //            default: 200000
  "model": string            // optional — target model for cost estimation
                             //            default: "claude-opus-4"
}

Response

{
  "estimated_tokens": number,
  "context_window": number,
  "pct_used": number,       // e.g. 42.5
  "status": string,         // "OK" | "WARNING" | "CRITICAL"
  "recommendation": string  // human-readable guidance
}
"color:#7dd3fc">curl "color:#fca5a5">-X POST https://api.gotcontext.ai/v1/check-budget \
  "color:#fca5a5">-H "Authorization: Bearer YOUR_API_KEY" \
  "color:#fca5a5">-H "Content-Type: application/json" \
  "color:#fca5a5">-d '{
    "text": "Your long document or codebase...",
    "context_window": 200000,
    "model": "claude-opus-4"
  }'

Error responses

422Missing or empty text field
401Missing or invalid Bearer token
503Budget check service not available

Issue Detection#

POST/v1/detect-issues

Detect hallucinations and blind spots in compressed output by comparing it against the original text. Finds claims not supported by the source (hallucinations) and critical information that was lost (blind spots). Requires a Pro or Enterprise plan.

AuthBearer token required (Pro / Enterprise)
This is a quality assurance tool for compression output. Run it after compressing important documents to verify no critical information was lost and no unsupported claims were introduced.

Request body

{
  "original_text": string,       // required — original uncompressed text (min 1 char)
  "compressed_text": string,     // required — compressed output to check (min 1 char)
  "check_hallucination": boolean, // optional — check for hallucinated content
                                  //            default: true
  "check_blind_spots": boolean   // optional — check for lost critical info
                                  //            default: true
}

Response

{
  "issues_found": number,
  "issues": [
    {
      "type": string,        // "hallucination" or "blind_spot"
      "severity": string,    // "low", "medium", or "high"
      "description": string,
      "location": string|null
    }
  ],
  "quality_score": number   // 0.0 - 1.0 (1.0 = no issues found)
}
"color:#7dd3fc">curl "color:#fca5a5">-X POST https://api.gotcontext.ai/v1/detect-issues \
  "color:#fca5a5">-H "Authorization: Bearer YOUR_API_KEY" \
  "color:#fca5a5">-H "Content-Type: application/json" \
  "color:#fca5a5">-d '{
    "original_text": "The full original document...",
    "compressed_text": "The compressed version...",
    "check_hallucination": true,
    "check_blind_spots": true
  }'

Error responses

403Requires a Pro or Enterprise plan
422Missing required text fields
401Missing or invalid Bearer token
503Issue detection service not available

Error Codes#

All errors return JSON with a detail field describing the problem.

// Example error response
{
  "detail": "Invalid fidelity 'garbage'. Valid: ['abstract', 'outline', 'balanced', 'detailed', 'raw']"
}
400

Bad Request

Invalid parameter value (e.g. invalid fidelity, unknown plan, already-revoked key).

401

Unauthorized

Missing, expired, or invalid Bearer token.

404

Not Found

Resource not found (e.g. unknown key_id).

422

Unprocessable Entity

Pydantic validation failed — missing required field or wrong type.

429

Too Many Requests

Rate limit exceeded. Check the Retry-After header.

500

Internal Server Error

Unexpected server error. Retry with exponential back-off.

503

Service Unavailable

Dependency unavailable (Redis, Postgres, or billing service).

Rate Limits#

PlanRate limitMonthly compressions
Free10 requests / minute1,000 / month
Pro100 requests / minute50,000 / month
Monthly limits reset at midnight UTC on the 1st of each month. Check GET /v1/usage for your current consumption. When you hit the rate limit, the API responds with HTTP 429 and a Retry-After header.

Projects#

RequiresTeam orEnterprise plan.

Organize compression workloads into projects. Each project tracks its own usage stats, making it easy to attribute token savings across teams or applications.

POST/v1/projects

Create a compression project.

AuthBearer token required (Team / Enterprise)

Request body

{
  "name": string,          // required — project name (1-100 chars)
  "description": string|null // optional — project description
}

Response

{
  "id": string,
  "name": string,
  "description": string|null,
  "created_at": string,
  "stats": { "compressions": 0, "tokens_saved": 0 }
}
"color:#7dd3fc">curl "color:#fca5a5">-X POST https://api.gotcontext.ai/v1/projects \
  "color:#fca5a5">-H "Authorization: Bearer YOUR_API_KEY" \
  "color:#fca5a5">-H "Content-Type: application/json" \
  "color:#fca5a5">-d '{"name": "backend-docs", "description": "API documentation compression"}'

Error responses

403Requires Team or Enterprise plan
422Missing or invalid name
GET/v1/projects

List all projects for the authenticated user.

AuthBearer token required (Team / Enterprise)

Response

{
  "projects": [
    {
      "id": string,
      "name": string,
      "description": string|null,
      "created_at": string,
      "stats": {
        "compressions": number,
        "tokens_saved": number
      }
    }
  ]
}
"color:#7dd3fc">curl https://api.gotcontext.ai/v1/projects \
  "color:#fca5a5">-H "Authorization: Bearer YOUR_API_KEY"
GET/v1/projects/{id}

Get project detail with usage statistics.

AuthBearer token required (Team / Enterprise)

Response

{
  "id": string,
  "name": string,
  "description": string|null,
  "created_at": string,
  "updated_at": string,
  "stats": {
    "compressions": number,
    "tokens_saved": number,
    "avg_savings_pct": number
  }
}
"color:#7dd3fc">curl https://api.gotcontext.ai/v1/projects/YOUR_PROJECT_ID \
  "color:#fca5a5">-H "Authorization: Bearer YOUR_API_KEY"

Error responses

404Project not found
PUT/v1/projects/{id}

Update a project's name or description.

AuthBearer token required (Team / Enterprise)

Request body

{
  "name": string|null,        // optional — new name
  "description": string|null  // optional — new description
}

Response

{
  "id": string,
  "name": string,
  "description": string|null,
  "updated_at": string
}
"color:#7dd3fc">curl "color:#fca5a5">-X PUT https://api.gotcontext.ai/v1/projects/YOUR_PROJECT_ID \
  "color:#fca5a5">-H "Authorization: Bearer YOUR_API_KEY" \
  "color:#fca5a5">-H "Content-Type: application/json" \
  "color:#fca5a5">-d '{"name": "backend-docs-v2"}'

Error responses

404Project not found
403Requires Team or Enterprise plan
DELETE/v1/projects/{id}

Delete a project. Compression history is retained but unlinked.

AuthBearer token required (Team / Enterprise)

Response

{
  "success": true,
  "id": string
}
"color:#7dd3fc">curl "color:#fca5a5">-X DELETE https://api.gotcontext.ai/v1/projects/YOUR_PROJECT_ID \
  "color:#fca5a5">-H "Authorization: Bearer YOUR_API_KEY"

Error responses

404Project not found
403Requires Team or Enterprise plan

Batch Queue#

RequiresTeam orEnterprise plan.

Submit large compression jobs asynchronously. The batch queue processes documents in the background and returns results when complete — ideal for bulk ingestion pipelines.

POST/v1/batch-queue

Submit an async batch compression job. Returns 202 Accepted with a job ID for polling.

AuthBearer token required (Team / Enterprise)

Request body

{
  "documents": [           // required — 1 to 500 items
    {
      "text": string,      // required
      "fidelity": string,  // optional, default "balanced"
      "query": string|null // optional
    }
  ],
  "project_id": string|null, // optional — associate with a project
  "webhook_url": string|null // optional — POST results on completion
}

Response

{
  "job_id": string,
  "status": "queued",
  "documents_count": number,
  "created_at": string
}
"color:#7dd3fc">curl "color:#fca5a5">-X POST https://api.gotcontext.ai/v1/batch-queue \
  "color:#fca5a5">-H "Authorization: Bearer YOUR_API_KEY" \
  "color:#fca5a5">-H "Content-Type: application/json" \
  "color:#fca5a5">-d '{
    "documents": [
      {"text": "First document..."},
      {"text": "Second document...", "fidelity": "outline"}
    ]
  }'

Error responses

403Requires Team or Enterprise plan
400Empty documents list or more than 500 items
GET/v1/batch-queue

List batch jobs for the authenticated user.

AuthBearer token required (Team / Enterprise)

Response

{
  "jobs": [
    {
      "job_id": string,
      "status": "queued" | "processing" | "completed" | "failed",
      "documents_count": number,
      "completed_count": number,
      "created_at": string,
      "completed_at": string|null
    }
  ]
}
"color:#7dd3fc">curl https://api.gotcontext.ai/v1/batch-queue \
  "color:#fca5a5">-H "Authorization: Bearer YOUR_API_KEY"
GET/v1/batch-queue/{id}

Get job status and progress.

AuthBearer token required (Team / Enterprise)

Response

{
  "job_id": string,
  "status": "queued" | "processing" | "completed" | "failed",
  "documents_count": number,
  "completed_count": number,
  "failed_count": number,
  "created_at": string,
  "completed_at": string|null,
  "progress_pct": number   // 0.0 - 100.0
}
"color:#7dd3fc">curl https://api.gotcontext.ai/v1/batch-queue/YOUR_JOB_ID \
  "color:#fca5a5">-H "Authorization: Bearer YOUR_API_KEY"

Error responses

404Job not found
GET/v1/batch-queue/{id}/results

Retrieve completed batch results. Only available when status is 'completed'.

AuthBearer token required (Team / Enterprise)

Response

{
  "job_id": string,
  "results": [
    {
      "compressed": string,
      "original_tokens": number,
      "compressed_tokens": number,
      "savings_pct": number,
      "error": string|null
    }
  ],
  "summary": {
    "total_documents": number,
    "successful": number,
    "failed": number,
    "total_tokens_saved": number,
    "avg_savings_pct": number
  }
}
"color:#7dd3fc">curl https://api.gotcontext.ai/v1/batch-queue/YOUR_JOB_ID/results \
  "color:#fca5a5">-H "Authorization: Bearer YOUR_API_KEY"

Error responses

404Job not found
409Job not yet completed

Analytics#

RequiresTeam orEnterprise plan.

Detailed analytics for compression usage across projects. View per-project breakdowns, track trends over time, and export data for reporting.

GET/v1/analytics/summary

Per-project usage breakdown for the current billing period.

AuthBearer token required (Team / Enterprise)

Response

{
  "period": string,           // "YYYY-MM"
  "total_compressions": number,
  "total_tokens_saved": number,
  "projects": [
    {
      "project_id": string,
      "project_name": string,
      "compressions": number,
      "tokens_saved": number,
      "avg_savings_pct": number
    }
  ]
}
"color:#7dd3fc">curl https://api.gotcontext.ai/v1/analytics/summary \
  "color:#fca5a5">-H "Authorization: Bearer YOUR_API_KEY"

Error responses

403Requires Team or Enterprise plan
GET/v1/analytics/export

Export analytics data as CSV for the specified date range.

AuthBearer token required (Team / Enterprise)

Response

Content-Type: text/csv

date,project,compressions,tokens_in,tokens_saved,savings_pct
2026-04-01,backend-docs,142,284000,248000,87.3
2026-04-01,frontend-app,89,178000,151300,85.0
...
"color:#7dd3fc">curl "https://api.gotcontext.ai/v1/analytics/export?start=2026-04-01&end=2026-04-14" \
  "color:#fca5a5">-H "Authorization: Bearer YOUR_API_KEY" \
  "color:#fca5a5">-o analytics.csv

Error responses

403Requires Team or Enterprise plan
400Invalid date range or missing parameters