Skip to main content

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​

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

FieldTypeRequiredDescription
nameStringNoName of the company.
emailStringNoEmail address of the company.
phoneNumberStringNoPhone number of the company.
statusStringNopending, active or inactive.
notesStringNoInternal notes about the company.
logoStringNoURL of the company logo.
isTaxExemptBooleanNoWhether the company is tax exempt.
taxExemptCodeStringNoTax exemption code.
taxExemptFileUrlStringNoURL of the tax exemption certificate.
companyGroupStringNoID of the company group to move the company to.
priceListsArrayNoIDs of price lists. Replaces the current list.
productGroupsObjectNoProduct visibility rules. Replaces the current rules. Same format as in Create Company.
paymentMethodsArrayNoIDs of the payment methods the company may use.
paymentAccessObjectNoPayment method access rule. Same format as in Create Company.
paymentTermsArrayNoPayment terms. Replaces the current list. Same format as in Create Company.
metaFieldsArrayNoCustom field values as code and value. Listed codes are added or updated; other values are kept.
parentCompaniesArrayNoThe 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.
corporateLinkAccessArrayNoWhat each listed parent can do in this company. Only allowed together with parentCompanies, and every companyId must be in parentCompanies. See below.
FieldTypeRequiredDescription
companyIdStringYesA parent company. List each parent only once.
allAccessBooleanNotrue gives the parent's users every permission in this company.
accessListArrayNoPermission 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 a code. 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​

FieldTypeDescription
successBooleanWhether the request succeeded.
messageStringResult message.
dataObjectThe 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, paymentMethods is set to the methods in it. If you send only paymentMethods, the company is limited to those methods.
  • parents, parentId, parentIds and isSubCompany are not accepted ("<field>" is not allowed). Set parents with parentCompanies. To set the sub-companies of a company, use Update Corporate.
  • One transaction. When parentCompanies is 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. parentCompanies is 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, read parentIds with Get Company first and send the full list.
  • Unknown parents are rejected. A parent ID that does not exist returns 400. This differs from subCompanies on 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.

codeWhen
HIERARCHY_SELFparentCompanies contains the company's own ID.
HIERARCHY_CYCLEA listed parent is a descendant of this company.
HIERARCHY_TOO_DEEPThe change would make a chain longer than 5 links.
ACCESS_UNKNOWN_KEYSaccessList contains a permission key that is not in the store's customer permissions. Keys are case-sensitive.
USER_ERROROther 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:

codeExample message
HIERARCHY_SELFA 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_KEYSUnknown permissions: <key>, <key>.
USER_ERRORCompany <id> was not found.
noneCompany 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"] }