Update Corporate
Updates an existing corporate. You can rename it, activate or deactivate it, change its sub-companies, and change what the parent company's users can do in each sub-company.
For the rules that apply across all corporate endpoints, see Corporate Hierarchy and Access.
HTTP Request
- URL:
/corporates/{id} - Method:
PUT - Headers:
accessToken: Required. Your API access token.Content-Type:application/json
- Required scope:
READ_WRITE_COMPANY
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | String | The ID of the corporate (not the parent company ID). Required. |
Request Body
Send a JSON object with the fields to update. All fields are optional.
| Field | Type | Required | Description |
|---|---|---|---|
parentCompany | String | No | ID of the parent company. It must match the current parent company. |
name | String | No | Name of the corporate. |
active | Boolean | No | Whether the corporate is active. false stops the parent company's users acting in every sub-company and every level below them. |
subCompanies | Array | No | IDs of all sub-companies. Replaces the current list. |
corporateLinkAccess | Array | No | Access settings for individual sub-companies. See below. |
Corporate Link Access Object
| Field | Type | Required | Description |
|---|---|---|---|
companyId | String | Yes | ID of a sub-company of this corporate. List each sub-company only once. |
allAccess | Boolean | No | true gives the parent company's users full access in this sub-company. |
accessList | Array | No | Permissions the parent company's users have in this sub-company, for example ORDERS, CREATE_ORDERS. |
allAccess, accessList and the rules for companyId work as described in Create Corporate. An empty accessList with allAccess omitted or false leaves the parent company's users with no access in that sub-company.
cURL Example
curl --location --request PUT '<BASE_URL>/corporates/67bd786f177125410d15d694' \
--header 'accessToken: <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"name": "Keystone Holdings Group",
"corporateLinkAccess": [
{
"companyId": "64f72a721e63ec3bf06acd65",
"accessList": ["ORDERS", "CREATE_ORDERS"]
}
]
}'
Response
- 200 OK: The corporate was updated successfully.
- 400 Bad Request: A field is not valid, the parent company was changed, a sub-company cannot be linked, or a permission is not recognised. Hierarchy errors include a
code. See Error Codes. - 401 Unauthorized: The access token is missing or invalid.
- 403 Forbidden: The access token does not have the required scope.
- 404 Not Found: No corporate matches the ID. The body is
{ "status": false, "message": "Corporate not found", "data": null }, withstatusinstead ofsuccess.
Unlike the Get endpoints, this endpoint returns 401, 403 and 404 as their own status codes.
Sample JSON Response
{
"success": true,
"message": "Corporate updated successfully",
"data": {
"id": "67bd786f177125410d15d694",
"name": "Keystone Holdings Group"
}
}
Response Details
| Field | Type | Description |
|---|---|---|
success | Boolean | Whether the request succeeded. |
message | String | Result message. |
data | Object | The corporate. See below. |
Corporate Data
| Field | Type | Description |
|---|---|---|
id | String | Unique identifier of the corporate. |
name | String | Name of the corporate. |
skippedSubCompanies | Array | IDs from subCompanies that were skipped because no company matches them. Only present when needed. |
When an ID in subCompanies does not match a company, the request still succeeds and links the IDs that exist:
{
"success": true,
"message": "Corporate updated successfully",
"data": {
"id": "67bd786f177125410d15d694",
"name": "Keystone Holdings Group",
"skippedSubCompanies": ["64f72a721e63ec3bf06acd99"]
}
}
A link that is rejected, such as one that would create a cycle or make the chain too deep, is not skipped. It fails the whole request.
Notes
- The parent company of a corporate cannot be changed. Sending a different
parentCompanyreturns400withThe parent company of a corporate can't be changed. - Sub-companies that are not in
subCompaniesare removed from the corporate. Leave outsubCompaniesto keep the current list. - A removed link and its access settings, including per-user access, are deleted. If the company has no other parent, it becomes a standalone company.
- Sending an empty
subCompaniesarray keeps the corporate, with no sub-companies. Only Delete Corporate removes it. - Sub-companies already in the corporate that have no
corporateLinkAccessentry keep their current access. A sub-company you add in this call without an entry gets full access. - A company can belong to more than one parent company. A chain can have at most 5 links, so up to 6 companies from the top company to the lowest sub-company. A company cannot be added below one of its own sub-companies.
- The request is all-or-nothing. If any link is rejected, nothing is changed.
- See Corporate Hierarchy and Access for the full rules.