GET /organizations
Request parameters
Parameter | Type | Description |
---|---|---|
organizationId | string | If provided then this specific organization will be returned and all of its first level sub-organizations (children) as well. If not provided then all companies which authenticated user is allowed to see will be retrieved. If id is provided which authenticated user is not allowed to see, then 401 code will be returned. Note: A company is always the head of the organization. |
organizationName | string | If provided a search for an organization containing this name will be performed and only organizations which match the search will be returned. If not provided all organizations within all organization units will be retrieved which authenticated user is allowed to see. If provided together with organizationId then organizationName will be searched only within the organizationId and all of its sub-organizations (children). Organizations will only be listed which authenticated user is allowed to see, otherwise 401 code will be returned. |
inactive | boolean | If "true" is provided only inactive organizations will be returned. If "false" or nothing is provided only active organizations will be returned. Note: An organization is inactive if the validTo date is in past. |
types | array [string] | If provided only organization with this specific type(s) will be returned. Possible query parameters: "project", "subsidiary", "partner", "client", "supplier", "branch", "other" |
page | integer (default 1) | Decide which page should be returned. Note: Maximum of 50 organizations will be returned per page. |
Request example:
https://mctime.com/api/v2/auth/organizations
//All companies which authenticated user is allowed to see will be returned.
//A company is always the head of the organization.
https://mctime.com/api/v2/auth/organizations?organizationId=123
//Organization with id "123" and all of its sub-organizations (children) will be returned if authenticated user is allowed to see them.
https://mctime.com/api/v2/auth/organizations?organizationName=test
//All organizatiosn which authenticated user is allowed to see and which have "test" in the organizations name will be returned.
https://mctime.com/api/v2/auth/organizations?organizationId=123&organizationName=test
//All organizatiosn which authenticated user is allowed to see AND which are saved within the organization with ID "123" AND which have "test" in the organizations name will be returned.
Responses
Code | Title | Description |
---|---|---|
200 | Success | Returned if request was successful. |
400 | Bad Request | Returned if request was bad. |
401 | Unauthorized | Returned if request was not authorized (eg. due to bad API key). |
404 | Not Found | Returned if request could not be found. |
Users permissions will be considered
The response will consider the permissions of the user who is authenticated by the API call and will only return organizations which user is allowed to see.
Response JSON example:
{
"items": [
{
"message": "Success",
"data": {
"organizations": [
{
"id": "12345678-abcd-9876-5432-10abcdefghij",
"locationTracking": false,
"organizationName": "Project ABC",
"type": "project"
},
{
"id": "87654321-dcba-6789-2345-98klmnopqrst",
"locationTracking": false,
"organizationName": "Client 123",
"type": "client"
}
],
"page": "1", //currently returned page
"pageSize": "15" //total number of pages
}
}
],
"valid": true
}