REST API: errors and conflicts
Errors are plain HTTP status codes with a JSON body. Application errors carry a stable, language-neutral code and its parameters, so scripts can react to the code and never have to parse a message:
{ "detail": { "code": "TOO_MANY_LOGIN_ATTEMPTS", "params": { "wait": 120 } } }| Status | Meaning | Typical cause and what to do |
|---|---|---|
400 | The request is not valid for the current state | A rule that is not allowed in that place, or a missing confirmation; the code names it |
401 | Not authenticated | Missing, expired or revoked token (NICHT_AUTHENTIFIZIERT); send Authorization: Bearer opx_… |
403 | Authenticated, but not allowed | The role lacks the permission (PERMISSION_MISSING, params.permission names it), or the token's scope does not cover the action (API_TOKEN_SCOPE_FORBIDDEN). The required permission of each endpoint is shown in the API reference |
404 | The object does not exist | Wrong id, or it was deleted meanwhile |
409 | Conflict | The object changed since you read it (see below), a name is already taken, or another operation on the same firewall is still open |
422 | The request body or a parameter is invalid | The body is a list of { "loc", "msg", "type" } entries that say where and why. Values you sent are never echoed back, so a secret does not end up in a log |
429 | Too many attempts | Too many failed logins (params.wait is the number of seconds to wait), or another operation of the same kind is already running |
502 | A firewall could not do it | The firewall did not answer, or it rejected the call (UPSTREAM_REJECTED, params.reason has the reason). Check the firewall and retry |
503 | A part of OPNexus is not available | For example the updater container for one-click updates is not running (UPDATER_UNAVAILABLE) |
Conflicts on edit. Objects that people edit concurrently (for example rules, port forwards, VPN tunnels) carry an updated_at timestamp. An update must send it back as expected_updated_at. If the object changed in between, OPNexus answers 409 instead of silently overwriting the other change. Read the object again, apply your change to the fresh state and resend.
Codes are stable, texts are not. The web interface translates each code into the user's language. In scripts, test the code, not text, and treat unknown codes like any other error of the same status.