Organization APIs
In Zoho Directory, your company is represented as an Organization. Each organization is assigned with a unique identifier (Organization ID). You will be using it while making API calls to access your organization-specific data and resources. You can retrieve all organizations associated with your user account, along with their details, by using your user ID. You can find this ID on your profile pane inside the Zoho Directory application. Your Organization's Information will be available under Organization > Organization Info in Zoho Directory.
Get all orgs of a user
Fetches the list of all the organizations to which the user belongs.
OAuth Scope : ZohoDirectory.Orgs.READ
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://zohoapis.com/directory/api/v2/orgs")
.get()
.addHeader("Authorization", "Zoho-oauthtoken 1000.41d9xxxxxxxxxxxxxxxxxxxxxxxxc2d1.8fccxxxxxxxxxxxxxxxxxxxxxxxx125f")
.build();
Response response = client.newCall(request).execute();
headers_data = Map();
headers_data.put("Authorization", "Zoho-oauthtoken 1000.41d9xxxxxxxxxxxxxxxxxxxxxxxxc2d1.8fccxxxxxxxxxxxxxxxxxxxxxxxx125f");
response = invokeUrl
[
url: "https://zohoapis.com/directory/api/v2/orgs"
type: GET
headers: headers_data
connection: <connection_name>
];
info response;
const http = require("https");
const options = {
"method": "GET",
"hostname": "zohoapis.com",
"port": null,
"path": "/directory/api/v2/orgs",
"headers": {
"Authorization": "Zoho-oauthtoken 1000.41d9xxxxxxxxxxxxxxxxxxxxxxxxc2d1.8fccxxxxxxxxxxxxxxxxxxxxxxxx125f"
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
import http.client
conn = http.client.HTTPSConnection("zohoapis.com")
headers = { 'Authorization': "Zoho-oauthtoken 1000.41d9xxxxxxxxxxxxxxxxxxxxxxxxc2d1.8fccxxxxxxxxxxxxxxxxxxxxxxxx125f" }
conn.request("GET", "/directory/api/v2/orgs", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request GET \
--url https://zohoapis.com/directory/api/v2/orgs \
--header 'Authorization: Zoho-oauthtoken 1000.41d9xxxxxxxxxxxxxxxxxxxxxxxxc2d1.8fccxxxxxxxxxxxxxxxxxxxxxxxx125f'
{
"status_code": 200,
"resource_name": "orgs",
"orgs": [
{
"created_time": "2024-xx-14T14:57:42.617+0530",
"is_active": true,
"org_id": 1,
"owner_id": "2xxxxxxxxxxxxxxxx6",
"display_name": "Zylker"
},
{...},
{...}
]
}
{
"status_code": 401,
"error_code": "INVALID_TOKEN",
"message": "Authentication required."
}
{
"status_code": 403,
"error_code": "ACCESS_DENIED",
"message": "You do not have permission to perform this action."
}
Get specific organization's details
Fetches the details of the specific organization using the given org_id. The organization ID, display name, owner ID, account type, organization created date/time and also the status of the user in the organization will be listed.
OAuth Scope : ZohoDirectory.Orgs.READ
Path Parameters
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://zohoapis.com/directory/api/v2/orgs/1")
.get()
.addHeader("Authorization", "Zoho-oauthtoken 1000.41d9xxxxxxxxxxxxxxxxxxxxxxxxc2d1.8fccxxxxxxxxxxxxxxxxxxxxxxxx125f")
.build();
Response response = client.newCall(request).execute();
headers_data = Map();
headers_data.put("Authorization", "Zoho-oauthtoken 1000.41d9xxxxxxxxxxxxxxxxxxxxxxxxc2d1.8fccxxxxxxxxxxxxxxxxxxxxxxxx125f");
response = invokeUrl
[
url: "https://zohoapis.com/directory/api/v2/orgs/1"
type: GET
headers: headers_data
connection: <connection_name>
];
info response;
const http = require("https");
const options = {
"method": "GET",
"hostname": "zohoapis.com",
"port": null,
"path": "/directory/api/v2/orgs/1",
"headers": {
"Authorization": "Zoho-oauthtoken 1000.41d9xxxxxxxxxxxxxxxxxxxxxxxxc2d1.8fccxxxxxxxxxxxxxxxxxxxxxxxx125f"
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
import http.client
conn = http.client.HTTPSConnection("zohoapis.com")
headers = { 'Authorization': "Zoho-oauthtoken 1000.41d9xxxxxxxxxxxxxxxxxxxxxxxxc2d1.8fccxxxxxxxxxxxxxxxxxxxxxxxx125f" }
conn.request("GET", "/directory/api/v2/orgs/1", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
curl --request GET \
--url https://zohoapis.com/directory/api/v2/orgs/1 \
--header 'Authorization: Zoho-oauthtoken 1000.41d9xxxxxxxxxxxxxxxxxxxxxxxxc2d1.8fccxxxxxxxxxxxxxxxxxxxxxxxx125f'
{
"status_code": 200,
"resource_name": "orgs",
"orgs": {
"created_time": "2024-xx-14T14:57:42.617+0530",
"is_active": true,
"org_id": 1,
"owner_id": "2xxxxxxxxxxxxxxxx6",
"display_name": "Zylker"
}
}
{
"status_code": 401,
"error_code": "INVALID_TOKEN",
"message": "Authentication required."
}
{
"status_code": 403,
"error_code": "ACCESS_DENIED",
"message": "You do not have permission to perform this action."
}
{
"status_code": 404,
"error_code": "RESOURCE_NOT_FOUND",
"message": "The requested resource was not found."
}