← Back to Docs

Error Code Reference

Every PatchOps Guard API error returns a structured JSON body with a machine-readable code (PG-XYYY), a human-readable message, and a suggested fix. 47 error codes across 6 categories.

{
  "error": {
    "code": "PG-1003",
    "message": "API key expired",
    "detail": "Your API key pk_live_...abc expired on 2026-04-15.",
    "fix": "Generate a new key at Settings → API Keys.",
    "docs": "https://patchguard.ai/guide#api-keys"
  }
}
🔍

Authentication

PG-1xxx

Errors related to API keys, sessions, and authorization.

CodeMessageStatusHow to Fix
PG-1001Missing authentication401Include 'Authorization: Bearer pk_live_...' header or login via /auth/github/start
PG-1002Invalid API key401Check your key at Settings → API Keys. Keys start with pk_live_ or pk_test_.
PG-1003API key expired401Generate a new key at Settings → API Keys.
PG-1004Insufficient API key scope403This endpoint requires a specific scope. Update your key's scopes at Settings → API Keys.
PG-1005Session expired401Log in again via /login.
PG-10062FA verification required403Provide your TOTP code or use a backup code.
PG-1007Organization access denied403Your API key does not belong to this organization. Switch org at Settings → Organizations.
PG-1008IP address not allowed403Your organization restricts API access by IP. Update allowed CIDRs at Settings → Security.

Input Validation

PG-2xxx

Errors caused by malformed or invalid request parameters.

CodeMessageStatusHow to Fix
PG-2001Invalid JSON body400Ensure the request body is valid JSON.
PG-2002Missing required field400Check the API docs for required fields.
PG-2003Invalid severity value400Use one of: critical, high, medium, low.
PG-2004Invalid finding kind400Use one of: cve, container, iac, secret, sast, malpkg, llm, model, mcp, agent.
PG-2005Invalid repository URL400Provide a valid GitHub/GitLab/Bitbucket repository URL.
PG-2006Unknown package ecosystem400Supported: pypi, npm, go, maven, cargo, nuget, composer, pub, swiftpm, hex, hackage, cran, rubygems.
PG-2007Invalid UUID format400IDs must be valid UUID v4 strings.
PG-2008Invalid pagination parameters400'page' must be >= 1, 'per_page' must be 1–100.
PG-2009Invalid SBOM format400Use one of: cyclonedx, spdx.
PG-2010Invalid filter expression400Check the filter syntax in the API docs.

Resource

PG-3xxx

The requested resource was not found or conflicts with existing state.

CodeMessageStatusHow to Fix
PG-3001Resource not found404Verify the resource ID. It may have been deleted.
PG-3002Repository not found404Check the repository ID or connect it at /onboarding.
PG-3003Finding not found404Verify the finding ID. Findings from disconnected repos are archived.
PG-3004Organization not found404Complete onboarding at /onboarding.
PG-3005Repair job not found404Check the job ID. Repair jobs are retained for 90 days.
PG-3006API key not found404The key may have been revoked. List active keys at Settings → API Keys.
PG-3007Webhook endpoint not found404Check your webhook configuration at Settings → Integrations.
PG-3008Organization member not found404The member may have left the organization.
PG-3009Resource already exists409A resource with this identifier already exists. Use a different value or update the existing one.
PG-3010Repair already in progress409Wait for the current repair to complete, or cancel it first.

Rate Limits & Quotas

PG-4xxx

You have exceeded a rate limit, plan quota, or concurrency ceiling.

CodeMessageStatusHow to Fix
PG-4001Rate limit exceeded429Wait and retry. Default: 1,000 requests/hour per API key.
PG-4002AI repair monthly quota exceeded429Upgrade your plan for more AI repairs at /pricing.
PG-4003Scan quota exceeded429Upgrade your plan for more scans at /pricing.
PG-4004Repository limit reached429Upgrade your plan to connect more repos at /pricing.
PG-4005Request payload too large413Maximum request body size is 10 MB.
PG-4006Concurrent repair limit reached429Maximum 5 simultaneous repair jobs per organization. Wait for one to finish.

Server

PG-5xxx

Internal platform errors. These are usually transient.

CodeMessageStatusHow to Fix
PG-5001Internal server error500If this persists, contact help@bitmax.im.
PG-5002Database error503Try again in a few seconds.
PG-5003Queue service unavailable503Background tasks may be delayed. Try again shortly.
PG-5004Sandbox execution failed500Retry the repair. If this persists, contact help@bitmax.im.
PG-5005Database migration required503Run 'alembic upgrade head' and restart the server.
PG-5006Scheduled maintenance503Check https://status.patchguard.ai for updates.

External Services

PG-6xxx

Upstream API failures from third-party services.

CodeMessageStatusHow to Fix
PG-6001GitHub API error502Check GitHub status at githubstatus.com.
PG-6002AI service unavailable503The AI repair engine is temporarily unavailable. Try again shortly.
PG-6003CVE data source unavailable503NVD/OSV may be experiencing issues. Findings are cached locally.
PG-6004GitLab API error502Check GitLab status at status.gitlab.com.
PG-6005Bitbucket API error502Check Bitbucket status at bitbucket.status.atlassian.com.
PG-6006Static analysis engine error503Retry the repair. The re-scan step will be retried automatically.
PG-6007Payment service error502Billing operations are temporarily unavailable. Try again shortly.
Still stuck?
Contact our support team or check the full API reference.
API ReferenceContact Support