OpenParable
Skip to content
← Back to skills

API Debugging

Testing & Quality
api-debugging

API Debugging is an Agent Skill for testing & quality published in the ownpilot/OwnPilot repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Systematic approach to debugging REST APIs, HTTP errors, authentication issues, and network problems. Use when the user has API errors, status code issues, timeout problems, or needs help troubleshooting HTTP requests.

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/ownpilot/OwnPilot/blob/HEAD/packages/gateway/data/example-skills/api-debugging/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/api-debugging, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

API Debugging

You are an expert API debugger. Follow this systematic process when helping troubleshoot API issues.

Debugging Workflow

  1. Reproduce — Get the exact request that fails (URL, method, headers, body)
  2. Isolate — Is it the request, the server, auth, or network?
  3. Check basics — Status code, response body, headers
  4. Fix — Apply the solution
  5. Verify — Confirm the fix works

HTTP Status Code Guide

Client Errors (4xx)

CodeMeaningCommon CauseFix
400Bad RequestMalformed JSON, missing fieldCheck request body schema
401UnauthorizedMissing/expired tokenRefresh auth token
403ForbiddenInsufficient permissionsCheck API key scopes
404Not FoundWrong URL or deleted resourceVerify endpoint path
405Method Not AllowedGET instead of POSTCheck HTTP method
409ConflictDuplicate resourceCheck unique constraints
422UnprocessableValidation failedCheck field types/values
429Too Many RequestsRate limitedAdd retry with backoff

Server Errors (5xx)

CodeMeaningAction
500Internal Server ErrorCheck server logs, report bug
502Bad GatewayUpstream service down, retry
503Service UnavailableService overloaded, wait and retry
504Gateway TimeoutIncrease timeout, check slow queries

Authentication Checklist

When auth fails (401/403):

  1. Is the token/key present in the request?
  2. Is it in the right header? (Authorization: Bearer <token> vs X-API-Key: <key>)
  3. Has the token expired? (Decode JWT at jwt.io to check exp)
  4. Are the scopes/permissions sufficient?
  5. Is there an IP allowlist blocking the request?
  6. Is the API key for the correct environment (prod vs staging)?

Common Patterns

Retry with exponential backoff

Wait: 1s → 2s → 4s → 8s (max 3-4 retries)
Only retry on: 429, 500, 502, 503, 504
Never retry on: 400, 401, 403, 404

Debug steps for timeout issues

  1. Is the endpoint correct? (Try a simple GET first)
  2. Is the payload too large?
  3. Is the server under load? (Check response time headers)
  4. Is there a proxy/firewall in the way?
  5. Try with a longer timeout to confirm it's not just slow

CORS issues (browser only)

  • Error: "No Access-Control-Allow-Origin header"
  • Fix: Server must add Access-Control-Allow-Origin header
  • Workaround: Use server-side proxy, not browser fetch

Request Debugging Template

When analyzing a failed request, gather:

Endpoint:  [METHOD] [URL]
Headers:   [Key headers, especially Auth]
Body:      [Request payload]
Status:    [Response status code]
Response:  [Error message or body]
Timing:    [How long did it take?]
Context:   [When did it start failing? What changed?]