Error Codes
The Sporeline API error format, every status code it returns, and which errors are safe to retry.
developerError Codes
When a request fails, the Sporeline API returns an HTTP error status and a JSON body in a standard shape. This page covers that shape, the status codes, and how to handle each one.
The Error Envelope
{
"error": {
"code": "BAD_REQUEST",
"message": "weight_g must be >= 0.01",
"retry": false,
"request_id": "2f1c7d6e-4b0a-4f8e-9d1a-3c5b7e9f0a12",
"field_errors": [
{
"field": "weight_g",
"issue": "below_minimum",
"expected": ">= 0.01",
"received": "0"
}
]
}
}
| Field | Present | Meaning |
|---|---|---|
code | Always | A machine-readable error code. See the tables below |
message | Always | A human-readable explanation |
retry | Always | true if the same request may succeed later. false if you need to change the request first |
request_id | Most errors | The ID of this request. Include it when you contact support |
field_errors | Some 400 errors | One entry per invalid field, with the field, the issue, and where available what was expected and received |
required_plan | 402 only | The plan that allows the action |
Every response also carries the request ID in the x-amzn-RequestId header, including errors whose body has no request_id.
Successful responses wrap their result in a data object instead: { "data": ... }.
Status Codes
| Status | code | retry | When it happens |
|---|---|---|---|
400 | BAD_REQUEST | false | The request is invalid: a missing or malformed field, a value out of range, a bad next_token, an action the record’s current state doesn’t allow, or a method the endpoint doesn’t support |
401 | SESSION_EXPIRED | false | The credentials are missing or weren’t accepted. See Authentication |
402 | UPGRADE_REQUIRED | false | The action would go over a limit of your plan, such as the number of active blocks |
403 | FORBIDDEN | false | Your role isn’t allowed to do this. API keys run with the Manager role |
404 | NOT_FOUND | false | The record doesn’t exist in your account, or the path or method doesn’t exist |
409 | CONFLICT | Usually false | The request conflicts with the record’s current state, for example editing a delivery that’s already been delivered. When retry is true, the conflict should clear on its own |
429 | n/a | n/a | Too many requests. Retry with backoff. This comes from the gateway, so don’t rely on the body. See Rate Limits |
500 | INTERNAL_ERROR | true | Something went wrong on our side. The message is always generic |
501 | NOT_IMPLEMENTED | false | The endpoint exists but this operation isn’t available yet |
502 | SERVICE_UNAVAILABLE | true | A service Sporeline depends on failed. Try again shortly |
503 | SERVICE_UNAVAILABLE | false | The feature is switched off for now |
Other 5xx | SERVICE_UNAVAILABLE | true | The request timed out or a backend was unavailable |
Other Codes
Team and invitation endpoints use more specific codes:
code | Status | Meaning |
|---|---|---|
ROLE_NOT_ALLOWED | 403 | You can’t assign, change or remove that role |
SELF_ROLE_CHANGE | 403 | You can’t change your own role |
SEAT_LIMIT_EXCEEDED | 409 | Your plan has no free seats |
EMAIL_ALREADY_MEMBER | 409 | That email already belongs to a team member |
INVITE_ALREADY_PENDING | 409 | That email already has a pending invitation |
Errors from the Gateway
Some errors are returned before a request reaches Sporeline:
401for missing or rejected credentials403when the firewall blocks an address that’s over the per-address limit404for a path or method that doesn’t exist429when the API throttle is exceeded- Other
5xxerrors when a request times out
These responses have no request_id in the body. For 429 and firewall 403 responses, don’t rely on the body at all. Check the HTTP status code.
Handling Errors
- Branch on the HTTP status code first, then on
codefor detail. - If
retryistrue, retry with exponential backoff, for example after 1, 2, 4 and 8 seconds. - If
retryisfalse, fix the request before sending it again. For400errors,field_errorssays which fields to fix. - Be careful retrying a create. If a
POSTtimes out, the record may have been created anyway. Check before sending it again, or you may end up with a duplicate. - Log the request ID. If you need help, email support@sporeline.com with the request ID and the time of the request.
Related Pages
- Authentication: API keys and the
Authorizationheader - Rate Limits: request limits and how to stay under them
- API Reference: base URL, response format and endpoints