Skip to main content

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​

ParameterTypeDescription
idStringThe 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.

FieldTypeRequiredDescription
parentCompanyStringNoID of the parent company. It must match the current parent company.
nameStringNoName of the corporate.
activeBooleanNoWhether the corporate is active. false stops the parent company's users acting in every sub-company and every level below them.
subCompaniesArrayNoIDs of all sub-companies. Replaces the current list.
corporateLinkAccessArrayNoAccess settings for individual sub-companies. See below.
FieldTypeRequiredDescription
companyIdStringYesID of a sub-company of this corporate. List each sub-company only once.
allAccessBooleanNotrue gives the parent company's users full access in this sub-company.
accessListArrayNoPermissions 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 }, with status instead of success.

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​

FieldTypeDescription
successBooleanWhether the request succeeded.
messageStringResult message.
dataObjectThe corporate. See below.

Corporate Data​

FieldTypeDescription
idStringUnique identifier of the corporate.
nameStringName of the corporate.
skippedSubCompaniesArrayIDs 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 parentCompany returns 400 with The parent company of a corporate can't be changed.
  • Sub-companies that are not in subCompanies are removed from the corporate. Leave out subCompanies to 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 subCompanies array keeps the corporate, with no sub-companies. Only Delete Corporate removes it.
  • Sub-companies already in the corporate that have no corporateLinkAccess entry 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.