Errors
HTTP error codes, request failure states, and per-object failures in the Data API.
The Data API reports errors in three places:
| Where | When | How you see it |
|---|---|---|
| HTTP response | The request was rejected before it was accepted | A 4xx or 5xx status code with a JSON error body |
| Request status | An accepted request could not be processed | status: "failed" on the request, with an optional error_summary |
| Per-object result | One object in an accepted request could not be reviewed | A workflow.failed webhook, and output: null for that object in the request results |
Ingestion is asynchronous, so a 200 from POST /v1/data/{namespace} means the data was accepted, not that it was processed. Watch the request status or your webhooks for the outcome.
HTTP errors
Section titled “HTTP errors”Error response body
Section titled “Error response body”Error responses are JSON objects with a message. Validation errors also list the fields that failed:
{ "message": "invalid request body", "details": "data[1].id: Invalid input: expected string, received undefined", "issues": [ { "path": "data[1].id", "message": "Invalid input: expected string, received undefined" } ]}message: A short description of the error.issues: Present on validation errors. One entry per invalid field, with thepathof the field in the request body and amessagesaying what is wrong with it. In the example above, the second object indatahas noid.details: Present on validation errors. The same issues as a single line of text, for logging.
Branch on the HTTP status code. Messages are written for people and can change.
Status codes
Section titled “Status codes”| Status | Meaning | Retry? |
|---|---|---|
400 |
The request is invalid. See the messages below. | No. Fix the request. |
401 |
The Authorization header is missing. |
No. Send your API key. |
403 |
The API key or access token is invalid, expired, or not formatted as Bearer <api_key>. |
No. Check the key. |
404 |
The request ID or namespace was not found. | No. See Not found. |
409 |
A namespace settings update conflicts with the stored configuration. | Only after re-reading the settings. |
413 |
The request body is too large, or a request result is too large to return inline. | No. See Too large. |
429 |
You sent requests faster than your rate limit allows. | Yes, with exponential backoff. |
500 |
SafetyKit failed to handle the request. | Yes, with exponential backoff. |
502, 503, 504 |
SafetyKit was temporarily unavailable or the request timed out. | Yes, with exponential backoff. |
A 5xx or 429 on an ingest call means the data was not accepted. Send it again; reusing the same object id makes the retry safe because it updates the same object.
Invalid request (400)
Section titled “Invalid request (400)”message |
Returned by | Cause |
|---|---|---|
request body is required |
Add data, upload URL, settings | The request has no body. The upload URL endpoint needs at least {}. |
request body must be valid JSON |
Add data, upload URL, settings | The body could not be parsed as JSON. |
invalid request body |
Add data, upload URL, settings | The body does not match the expected shape. issues lists the failing fields. The most common cause is an object without a non-empty string id, or a missing data field. |
namespace is required |
All | The namespace is missing from the path. |
namespace and requestId are required |
Request status, download URL | The namespace or request ID is missing from the path. |
Authentication (401 and 403)
Section titled “Authentication (401 and 403)”Both are returned before your request reaches the Data API, so the body carries only a generic message.
401: NoAuthorizationheader was sent.403: A header was sent, but the key was rejected. Check that the value isBearer <api_key>, that the key belongs to the right environment, and that a short-lived access token has not expired.
Not found (404)
Section titled “Not found (404)”message |
Returned by | Cause |
|---|---|---|
Request not found |
Request status, download URL | The request ID does not exist in this namespace for your team. Check that the namespace in the path matches the one you ingested into. Requests are retained for 30 days. |
namespace not found |
Get namespace settings | The namespace has not been created yet. A namespace is created the first time you send data to it. |
Conflict (409)
Section titled “Conflict (409)”Returned only by PUT /v1/data/{namespace}/settings.
message |
Cause |
|---|---|
previous_version does not match the stored configuration version; GET the namespace settings and retry with the current version |
The settings changed since you read them. Fetch them again and reapply your change. |
namespace configuration is managed by SafetyKit; contact SafetyKit to change its schema or settings |
SafetyKit manages this namespace’s configuration, so it cannot be changed by the API. |
Too large (413)
Section titled “Too large (413)”- On
GET /v1/data/{namespace}/requests/{requestId}: the completed result is over the 5 MiB inline limit. The request itself succeeded. Use the download URL endpoint instead. - On
POST /v1/data/{namespace}: the request body is too large. Split it into smaller requests, or use an upload URL for large batches.
Rate limited (429)
Section titled “Rate limited (429)”Your team has a requests-per-second limit shared across SafetyKit API endpoints. When you exceed it, requests are rejected with 429 and are not processed. Retry with exponential backoff and jitter. For large backfills, use an upload URL rather than many individual requests. Contact support@safetykit.com if you need a higher limit.
Server errors (5xx)
Section titled “Server errors (5xx)”message |
Returned by | Cause |
|---|---|---|
failed to store request |
Add data | SafetyKit could not accept the data. Nothing was queued. Retry. |
failed to generate upload url |
Upload URL | SafetyKit could not create the upload URL. Retry. |
A message ending in Please contact us if this error persists. |
Request status, download URL | The stored request record or its output could not be read. Retry, and contact support with the request ID if it continues. |
Other 5xx responses carry a generic message. All of them are safe to retry.
Request failure states
Section titled “Request failure states”After a request is accepted, GET /v1/data/{namespace}/requests/{requestId} reports its status:
status |
Meaning | Terminal? |
|---|---|---|
queued |
Accepted and waiting to be processed. | No |
uploading |
An upload URL was issued and SafetyKit is waiting for the file. Upload URLs expire after 12 hours. | No |
ingesting |
Being processed, or paused while SafetyKit recovers from an internal failure. | No |
succeeded |
Processing finished. Individual objects may still have failed. | Yes |
failed |
The request could not be processed. | Yes |
Two behaviors are worth planning for:
- A
succeededrequest can contain failed objects. A failed object has"output": nullin the request results. Check each object rather than relying on the request status alone. - SafetyKit retries internal failures for you. If processing fails because of a problem on our side, the request stays in
ingestingwhile we recover it, rather than moving tofailed. You do not need to resubmit.
Requests recovering from an internal failure
Section titled “Requests recovering from an internal failure”A request in recovery looks the same as one still being processed: status is ingesting, data is empty, and there is no error_summary. A failure in one object holds the whole request in ingesting, including objects that already finished.
- Objects that finished before the failure may already have sent their
workflow.succeededwebhooks. - When the request is recovered, only the unfinished objects are processed again. You will not receive a second webhook for objects that already completed.
- The request then finishes as
succeededwith results for every object.
Nothing in the response tells you a request is in recovery, so alert on requests that stay in ingesting well past your normal processing time and contact support@safetykit.com with the request_id. Sending smaller requests limits how many results one failure can delay.
Failed requests
Section titled “Failed requests”A failed request has no output: data is empty, and the download URL endpoint returns null for data_url, data_count, and data_expires_at. Send the objects again in a new request.
Because internal failures are recovered by default, failed is rare. If you would rather have internal failures move the request to failed immediately, with a workflow.failed webhook for each affected object, so that your system can resubmit on its own schedule, contact support@safetykit.com to change this for a namespace.
Upload URL requests
Section titled “Upload URL requests”Requests created with an upload URL can also fail before processing starts:
- The
PUTtoupload_urlis rejected. Object storage returns403if the URL has expired or theContent-Typeheader is notapplication/json. Request a new upload URL and upload again. - The file cannot be parsed. The file is validated as a whole before any object is processed. One line that is not valid JSON, has no non-empty string
id, or has a value that does not match a number or datetime schema field stops the entire file. Nothing is ingested and the request does not move pastuploading.
If a request is still uploading several minutes after your PUT returned 200, treat the file as rejected. Check that it has one JSON object per line (not a JSON array or pretty-printed JSON), fix it, and upload it to a new upload URL.
Error summary
Section titled “Error summary”When error details are enabled for your namespace, terminal responses from the request status and download URL endpoints include an error_summary string describing what failed:
{ "namespace": "products", "request_id": "req_01h2m7qdmdjckc30e1mnq6xqfd", "status": "succeeded", "error_summary": "Some requests failed: 2 of 100 (2.0%). Sample failing ids: product_123, product_456. Failure categories: image_mirroring_error (2). Image mirroring error: The workflow could not fetch or mirror one or more image URLs. Please check that the image URLs are valid, public, and reachable, then retry the request.", "data": []}The summary reports how many objects failed, up to five sample IDs, and one or more failure categories:
| Category | Meaning | What to do |
|---|---|---|
image_mirroring_error |
SafetyKit could not fetch one or more media URLs. | Check that the URLs are valid, public, and reachable, then resubmit. |
input_error |
The submitted data failed validation or could not be prepared for review. | Fix the payload and resubmit. |
llm_error |
Model processing failed. | Resubmit. |
request_timeout |
Processing timed out or was throttled. | Resubmit. |
output_error |
The result could not be saved or indexed. | Resubmit. |
processing_error |
Processing failed for another reason, often an invalid value in the payload. | Check the payload, then resubmit. |
error_summary is written for people. Log it and show it to an operator, but do not parse it. It is off by default; contact support@safetykit.com to enable it for a namespace.
Per-object failures
Section titled “Per-object failures”When an object cannot be reviewed, SafetyKit sends a workflow.failed webhook for it instead of workflow.succeeded. The error field says why. See that page for the list of messages.
In the request results, a failed object has "output": null. This is different from an object with an empty labels array, which was reviewed and had no labels applied. The request results do not include the reason for a failure; that is only in the workflow.failed webhook.
Most per-object failures come from media that could not be downloaded. To avoid them, keep media URLs publicly retrievable at processing time, and make sure signed URLs do not expire before SafetyKit fetches them.
Not every media failure fails the object:
- If an object has several images and at least one downloads, the object is reviewed with the images that worked.
- If a video cannot be downloaded or decoded, the object fails.
- If a required media field has no usable media, the object fails.
To retry a failed object, send it again with the same id.
Handling errors in your integration
Section titled “Handling errors in your integration”- Retry
429and5xxresponses with exponential backoff. Do not retry other4xxresponses without changing the request. - Store the
requestIdfrom every ingest call. It identifies the request in status calls, webhooks, and support conversations. - Treat
succeededandfailedas the only terminal request statuses, and alert on requests that stay iningestingoruploadinglonger than you expect. - Handle
workflow.failedalongsideworkflow.succeeded, and check for"output": nullwhen reading request results. - Include the
request_idand objectidwhen contacting support@safetykit.com.