Error Codes & Troubleshooting

WebPerception API uses standard HTTP status codes. This guide covers every error you might encounter and how to fix it.

HTTP Status Codes

CodeNameDescription
200OKRequest succeeded. Response contains your data.
400Bad RequestInvalid parameters. Check the error field for details.
401UnauthorizedMissing or invalid API key.
403ForbiddenValid API key but insufficient permissions or plan limits.
404Not FoundThe target URL returned a 404 or the endpoint doesn't exist.
422UnprocessableValid request but the target page couldn't be processed (e.g., CAPTCHA, login wall).
429Rate LimitedToo many requests. Slow down or upgrade your plan.
500Server ErrorSomething went wrong on our end. Retry with exponential backoff.
502Bad GatewayUpstream timeout. The target site took too long to respond.
503Service UnavailableTemporary maintenance. Retry after a few seconds.

Common Issues

401 — "Invalid API Key"

Your API key is missing, malformed, or revoked.

Fix:

# ✅ Correct
curl -X POST https://api.mantisapi.com/v1/scrape \
  -H "Authorization: Bearer sk_live_abc123..." \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com"}'

# ❌ Wrong — missing "Bearer" prefix
curl -X POST https://api.mantisapi.com/v1/scrape \
  -H "Authorization: sk_live_abc123..."

429 — Rate Limited

You've exceeded your plan's requests-per-second limit.

💡 Tip: Check the Retry-After header in the response — it tells you exactly how many seconds to wait.

Implement exponential backoff:

import time
import requests

def scrape_with_retry(url, api_key, max_retries=3):
    for attempt in range(max_retries):
        response = requests.post(
            "https://api.mantisapi.com/v1/scrape",
            headers={"Authorization": f"Bearer {api_key}"},
            json={"url": url}
        )
        if response.status_code == 429:
            wait = int(response.headers.get("Retry-After", 2 ** attempt))
            print(f"Rate limited. Waiting {wait}s...")
            time.sleep(wait)
            continue
        return response
    raise Exception("Max retries exceeded")

422 — Page Can't Be Processed

The target page loaded but couldn't be scraped. Common causes:

502 — Target Site Timeout

The website you're scraping took too long to respond (>30 seconds).

Fix:

Empty or Unexpected Content

You got a 200 response but the content isn't what you expected.

⚠️ Common cause: The page requires JavaScript rendering but you didn't enable it. Add "render_js": true to your request.
# Many modern sites need JS rendering
response = requests.post(
    "https://api.mantisapi.com/v1/scrape",
    headers={"Authorization": f"Bearer {api_key}"},
    json={
        "url": "https://example.com/dynamic-page",
        "render_js": True,
        "wait_for": ".product-card"  # Wait for this element
    }
)

AI Extraction Errors

Extraction Returns Empty or Wrong Data

💡 Pro tip: Always test your extraction schema on a single page before running it at scale. Use the /scrape endpoint first to see what content the AI model receives.

Credit Usage

EndpointStandardWith JS Rendering
/scrape1 credit2 credits
/screenshot1 credit2 credits
/extract2 credits3 credits

Failed requests are not charged. If a request returns a 4xx or 5xx error, no credits are deducted from your account.

Still Stuck?

Need Help?

Our team typically responds within 2 hours during business days.

Contact Support →