Errors and limits

Error responses

The public API (/api/v1) answers errors with an HTTP status and a JSON body. error is a stable code for your program; message explains it for people and can change.

curl https://api.spamapi.de/api/v1/check \
  -H "X-API-Key: $SPAMAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{"blog": "https://example.com"}'
{
  "error": "validation_error",
  "message": "user IP is required"
}

Every response has an X-Request-ID header. Include it when you contact support. You can send your own X-Request-ID, up to 128 printable ASCII characters without spaces, to match SpamAPI's logs with yours; it isn't an idempotency key. Check responses also carry the ID in request_id.

An error never contains a spam decision. Don't treat an error as allow.

Error codes

Status error Endpoints Meaning and what to do
400 invalid_json POST endpoints The body isn't valid JSON. Fix the request.
400 validation_error check, submit-spam, submit-ham A field is missing or invalid; message names it. blog and user_ip are required, and user_ip must be an IPv4 or IPv6 address. Fix the request.
400 missing_api_key verify-key The body has no api_key.
400 invalid_request check, submit-spam, submit-ham The request couldn't be read. Fix the request.
401 missing_api_key Endpoints with an API key The X-API-Key header is missing.
401 invalid_api_key Endpoints with an API key The key is unknown, revoked or malformed, or an api_key in the body differs from the header. Check the key in the dashboard.
403 account_unavailable check, usage The account can't use the API. Contact support.
403 contribution_denied check installation_id isn't registered for this blog. Omit installation_id unless you use the WordPress plugin.
429 rate_limit_exceeded All except pricing Too many requests in a minute. Wait the number of seconds in Retry-After.
429 usage_limit_exceeded check This month's checks are used up. Wait until resets_at from GET /api/v1/usage, or upgrade your plan.
500 detection_error check The check failed and wasn't counted. Retry later.
500 server_error, feedback_error, usage_error, sites_error verify-key, submit-spam, submit-ham, sites SpamAPI couldn't complete the request. Retry later.
500 internal_server_error All An unexpected failure. The body also contains request_id. Retry later.
503 detection_unavailable check Classification is temporarily unavailable or timed out. The check isn't counted. Hold the submission and retry later.
503 quota_unavailable check, verify-key, usage SpamAPI couldn't read or record usage. Retry later.
503 pricing_unavailable pricing Prices can't be read right now.

Request bodies over 2 MiB are rejected. Codes beginning with contribution_ from the shared-model endpoints are described in the OpenAPI specification.

A retry is a new request. If a check's response was lost, the retry can use a second check. Retry 5xx and 429 responses with a growing delay, not in a tight loop.

Rate limits

Endpoints Limit
Endpoints with an API key 100 requests a minute per account, shared by all its keys
POST /api/v1/verify-key 10 requests a minute per IP address, including dashboard sign-ins from that address
GET /api/v1/pricing No rate limit

Responses carry the limit's state:

  • X-RateLimit-Limit: requests allowed in the window.
  • X-RateLimit-Remaining: requests left in the window.
  • X-RateLimit-Reset: end of the window as a Unix timestamp.

When the limit is reached, the response is 429 rate_limit_exceeded with a Retry-After header in seconds:

{
  "error": "rate_limit_exceeded",
  "message": "Too many requests"
}

Monthly checks

Each plan includes a number of checks per month: 100 on Free; see plans and prices for the others. All API keys of an account share them.

  • Each successful POST /api/v1/check counts toward the UTC calendar month in which it was made, independent of billing dates.
  • Test values, feedback reports and usage queries don't count. Neither do checks that return an error, except when SpamAPI couldn't confirm whether it recorded the check (503 quota_unavailable); such a check may count.
  • Check responses carry X-Usage-Limit, X-Usage-Used and X-Usage-Remaining headers. GET /api/v1/usage returns the same numbers and when they reset.
  • Once the checks are used up, checks get 429 usage_limit_exceeded until the next month or until you upgrade. Nothing extra is billed.
{
  "error": "usage_limit_exceeded",
  "message": "Monthly API usage limit exceeded"
}

Follow your usage on the dashboard's usage page.