Errors and Limits
Every error Surface returns from the scan and account endpoints, what causes it, and whether to retry, fix the request, or change plans. The limits that produce those errors (file size, payload size, rate limits and the monthly allowance) are listed at the end.
Error responses#
Errors are JSON with an error message. Errors raised by the scan handlers also carry a requestId; errors raised before the request reaches a handler (authentication, permissions, rate limits, a blocked IP) do not. Every response, error or not, carries the request ID in the X-Request-ID header, so log that header if you need to match a failure to a scan.
Branch on the HTTP status. Within a status, read the extra fields described below. The only code value Surface sends is plan_required, on a 403 for a feature your plan does not include.
Retry, fix or upgrade#
| Status | Retry? | What to do |
|---|---|---|
| 400 | No | Fix the request |
| 401 | No | Fix the API key |
| 402 | No | Wait for your allowance to reset, or upgrade |
| 403 | No | Depends on the body: fix a role or profile, upgrade, or unblock an IP |
| 404 | No | Check the ID; the record may have aged out of retention |
| 413 | No | Send a smaller file, or scan it with the local scanner |
| 429 | Yes, after waiting | Slow down |
| 503 | Yes, after Retry-After |
Transient; the scanner is busy or restarting |
A 402, 413 or 429 is never a verdict. Do not treat a refused scan as clean.
400 Bad Request#
The request could not be scanned as sent.
error |
Endpoint | Cause |
|---|---|---|
No file uploaded |
POST /api/scan |
No multipart field named file |
File type "exe" is not allowed by scan profile "Default" |
POST /api/scan |
The profile does not accept this extension. The body also carries fileType, profile and allowedTypes. Use a key linked to a profile that accepts the type, or add it to the profile. Nothing was scanned and nothing was counted |
scan profile not found |
both scan endpoints | The profile_id you sent does not belong to this account |
invalid JSON body: … |
POST /api/scan/payload |
Malformed JSON |
payload field is required |
POST /api/scan/payload |
payload is missing or empty |
payload is not valid base64 |
POST /api/scan/payload |
"encoding": "base64" with a payload that does not decode |
payload decodes to empty content |
POST /api/scan/payload |
The base64 decoded to zero bytes |
invalid context: … |
POST /api/scan/payload |
A context field has the wrong type, or strictness is not relaxed, balanced or strict, or source is not user_prompt, content or tool_call |
Account endpoints also return 400 for an invalid request body, and no webhook URL configured for this profile when testing a profile without one.
401 Unauthorized#
{"error": "authentication required"} means the Authorization: Bearer <key> header is missing, the key is wrong or revoked, or the session has expired. Retrying the same key will not help.
402 Payment Required#
A usage limit stopped the scan before it ran.
error |
Cause | What to do |
|---|---|---|
monthly scan quota exceeded (100/100 scans used) |
The monthly scan allowance is spent. The numbers are your own usage and limit | Wait for the reset, or upgrade. See Usage and quotas |
async scanning is not included on the free plan |
You sent ?defer=true on a plan without async scanning (Free, Starter). The body also carries feature, current_plan and upgrade: true |
Drop ?defer=true, or upgrade to Standard or Pro |
In the SDKs, an exhausted allowance raises QuotaExceededError, and the async-scanning 402 raises PlanRequiredError. Both are on the SDKs' default branch; with a v0.3.0 pin, either 402 raises the base SurfaceError (check status_code == 402). A 429 is a rate limit and raises RateLimitError.
403 Forbidden#
Four different causes share this status. Tell them apart by the body:
| Body | Cause | What to do |
|---|---|---|
code: "plan_required", with feature, current_plan and upgrade: true |
The feature is not on your plan: webhooks, auto-block IP, blocked IPs, analytics, audit log, access control, data export or the local scanner. Creating a scan profile past your plan's allowance returns the same code with feature: "scan profiles" and a limit |
Upgrade, or stop using the feature |
error: "IP address is blocked", with reason and ip |
The address the request came from is on your account's block list | Unblock it: see IP blocking |
error: "permission denied: scans:write required" (or another resource and permission) |
The key's or user's role does not allow this action | Use a key with a role that does. See Access control |
error: "Payload scanning is not enabled for this scan profile. …" |
The profile linked to your key has payload scanning off | Turn it on in the profile, or use a key linked to one that has it |
Editing a built-in profile also returns 403: built-in profiles cannot be modified.
In the SDKs, a 403 with code: "plan_required" raises PlanRequiredError; every other 403 raises PermissionDeniedError (its parent class), whose message tells these cases apart. AuthenticationError is reserved for 401.
404 Not Found#
error |
Endpoint |
|---|---|
scan not found |
GET /api/scan/{scanId}, GET /api/account/history/{id} and its export |
profile not found |
Profile routes |
IP not found in block list |
DELETE /api/account/blocked-ips/{ip} |
A scan that has aged out of your plan's retention window is gone and returns 404.
413 Payload Too Large#
error |
Cause |
|---|---|
File exceeds maximum size (10 MB for your plan) |
The file is over the smaller of your plan's per-file cap and your scan profile's Max file size. The number shown is the limit that applied |
decoded payload exceeds size limit (10485760 bytes max) |
A payload over 10 MB after decoding |
This file is too large to scan on the hosted service. … |
The file is within your cap, but its scan would not fit the hosted scanner's memory. The message points to the local scanner, which has no per-file limit on paid plans |
None of these are counted against your allowance.
429 Too Many Requests#
Two limiters can answer 429, and they look different. See Rate limits for which applies where.
Scan rate limit (your plan's per-minute scan rate):
{
"error": "rate limit exceeded",
"plan": "free",
"limit_per_minute": 10,
"message": "Upgrade your plan for higher rate limits"
}
It carries no Retry-After. The allowance refills continuously, so one more request is admitted every 60 ÷ limit_per_minute seconds; wait at least that long before retrying.
API rate limit (account and history endpoints):
{
"error": "rate limit exceeded",
"retry_after": "60"
}
It is sent with a Retry-After: 60 header. Responses counted by this limiter also carry X-RateLimit-Limit and X-RateLimit-Remaining.
Feedback: POST /api/feedback is limited to 50 submissions a day per account (bursts of up to 10), and answers feedback rate limit exceeded, try again later.
503 Service Unavailable#
error |
Cause | What to do |
|---|---|---|
Server at capacity, try again shortly |
Every scan slot was busy for the whole of the request's time budget | Retry after the Retry-After header (5 seconds) |
Scan engine unavailable: … |
The scanner could not take the scan, most often because it is restarting | Retry after Retry-After (5 seconds) |
rate limiting service unavailable |
The rate limiter could not be reached, and Surface refuses requests rather than serve them unlimited | Retry shortly |
The SDKs retry 502, 503 and 504 for you within their timeout, waiting for Retry-After when it is present. A synchronous scan that fails this way is not counted against your allowance.
Limits#
Per-file size#
A file upload is limited to the smaller of two caps:
| Plan | Hosted per-file cap |
|---|---|
| Free | 10 MB |
| Starter | 15 MB |
| Standard | 20 MB |
| Pro | 25 MB |
and the Max file size on the scan profile that applies (100 MB on the built-in profiles). The hosted caps exist because a scan needs many times the file's size in memory. The scanner binary has no per-file cap on paid plans, so use it for larger files.
GET /api/account/usage returns your current cap as max_file_size_mb.
Payload size#
POST /api/scan/payload accepts up to 10 MB of decoded content on every plan. A base64 payload is measured after decoding.
Rate limits#
| Limiter | Applies to | Limit | Window |
|---|---|---|---|
| Scan rate | Authenticated POST /api/scan and POST /api/scan/payload |
Free 10, Starter 60, Standard 200, Pro 500 requests a minute | Continuous refill, with bursts of up to a full minute's allowance |
| API reads | Other GET requests under /api/ |
60 a minute | Fixed one-minute window |
| API writes | Other POST, PUT, PATCH and DELETE requests under /api/, including result reporting from the local scanner |
30 a minute | Fixed one-minute window |
Limits are per account. Authenticated scan requests count only toward the scan rate, not the API limits. Reads and writes are counted separately. Requests without valid credentials are counted per IP address against the API read and write limits, scan requests included. Accounts on manually billed plans have no scan rate limit.
Monthly scan allowance#
Each plan includes a number of hosted scans a month (see pricing). When it is spent, scan requests return 402 until the allowance resets. What counts, when it resets and how to check it are in Usage and quotas.
Time#
Each request has a 60-second budget for waiting on a free scan slot; past that it returns 503 Server at capacity. A scan the scanner has not answered within 120 seconds fails with 503 Scan engine unavailable. For files that take a long time, use deferred mode on Standard or Pro.
Related#
- Reading a scan result: what a successful response means
- Usage and quotas: how scans are counted and when allowances reset
- IP blocking: the 403 for a blocked address
- API reference: endpoints and request formats
- Pricing: scan allowances by plan
Tendrl