Errors
Every error response has the same JSON body, so a client can handle errors in one place.
The error object
{"error": "not_found", "message": "no such device"}
errorA stable code. Programs act on it.
messageAn explanation for people. It never quotes tokens, keys or values sent by the client. Do not parse it: the text may change.
acr_valuesOnly with
insufficient_user_authentication: theacrthe action needs.
Codes
|
Status |
Meaning |
|---|---|---|
|
400 |
Malformed request: syntax, a missing field, a wrong parameter or
cursor, a missing |
|
401 |
Missing, expired or wrong credential |
|
401 |
The action needs a second factor (see Authentication) |
|
403 |
No permission, or not a member of |
|
404 |
Unknown, or not visible to the active organization |
|
409 |
Conflicts with the current state, for example a name that exists |
|
422 |
A value does not fit the data dictionary or a field definition |
|
429 |
Too many commands that are not final for the device |
|
429 |
Too many requests; wait |
|
500 |
Server error; retry later |
Order of the checks
Findy IoT Core checks a request in this order and answers with the first check that fails, so the response tells nothing beyond what the caller may know:
authentication → 401
unauthorized;X-Org: membership, or the organization of the key → 403forbidden;the second factor of the active organization → 401
insufficient_user_authentication;the permission of the operation → 403
forbidden;the visibility of the resource (device, command, filter, key, organization, member, role, invite, relation) → 404
not_found;the checks of the operation itself, for example the checks of a command (see Devices, data and commands).
How to handle errors
400, 404 and 422: fix the request.
409: read the current state first, for example run the preview of a bulk action again.
401: get a new credential; for
insufficient_user_authenticationsign in again with a second factor.403: the key or role lacks the permission named in
x-permissionof the operation.429: wait
Retry-Afterseconds, or fortoo_many_pendinguntil a command of the device is final.500: retry later.
Example
A device that does not exist, or that your organization cannot see:
curl -i -H "Authorization: Bearer <your API key>" \
https://console.example.com/api/v1/devices/123456789012347
HTTP/1.1 404 Not Found
Content-Type: application/json
Cache-Control: no-store
{"error": "not_found", "message": "no such device"}