Unregister request for a non-existent device returns "not authorized" code

I'm working on functionality that unregisters an ecobee device through the API when it's deleted from our software. We use a utility account and send an unregister request to ecobee (/hierarchy/thermostat with "operation":"unregister").

If the device is in ecobee, the operation completes successfully (status 0) and the device is deleted. However, if the device is not in ecobee - e.g. deleted from the utility portal - I get a "not authorized" error response (status 2).

I expected an error in this situation, but "not authorized" seems...misleading.

Status code 2 is described in documentation as "Not Authorized: Attempted to access resources which user is not authorized for. Ensure the thermostat identifiers requested are correct."

But it's not a matter of authorization, the device simply isn't present to be unregistered.

1. Is this intended behavior?
2. If so, is there any way for me to differentiate between a status 2 for missing device, vs. a status 2 for lack of authorization?
3. Is there any available documentation of possible status codes returned by each API endpoint, and their causes? I've been using https://www.ecobee.com/home/developer..., which lists the possible status codes, but lacks details on where they might occur.
1 person has
this question
  • ScottF (Official Rep) May 19, 2015 12:45
    Hi Samuel,
    To answer your questions:
    1. Yes, this is the intended behavior. Your device is no longer in the node hierarchy, so therefore access is not authorized.
    2. The error code will be the same, as you mention, however the error message should be different.
    3. Right now the API documentation describes the possible error codes, which I'm sure you seen, here: https://www.ecobee.com/home/developer...

    There is no further documentation available on the subject at this point in time.

    Hope this helps,
  • (some HTML allowed)
    How does this make you feel?
    Add Image

    e.g. kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned sad, anxious, confused, frustrated