Errors
Formats
| Service | Format |
|---|---|
| Customers, Insights | { "error": "entity/not-found" } |
| Customers, Insights (validation) | { "errors": [{ "message": "…", "path": "name" }] } |
| Auth | Plain text body, e.g. oauth/invalid-client |
Customers 401 | Empty body |
Error codes follow scope/problem. The complete list, grouped by area, is on the SDK error reference.
Status codes
| Status | Typical reason |
|---|---|
| 400 | Validation, unknown id, invalid argument |
| 401 | No token, expired token, wrong token type |
| 403 | Token valid but not allowed (source scope, grant not allowed) |
| 404 | Unknown document or route |
| 429 | Too many token requests |
| 500 | Server error. Retry idempotent calls |
Handling
- JavaScript
- Python
- R
const call = async (url, options) => {
const response = await fetch(url, options)
const text = await response.text()
const body = text ? JSON.parse(text) : undefined
if (response.ok) return body
throw Object.assign(new Error(body?.error ?? `HTTP ${response.status}`), { status: response.status, body })
}
import requests
class ScenidError(Exception):
def __init__(self, status, body):
super().__init__(body.get("error") if isinstance(body, dict) else f"HTTP {status}")
self.status = status
self.body = body
def call(method, url, **kwargs):
response = requests.request(method, url, **kwargs)
try:
body = response.json() if response.text else None
except ValueError:
body = response.text # the auth service answers with plain text
if response.ok:
return body
raise ScenidError(response.status_code, body)
library(httr2)
call <- function(req) {
response <- req |>
req_error(is_error = \(r) FALSE) |>
req_perform()
body <- resp_body_string(response)
parsed <- tryCatch(jsonlite::fromJSON(body, simplifyVector = FALSE), error = \(e) body)
if (resp_status(response) >= 400) {
message <- if (is.list(parsed) && !is.null(parsed$error)) parsed$error else paste("HTTP", resp_status(response))
stop(message, call. = FALSE)
}
parsed
}
Note: the auth service answers with plain text. Parse defensively.