Getting started with the REST API¶
Check your first comment or form submission in a few minutes: create a free account and an API key, then send a request from the command line. Using WordPress? Follow the WordPress setup instead; it uses the same account and key.
API requests go to https://api.spamapi.de. Your account, keys and usage are in
the dashboard.
Create a free account¶
Create a free account with a username, email address and password. SpamAPI emails you a verification token; open the link in the email, or paste the token on the verification page. You then land on the dashboard's API keys page. The Free plan includes 100 checks a month and needs no payment details.
Create an API key¶
- Open API keys in the dashboard.
- Enter a name you will recognize, such as the site or app that will use the key, and select Create key.
- Copy the key, which starts with
spa_, and store it somewhere safe. The dashboard shows it only this once. - Check I saved this key and close the dialog.
Keep the key on your server and send it in the X-API-Key header. Never put it
in code that runs in a visitor's browser. If a key is lost or exposed, revoke it
on the API keys page and create a new one. Stripe keys (sk_live_…, sk_test_…)
are not SpamAPI keys.
All keys of an account share its monthly checks. For the commands below, store the key in an environment variable:
export SPAMAPI_KEY='spa_...'
Check that the key works¶
curl https://api.spamapi.de/api/v1/usage \
-H "X-API-Key: $SPAMAPI_KEY"
A working key returns this month's checks. This request doesn't use one.
{
"reserved": 0,
"remaining": 100,
"limit": 100,
"used": 0,
"percentage": "0.00",
"resets_at": "2026-12-01T00:00:00Z",
"throttled": false
}
HTTP 401 with invalid_api_key means the key is mistyped, revoked, or not a
SpamAPI key; missing_api_key means the header is missing.
Check a submission¶
Send each comment or form submission to POST /api/v1/check before you publish,
store or forward it. Only blog, your site's URL, and user_ip, the visitor's
IP address, are required. Add the text, author details and user agent you have;
the API reference lists every field.
curl https://api.spamapi.de/api/v1/check \
-H "X-API-Key: $SPAMAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"blog": "https://example.com",
"user_ip": "203.0.113.10",
"user_agent": "Mozilla/5.0 (X11; Linux x86_64)",
"comment_type": "comment",
"comment_author": "Watch Deals",
"comment_author_email": "deals@example.net",
"comment_content": "Cheap replica watches, order now!"
}'
The response classifies the submission:
{
"is_spam": true,
"score": 0.594,
"recommendation": "review",
"request_id": "0f6c2a7e-5d1b-4c39-9e8a-2b7d4f1c6a90",
"prediction_ref": "5b0e8f3c-9a4d-4e21-8c67-1d2f3a4b5c6d"
}
Your score can differ. The response can also contain optional fields such as
reasons, short notes about the result for your logs; ignore fields you don't
use. Each successful check uses one of your monthly checks.
| Field | Meaning |
|---|---|
is_spam |
true if SpamAPI considers the submission spam. |
score |
From 0 (ham) to 1 (spam). |
recommendation |
allow, review or discard; see below. |
request_id |
Identifies the request. Include it when you contact support. |
prediction_ref |
Reference to the stored check. |
Act on the result¶
Your code decides what happens. SpamAPI doesn't publish or delete anything.
recommendation |
Suggested action |
|---|---|
allow |
Publish or deliver the submission as usual. |
review |
Hold it for a person to check. |
discard |
Reject it or move it to spam. |
Scores are estimates and some results will be wrong, so keep a way to review held submissions. When the API can't make a decision, it returns an error instead of a result:
503detection_unavailable: classification is temporarily unavailable. The check isn't counted. Hold the submission and retry later, or let a person review it; don't treat the error asallow.429usage_limit_exceeded: this month's checks are used up. Checks resume when the quota resets (resets_at) or after you upgrade.429rate_limit_exceeded: too many requests in a minute. Wait for the number of seconds in theRetry-Afterheader.
Errors and limits lists every error code and what to do.
Report mistakes¶
If a result was wrong, send the same fields to POST /api/v1/submit-spam for
spam that got through, or to POST /api/v1/submit-ham for legitimate content
that was flagged:
curl https://api.spamapi.de/api/v1/submit-ham \
-H "X-API-Key: $SPAMAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"blog": "https://example.com",
"user_ip": "198.51.100.7",
"comment_author": "Jane Doe",
"comment_author_email": "jane@example.com",
"comment_content": "Could you send me a quote for a new roof?"
}'
{"status": "ok"}
Reports don't use checks. The dashboard's usage page counts them.
Before you go live¶
- Test your integration with test mode values, which skip classification and don't use checks.
- Follow your monthly checks in the dashboard
or with
GET /api/v1/usage, and compare plans if you need more. - Start from an example in Go, JavaScript, PHP or Python.
- Keep troubleshooting at hand.