Flowdock: REST API - How can I find the sub-organizations of a given organization?

Document ID : KB000098903
Last Modified Date : 31/05/2018
Show Technical Document Details
Is there a way to use Flowdock's REST API to find the sub-organizations of a given organization?
The short answer to this is: "No. The REST API itself does not provide a mean to find the sub-organizations".

But ...  we do have a way.

Let's start by finding our organization using Flowdock's REST API:

This is a call that finds an organization with an id of "ABC":
User-added image

This will return:
User-added image

You can see the returned JSON of our ABC organization. As you can tell there is no section for sub-organizations. This is why there isn't a straight forward way to get the sub-organizations. 

Yet, note that there is a property named: parent_organization_id . In this case it is set to 'null' . This means our "ABC" organization is not parented by any other organization.

This suggests we may be able to use this property to query for the sub-organizations in such a way:
User-added image
The above query basically is attempting to find all organizations that have a parent_organizations_id set to 'ABC'.
The problem with this though, is that the /find method does not support query by this argument parent_organizations_id . If you try this out you'll result with: "Access Denied".

Yet, there is a way to find the sub-organizations. Here is how:

We need to make a call to /organizations :
User-added image

This will return all organizations authorized under the Token used in this query. This returns blocks of JSON sections such as above for all organizations. At that point you can use a simple program, locate all the lines where "parent_organization_id": ABC
These will be the lines that are part of all the sub-organizations you are looking for.
Additional Information:
More on Flowdock's REST API: https://www.flowdock.com/api/rest
More on Flowdock's REST API for Organization: https://www.flowdock.com/api/organizations