Update Company
Updates an existing company. Only the fields you send are changed. You can identify the company by its ID or by its email address.
HTTP Request
- URL:
/companies/{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 or the email address of the company. Required. |
Request Body
Send a JSON object with the fields to update. All fields are optional, but the body cannot be empty.
| Field | Type | Required | Description |
|---|---|---|---|
name | String | No | Name of the company. |
email | String | No | Email address of the company. |
phoneNumber | String | No | Phone number of the company. |
status | String | No | pending, active or inactive. |
notes | String | No | Internal notes about the company. |
logo | String | No | URL of the company logo. |
isTaxExempt | Boolean | No | Whether the company is tax exempt. |
taxExemptCode | String | No | Tax exemption code. |
taxExemptFileUrl | String | No | URL of the tax exemption certificate. |
companyGroup | String | No | ID of the company group to move the company to. |
priceLists | Array | No | IDs of price lists. Replaces the current list. |
productGroups | Object | No | Product visibility rules. Replaces the current rules. Same format as in Create Company. |
paymentMethods | Array | No | IDs of the payment methods the company may use. |
paymentAccess | Object | No | Payment method access rule. Same format as in Create Company. |
paymentTerms | Array | No | Payment terms. Replaces the current list. Same format as in Create Company. |
metaFields | Array | No | Custom field values as code and value. Listed codes are added or updated; other values are kept. |
parentCompanies | Array | No | The complete list of this company's direct parents, as company IDs. Parents not in the list are unlinked, new ones are linked, and parents already linked are left as they are. [] removes all parents. Leave the field out to keep the parents unchanged. null is rejected. Each ID may appear once, and the list cannot contain the company itself. |
corporateLinkAccess | Array | No | What each listed parent can do in this company. Only allowed together with parentCompanies, and every companyId must be in parentCompanies. See below. |
Corporate Link Access Object
| Field | Type | Required | Description |
|---|---|---|---|
companyId | String | Yes | A parent company. List each parent only once. |
allAccess | Boolean | No | true gives the parent's users every permission in this company. |
accessList | Array | No | Permission keys the parent's users get in this company. Unknown keys are rejected with ACCESS_UNKNOWN_KEYS. See Create Corporate for how allAccess and accessList work. |
A new link with no corporateLinkAccess entry gets all access. A link that already exists and has no entry keeps its current access. An entry for a parent that is already linked updates that link's access.
cURL Example
curl --location --request PUT '<BASE_URL>/companies/66b9b3b166169eecd60e5ba8' \
--header 'accessToken: <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"status": "inactive",
"notes": "Account on hold pending credit review.",
"metaFields": [{ "code": "erp_customer_id", "value": "12544" }]
}'
Response
- 200 OK: The company was updated successfully.
- 400 Bad Request: The access token is missing or invalid, the body is empty, a field is not valid, no company matches the ID or email, or a parent link is rejected. Every failure is
400, including authentication errors. Hierarchy failures also include acode. See Error Codes.
Sample JSON Response
{
"success": true,
"message": "Company updated successfully",
"data": {
"id": "66b9b3b166169eecd60e5ba8",
"entityId": 22,
"name": "Keystone Building Supply",
"email": "purchasing@keystonebuild.com",
"phoneNumber": "9085551234",
"status": "inactive",
"notes": "Account on hold pending credit review.",
"logo": null,
"isLock": false,
"priceLists": [],
"companyGroup": "66a6dd927d6c18df2d9eb836",
"shippingMethods": [],
"paymentMethods": [],
"paymentAccess": { "mode": "inherit", "methods": [] },
"paymentTerms": [],
"isSubCompany": false,
"parents": [],
"parentId": null,
"parentIds": [],
"isTaxExempt": false,
"taxExemptFileUrl": null,
"warehouses": [],
"metaFields": [
{
"metaFieldId": "6643a1f2e4b0a1b2c3d4e600",
"code": "erp_customer_id",
"label": "ERP Customer ID",
"displayStorefront": false,
"value": "12544",
"valueType": "text"
}
],
"createdBy": {
"id": "64f0a70c6212cdcbe89a2402",
"name": "ERP integration",
"type": "api"
},
"createdAt": "2024-08-12T07:03:13.111Z",
"updatedAt": "2024-10-09T13:05:59.036Z"
}
}
Response Details
| Field | Type | Description |
|---|---|---|
success | Boolean | Whether the request succeeded. |
message | String | Result message. |
data | Object | The updated company. |
Company Data
data has the same company fields as Get Company, except that companyGroup is the group ID and the addresses are not included. That includes parents, parentIds and parentId (deprecated, use parentIds).
The values come from a fresh read after the update, so parents, parentId, parentIds and isSubCompany reflect the saved state. This is true for every update, not only when parentCompanies is sent.
Notes
- To add, change or remove addresses, use the Address endpoints.
- If you send
paymentAccess,paymentMethodsis set to the methods in it. If you send onlypaymentMethods, the company is limited to those methods. parents,parentId,parentIdsandisSubCompanyare not accepted ("<field>" is not allowed). Set parents withparentCompanies. To set the sub-companies of a company, use Update Corporate.- One transaction. When
parentCompaniesis sent, the company's other fields and the parent links are saved together. If any link is rejected, nothing is saved, including the other fields in the same request. - Replace, not merge.
parentCompaniesis the full list. Sending a partial list unlinks the parents you left out, and removes their access and any per-user access in this company. To add one parent, readparentIdswith Get Company first and send the full list. - Unknown parents are rejected. A parent ID that does not exist returns
400. This differs fromsubCompanieson Create and Update Corporate, which skips unknown IDs. - A parent that has no corporate yet gets one automatically.
- Sending the same list again changes nothing.
- A chain can have at most 5 links, and a company cannot be its own ancestor.
- See Corporate Hierarchy and Access for the full rules.
Error Codes
Hierarchy failures return 400 with a code next to success and message.
code | When |
|---|---|
HIERARCHY_SELF | parentCompanies contains the company's own ID. |
HIERARCHY_CYCLE | A listed parent is a descendant of this company. |
HIERARCHY_TOO_DEEP | The change would make a chain longer than 5 links. |
ACCESS_UNKNOWN_KEYS | accessList contains a permission key that is not in the store's customer permissions. Keys are case-sensitive. |
USER_ERROR | Other rejected input, such as an unknown parent ID (Company <id> was not found.), a corporateLinkAccess.companyId that is not in parentCompanies, or a duplicate companyId. |
These failures have no code: an invalid body shape (null, bad IDs, duplicate IDs, corporateLinkAccess without parentCompanies), an unknown company in the path (Company not found), and a missing or insufficient token.
Match on code when it is present. Messages can change.
{
"success": false,
"message": "Acme East can't be added: it is already below Acme West.",
"code": "HIERARCHY_CYCLE"
}
Here Acme West is the company being updated (the id in the path), and Acme East, which is already below it, was sent in parentCompanies. Messages are built from company names, so the text changes per request. Other examples:
code | Example message |
|---|---|
HIERARCHY_SELF | A company can't be its own parent. |
HIERARCHY_TOO_DEEP | <name> can't be added: the chain below <top company> would be more than 5 levels deep. |
ACCESS_UNKNOWN_KEYS | Unknown permissions: <key>, <key>. |
USER_ERROR | Company <id> was not found. |
| none | Company not found (unknown company in the path) |
Set Parents Example
Give a company two parents in one call. Use keys from your store's customer permissions. See Permission keys.
curl --location --request PUT '<BASE_URL>/companies/66a000000000000000000001' \
--header 'accessToken: <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"parentCompanies": ["66a000000000000000000002", "66a000000000000000000003"],
"corporateLinkAccess": [
{ "companyId": "66a000000000000000000002", "allAccess": true },
{ "companyId": "66a000000000000000000003", "accessList": ["CREATE_ORDERS", "VIEW_OTHERS_ORDERS"] }
]
}'
The response, with other fields left out:
{
"success": true,
"message": "Company updated successfully",
"data": {
"id": "66a000000000000000000001",
"name": "Acme West",
"isSubCompany": true,
"parents": ["66a000000000000000000002", "66a000000000000000000003"],
"parentId": "66a000000000000000000002",
"parentIds": ["66a000000000000000000002", "66a000000000000000000003"]
}
}
To unlink one parent and keep the other, send the list without it:
{ "parentCompanies": ["66a000000000000000000002"] }